akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

typedef pair<int, int> P;
struct BIT {
  vector<long long> data;
  int n;
  BIT(int n) : n(n) {
    data.resize(n+1);
  }
  long long sum(int i) {
    long long s = 0LL;
    i++;
    for (int x=i; x>0; x-=x&-x) s += data[x];
    return s;
  }
  void add(int i, long long v) {
    i++;
    for (int x=i; x<=n; x+=x&-x) data[x] += v;
  }
};

int N;
P A[300000];
int B[300000];

bool f(long long X) {
  BIT s(N), v(N);
  for (int i=0; i<N; i++) {
    s.add(i, B[i]);
    v.add(i, 1);
  }
  for (int i=0; i<N-X+1; i++) {
    int x = A[i].second;
    long long b = (long long)A[i].first * X - x;
    int u = lower_bound(B, B+N, x) - B;
    s.add(u, -B[u]);
    v.add(u, -1);

    long long t = 0;
    if (X > 1) {
      int lo = 0, hi = N+1;
      while (hi - lo > 1) {
        int mid = (lo + hi) / 2;
        if (v.sum(mid) < X-1) lo = mid;
        else                  hi = mid;
      }
      t = s.sum(hi);
    }
    if (t <= b) return true;
  }
  return false;
}

int main() {
  cin >> N;
  for (int i=0; i<N; i++) {
    int a, b;
    cin >> a >> b;
    A[i] = P(b, a);
    B[i] = a;
  }
  sort(A, A+N);
  sort(B, B+N);

  int lo = 0, hi = N+1;
  while (hi - lo > 1) {
    int mid = (lo + hi) / 2;
    if (f(mid)) lo = mid;
    else        hi = mid;
  }
  cout << lo << "\n";
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> b(n);
    b = a;
    sort(b.begin(), b.end());
    reverse(b.begin(), b.end());
    int mx1 = b[0], mx2 = b[1];
    int id1 = -1;
    rep(i, n)
    {
        if (mx1 == a[i] && id1 == -1)
            id1 = i;
    }
    rep(i, n)
    {
        if (i == id1)
            cout << mx2 << endl;
        else
            cout << mx1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4844
N = int(input())
if N % 2 == 1:
    print(0)
else:
    N = N//2
    d = 5
    sum = 0
    while True:
        if N // d == 0:
            break
        else:
            sum = sum + (N // d)
            d = d * 5
    print(sum)


Measured memory_bytes: 2940
import itertools


N = int(input())

x, y = [None] * N, [None] * N
for i in range(N):
    x[i], y[i] = list(map(int, input().split()))

town_l = [i for i in range(N)]
V = list(itertools.permutations(town_l, N))
C = len(V)
a = 0
for v in V:
    for i in range(N - 1):
        a += ((x[v[i]] - x[v[i + 1]]) ** 2 + (y[v[i]] - y[v[i + 1]]) ** 2) **0.5

ans = a / C
print(ans)

Measured memory_bytes: 8180
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

//Ci:=最大値がiになる区間の個数
//求めるべき値はΣCi*i
//例えば2 1 5 7 3 4 6ならC7は16
//次に考えるべきは2 1 5と3 4 6の二つの区間。7をまたぐと最大値は7に変わるので考える必要がない
//abababaaaa←(x)baabaa a<=x b>x
//2番目に大きいという条件はbをちょうど一つ含む、ということ

int main() {
	int N; cin >> N;
	vector<int>a(N);
	REP(i, N)cin >> a[i];
	REP(i, N)a[i]--;
	vector<int>idx(N);
	REP(i, N)idx[a[i]] = i;
	set<int>s;
	ll ans = 0;
	for (int x = N - 1; x >= 0; --x) {
		int i = idx[x];
		ll c = 0;
		{//calc c
			s.insert(i);
			vector<int>l(2,-1);
			vector<int>r(2,N);
			{// calc l
				auto it = s.find(i);
				REP(j, 2) {
					if (it == s.begin())break;
					--it;
					l[j] = *it;
				}
			}
			{// calc r
				auto it = s.find(i);
				REP(j, 2) {
					++it;
					if (it == s.end())break;
					r[j] = *it;
				}
			}
			vector<int>ls(2);
			ls[0] = i-l[0];
			ls[1] = l[0] - l[1];
			vector<int>rs(2);
			rs[0] = r[0] - i;
			rs[1] = r[1] - r[0];
			c = (ll)ls[0] * rs[1] + (ll)ls[1] * rs[0];
		}
		ans += c * (x + 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5760
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

struct UnionFind {
    vector<int> par, rank;

    UnionFind(int n) : par(n, -1), rank(n, 0) {};
    void init(int n) { par.assign(n, -1), rank.assign(n, 0); }

    int root(int x) {
        if (par[x] == -1) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
    
};



int main() {
    int n, m; cin >> n >> m;
    UnionFind uf(n);
    rep(i,m) {
        int x, y, z; cin >> x >> y >> z;
        --x, --y;
        uf.merge(x,y);
    }
    set<int> s;
    int ans = 0;
    rep(i,n) {
        int x = uf.root(i);
        auto it = s.find(x);
        if (it == s.end()) {
            ++ans;
            s.insert(x);
        }

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





























Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define SYNC                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007s
#define all(c) c.begin(), c.end()
#define endl '\n'

typedef long long int lli;

int main()
{
    lli n,m;
    cin>>n>>m;

    lli arr[n];
    lli temp[n];
    for(lli i=0;i<n;i++)
    {
        cin>>arr[i];
        temp[i] = arr[i];
    }

    vector< pair<lli,lli> >myVec;
    
    for(lli i=0; i<n; i++)
    {
        while(temp[i] != 0)
        {
            lli x1 = temp[i];
            pair<lli,lli>p1;
            p1.first = x1-(x1/2);
            p1.second = i;
            myVec.push_back(p1);
            temp[i]/=2;
        }
    }

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

    lli j= 0;
    for(lli i = myVec.size() -1 ; i>= 0 ;i--)
    {
        if(j >=m )
            break;
            else {
                arr[myVec[i].second] -= myVec[i].first;
            }

        j++;    
    }

    lli sum = 0;
    
    for(lli i=0;i<n;i++)
        sum+= arr[i];


    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 69216
public class Main {
	 public static void main(String[] args) {
		    java.util.Scanner scanner = new java.util.Scanner(System.in);
		    int a = scanner.nextInt();
		    int b = scanner.nextInt();
		    int c = scanner.nextInt();
		    int d = scanner.nextInt();
		    int e = scanner.nextInt();
		    int f = scanner.nextInt();
		    
		    int a1 = 0;
		    int b1 = 0;
		    
		    double maxnoudo = 0;
		    int maxtotal = 100 * a;
		    int maxsatou = 0;
		    double limitnoudo = (double) (e * 100) / (double) (100 + e);
		    
		    while(true) {
		    	b1 = 0;
		    	if (100 * a * a1 > f) {
		    		break;
		    	}
		    	while(true) {
			    	int c1 = 0;
			    	int d1 = 0;
				    int mizu = 100 * ( a * a1 + b * b1);
				    if (mizu + c> f) {
				    	break;
				    }
				    while (true) {
				    	d1 = 0;
				    	if (mizu + c * c1 > f) {
				    		break;
				    	}
				    	while (true) {
						    int satou = c * c1 + d * d1;
						    int total = mizu + satou;
						    if (total > f) {
						    	break;
						    }
		//				    if ((satou * 100) > (e * mizu)) {
		//				    	break;
		//				    }
						    double noudo = (double) (satou * 100) / (double) total;
						    if (noudo > limitnoudo) {
						    	break;
						    }
						    if (noudo > maxnoudo) {
						    	maxnoudo = noudo;
						    	maxtotal = total;
						    	maxsatou = satou;
						    }
//						    if (c1 > d1) { c1--; d1++; } else { c1++; }
						    d1++;
				    	}
				    	c1++;
				    }
				    b1++;
	//			    if (a1 > b1) { a1--; b1++; } else { a1++; }
		 		}
		    	a1++;
		    }
		    System.out.println(maxtotal + " " + maxsatou);
		 }


}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
using std::cout;
using std::cin;
using std::endl;

int main(void){
    //cout << "main called" << endl;
    int N;
    std::vector<int> vec;
    int m1;
    cin >> N;

    for (int i = 0; i < N;i++){
        cin >> m1;
        vec.push_back(m1);
    }

    std::vector<int> queue = vec;
    std::sort(vec.begin(), vec.end());
    int med_r = vec[N / 2];
    int med_l=vec[N / 2 - 1];
    for(int i=0;i<N;i++){
        if(queue[i]<=med_l){
            cout << med_r << endl;
        }else{
            cout << med_l << endl;
        }
    }

    return 0;
}


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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N, mini = 2000, maxi = -1;
	
	cin >> N;
	
	rep(i, N){
		int a;
		cin >> a;
		mini = min(mini, a);
		maxi = max(maxi, a);
	}
	
	cout << maxi - mini << endl;
	
	return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

ll n;

ll m;

ll ans;

int main(void) {
  // Here your code !
  scanf("%lld", &n);

  m = n;

  ans = 0LL;

  ll base = (ll)(1e9);

  for (int i = 0; i < 10; ++i) {
    ll tmp = n / base;
    n -= tmp * base;
    ans += tmp;
    if (base == 1LL) break;
    base /= 10LL;  
  }

  if (m % ans == 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


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

int main() {
  int a,b;
  cin>>a>>b;
  if(b%a==0){
     cout<<a+b<<endl;
  }else{
     cout<<b-a<<endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main
{

    private final static int MOD = 1_000_000_007;

    public static int gcd(int a, int b) { 
        // Everything divides 0  
        if (a == 0) 
          return b; 
        if (b == 0) 
          return a; 
       
        // base case 
        if (a == b) 
            return a; 
       
        // a is greater 
        if (a > b) 
            return gcd(a-b, b); 
        return gcd(a, b-a); 
    }
    
    public static long mod(long a, long b) {
        return ((a % b) + b ) % b;
    }

    public static int mod (int a, int b) {
        return ((a % b) + b ) % b;
    }
    
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
	int a = in.nextInt();
	System.out.println((int)(Math.pow(a,2) + Math.pow(a,3) + a));
	in.close();
    }
}


Measured memory_bytes: 35840
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

ll GCD(ll a, ll b) {
  if (b == 0)
    return a;
  return GCD(b, a % b);
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll X;
  cin >> X;
  cout << 360 / GCD(X, 360) << endl;

  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
  string s;
  cin >> s;
  
  int n = s.length();
  
  int ans_a = 0;
  int ans_b = 0;
  
  //奇数0,偶数1
  for(int i=0;i<n;i++){
    if(i % 2 == 1){
      if(s[i] == '0'){
        ans_a++;
      }
    }
    if(i % 2 == 0){
      if(s[i] == '1'){
        ans_a++;
      }
    }
  }
  
  //奇数0,偶数1
  for(int i=0;i<n;i++){
    if(i % 2 == 0){
      if(s[i] == '0'){
        ans_b++;
      }
    }
    if(i % 2 == 1){
      if(s[i] == '1'){
        ans_b++;
      }
    }
  }
  
  cout << min({ans_a,ans_b}) << endl;
  
  return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

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



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



int main() {
	int n;
	cin >> n;
	
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int p;
		cin >> p;
		if (p != i + 1) {
			cnt++;
		}
	}

	if (cnt > 2) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
}


Measured memory_bytes: 3604
import sys

def resolve():
    S = input()
    N = len(S)
    arr = [0] * N

    target = "L"
    lastIndex = 0
    for i in range(N):
        if S[i] == target and target == "L":
            target = "R"
            for j in range(lastIndex, i):
                if (j-i) % 2 == 0:
                    arr[i] += 1
                else:
                    arr[i-1] += 1
            lastIndex = i
            if i == N-1:
                arr[i] += 1
        elif S[i] == target and target == "R":
            target = "L"
            for j in range(lastIndex, i):
                if (j-lastIndex) % 2 == 0:
                    arr[lastIndex] += 1
                else:
                    arr[lastIndex - 1] += 1
            lastIndex = i
        elif i == N-1:
            # このときの target は必ず R
            for j in range(lastIndex, N):
                if (j-lastIndex) % 2 == 0:
                    arr[lastIndex] += 1
                else:
                    arr[lastIndex - 1] += 1

    print(' '.join(map(str, arr)))


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 10612
package main
 
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func nextStr() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
 
func main() {
	sc.Split(bufio.ScanWords)
	bingo := make([]int, 9)
	exist := make([]bool, 9)
	res := "No"
	for i := 0; i < 9; i++ {
		bingo[i] = nextInt()
	}
 
	n := nextInt()
	for i := 0; i < n; i++ {
		num := nextInt()
		for j := 0; j < 9; j++ {
			if bingo[j] == num {
				exist[j] = true
				continue
			}
		}
	}
 
	for i := 0; i < 3; i++ {
		//横[0,1,2][3,4,5][6,7,8]
		if exist[i*3] && exist[i*3+1] && exist[i*3+2] {
			res = "Yes"
		}
		//縦[0,3,6][1,4,7][2,5,8]
		if exist[i] && exist[i+3] && exist[i+6] {
			res = "Yes"
		}
	}
	//斜[0,4,8][2,4,6]
	if exist[0] && exist[4] && exist[8] || exist[2] && exist[4] && exist[6] {
		res = "Yes"
	}
	fmt.Println(res)
}

Measured memory_bytes: 640
n=int(input())
s={}
for _ in range(n):
  b=tuple(sorted([i for i in input()]))
  if b in s:
    s[b]+=1
  else:
    s[b]=1
k=0
for i in s:
  j=s[i]
  k+=j*(j-1)//2
print(k)

Measured memory_bytes: 23524
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn=new Scanner(System.in);
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=stdIn.nextInt();
		for(int i=1;i<=n;i++){
			int x=i;
			if(x%3==0)
				System.out.print(" "+i);
			else{
				while(x!=0){
					if(x%10==3){
						System.out.print(" "+i);
						break;
					}
					x/=10;
				}
			}
		}
		System.out.println("");
	}	
}

Measured memory_bytes: 29016
import java.io.*;
import java.util.*;


class Main {
    static ArrayList<Integer>[]g;
    static int maxMatching(int v,int p){
        int a=0;
        int o=0;
        for(int w:g[v]){
            if(w==p)continue;
            int r=maxMatching(w,v);
            a+=r/2;
            o+=r%2;
        }
        return 2*a+Math.min(1,o)+1;
    }
    @SuppressWarnings("unchecked")
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        g=new ArrayList[n];
        Arrays.setAll(g,x->new ArrayList<Integer>());
        for(int i=0;i<n-1;++i){
            int a=sc.nextInt()-1;
            int b=sc.nextInt()-1;
            g[a].add(b);
            g[b].add(a);
        }
        int m=maxMatching(0,-1)/2;
        out.println(2*m==n?"Second":"First");
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

int main() {
  string s,t,u;
  cin >> s >> t >> u;
  if(s[s.size()-1]==t[0]&&t[t.size()-1]==u[0]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N - 1);
  map<int, int> boss;
  
  for (int i = 0; i < N - 1; i++) {
    cin >> A.at(i);
    boss[A.at(i)]++;
  }
  
  for (int i = 0; i < N; i++) {
    cout << boss[i + 1] << endl;
  }

}


Measured memory_bytes: 13556
M,D = map(int,input().split())
ans = 0
for i in range(1,M+1):
  for j in range(1,D+1):
    if len(str(j))>=2:
      if int(str(j)[0])>=2 and int(str(j)[1])>=2 and i == int(str(j)[1])*int(str(j)[0]):
        ans += 1
print(ans)

Measured memory_bytes: 3060
use whiteread::parse_line;

fn calc(n: usize, dp: &mut Vec<bool>, price: &[usize; 6]) -> bool {
    if !dp[n] && n > 105 {
        dp[n] |= match n % 5 {
            x @ 1..=4 => calc(n - price[x], dp, price),
            _ => calc(n - price[0], dp, price) | calc(n - price[5], dp, price),
        };
        /*
        for &p in price {
            if dp[n] {
                break;
            }
            dp[n] = dp[n] | calc(n - p, dp, price);
        }
        */
    }
    dp[n]
}

fn main() {
    let x: usize = parse_line().unwrap();
    let price: [usize; 6] = [100, 101, 102, 103, 104, 105];
    let mut dp: Vec<bool> = vec![false; x + 1];

    dp[0] = true;
    for &p in &price {
        let mut idx = 0;
        while idx <= x {
            dp[idx] = true;
            idx += p;
        }
    }

    calc(x, &mut dp, &price);
    if dp[x] {
        println!("1");
    } else {
        println!("0");
    }
}


Measured memory_bytes: 2188
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
const ll MOD = 1e9 + 7;
using namespace std;

int main() {
	//二日目
	ll n = 0, m = 0;
	ll kain = 1, kaim = 1;
	cin >> n >> m;
	if (abs(n - m) >= 2) {
		cout << 0 << endl;
		return 0;
	}
	else if (abs(n - m) == 1) {
		for (ll i = n; i >= 2; i--) {
			kain *= i;
			kain %= MOD;
		}
		for (ll i = m; i >= 2; i--) {
			kaim *= i;
			kaim %= MOD;
		}

		cout << (kain * kaim) % MOD << endl;
	}
	else {
		for (ll i = n; i >= 2; i--) {
			kain *= i;
			kain %= MOD;
		}
		for (ll i = m; i >= 2; i--) {
			kaim *= i;
			kaim %= MOD;
		}

		cout << (2 * (kain * kaim)) % MOD << endl;
	}
	return 0;
}

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

int main(){
    int N,u,v;
    cin >> N >> u >> v;
    vector<vector<int>> A(N);
    for(int i=0;i<N-1;i++){
        int a,b;cin>>a>>b;
        A[a-1].push_back(b-1);
        A[b-1].push_back(a-1);
    }
    queue<int> q1;
    q1.push(u-1);
    vector<int> D1(N,-1);
    D1[u-1]=0;
    while(q1.size()){
        int f=q1.front();
        q1.pop();
        for(int a:A[f]){
            if(D1[a]==-1){
                D1[a]=D1[f]+1;
                q1.push(a);
            }
        }
    }
    queue<int>q2;
    q2.push(v-1);
    vector<int>D2(N,-1);
    D2[v-1]=0;
    while(q2.size()){
        int f=q2.front();
        q2.pop();
        for(int a:A[f]){
            if(D2[a]==-1){
                D2[a]=D2[f]+1;
                q2.push(a);
            }
        }
    }
    
    vector<int> NG(N,0);
    int M=0,Mi=-1;
    for(int i=0;i<N;i++){
        NG[i]=(D2[i]-D1[i]<0);
        if((!NG[i]) && M<D2[i]){
            M=D2[i];
            Mi=i;
        }
    }
    if(NG[u-1]){
        cout << 0;
        return 0;
    }
    cout << D1[Mi]+(D2[Mi]-D1[Mi])-1 << "\n";
}

Measured memory_bytes: 7040
#include<iostream>

using namespace std;

int main(void){

    int n;

    cin >> n;

    int a; //??\????????????
    int M = -1000000;
    int m = 1000000;
    long long int S = 0; //?????????

    for(int i = 0; i < n; i++){

      cin >> a;
 
      if(M < a)M = a; //?????§???????±???????

      if(m > a)m = a; //????°????????±???????

      S = S + a; //???

    }

    cout << m << " " << M << " " << S << endl;

return 0;

}

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

n = INT()
p = LIST()

count = 0
for i in range(1, n - 1):
	if p[i - 1] < p[i] and p[i] < p[i + 1]:
		count += 1
	if p[i - 1] > p[i] and p[i] > p[i + 1]:
		count += 1

print(count)

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

typedef pair <long long, int> II;

const int N = 15;
const int M = (int) 1e3 + 5;
const long long INF = (long long) 1e15;

int n, m;
int a[M], b[M];
long long f[5010];
// vector <int> g[N];

int main() {
	//freopen("test.inp", "r", stdin);
	cin >> n >> m;
	for (int j = 0; j < (1 << n); j++) f[j] = INF;
	for (int i = 1; i <= m; i++) {
		cin >> a[i] >> b[i];
		int mask = 0;
		for (int j = 1; j <= b[i]; j++) { 
			int x; cin >> x;
			mask = (mask | (1 << (x - 1)));
		}
		// cout << mask << endl;
		f[mask] = min(f[mask], 1LL * a[i]);
	}
	priority_queue <II, vector <II>, greater <II> > q;
	for (int i = 0; i < (1 << n); i++)
		if (f[i] != INF) q.push(make_pair(f[i], i));
	while (!q.empty()) {
		int u = q.top().second;
		long long du = q.top().first;
		q.pop();
		if (du != f[u]) continue;
		for (int i = 0; i < (1 << n); i++) {
			int v = (i | u);
			if (f[v] > f[u] + f[i]) q.push(make_pair(f[v] = f[u] + f[i], v));
		} 
	}
	if (f[(1 << n) - 1] == INF) f[(1 << n) - 1] = -1;
	cout << f[(1 << n) - 1];
	return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        //List<int> values = new List<int>(Console.ReadLine().Split(' ').Select(s => int.Parse(s)));
        //List<int> values = new List<int>();

        string input = Console.ReadLine();
        int n = int.Parse(input.Split(' ')[0]);
        int m = int.Parse(input.Split(' ')[1]);
        int k = int.Parse(input.Split(' ')[2]);

        if (input == "5 5 7")
        {
            Console.WriteLine("YES"); return;
        }
        if (input == "5 7 5")
        {
            Console.WriteLine("YES"); return;
        }
        if (input == "7 5 5")
        {
            Console.WriteLine("YES"); return;
        }


        Console.WriteLine("NO");
        
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
#include <iomanip>
#include<sstream>
#include<string.h>
using namespace std;
int main()
{
    int p[25];
    ios::sync_with_stdio(0), cin.tie(0);
    int n, k, i, a, b;
    while (cin >> n)
    {
        k = 0;
        for (i = 0;i < n;i++)
            cin >> p[i];
        for (i = 1;i < n - 1;i++)
        {
            if (p[i] > p[i - 1] && p[i] < p[i + 1])
                k++;
            if (p[i] < p[i - 1] && p[i] > p[i + 1])
                k++;
        }
        cout << k << '\n';
    }
}

Measured memory_bytes: 256
while gets do
  a, b, c, d, e, f = $_.split(/\s/).map(&:to_f)

  z = b*d - a*e
  x = (b*f - c*e)/z + 0.000
  y = (c*d - a*f)/z + 0.000

  puts sprintf("%.3f\s%.3f", x, y)
end

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

using namespace std;

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

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256
use std::cmp;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let a: Vec<u32> = (0..n).map(|_| sc.read()).collect();
    let mut max_i = 0;
    for i in 0..n {
        if a[max_i] < a[i] {
            max_i = i;
        }
    }

    let max = a[max_i];
    let mut mid = if max_i == 0 { a[1] } else { a[0] };
    for i in 0..n {
        if i == max_i { continue; }
        if cmp::min(max - mid, mid) < cmp::min(max - a[i], a[i]) {
            mid = a[i];
        }
    }
    println!("{} {}", max, mid);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



Measured memory_bytes: 4352
"""
問題文
英大文字からなる文字列 S が与えられます。S の部分文字列 (注記を参照) であるような最も長い ACGT 文字列 の長さを求めてください。
ここで、ACGT 文字列とは A, C, G, T 以外の文字を含まない文字列です。
"""
import string
str_up = string.ascii_uppercase.replace("A","").replace("C","").replace("G","").replace("T","")
S = input()
part = []
for i in range(len(S)):
    for j in range(len(S)-i+1):
        part.append(S[i:i+j])
max_s = 0

for i in part:
    for j in str_up:
        if j in i:
            break
        elif j == "Z":
            if len(i) > max_s:
                max_s = len(i)
print(max_s)

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

#define MAX_N 1100
#define MAX_M 1100
const int INF = 100000000;

typedef pair<int, int> P;

char maze[MAX_N][MAX_M+1]; // 迷路を表す文字列の配列
int N, M;
int cnt, ans;
int d[MAX_N][MAX_M]; // 各点までの最短距離の配列
bool flag, check;

// 移動4方向のベクトル
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

// (sx, sy)から(gx, gy)への最短距離を求める
// たどり着けないとINF
int bfs(){
    queue<P> que;
    ans = 0;
    // 全ての点をINFで初期化
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            d[i][j] = INF;
            if(maze[i][j] == '#'){
                // スタート地点をキューに入れ、その点の距離を0にする
                que.push(P(i, j));
                d[i][j] = 0;
            }
        }
    }

    // キューが空になるまでループ
    while(que.size()){
        // キューの先頭を取り出す
        P p = que.front(); que.pop();
        // 取り出してきた状態がゴールなら探索をやめる
        //if(p.first == gx && p.second == gy) break;
        // 移動4方向をループ
        for(int i = 0; i < 4; i++){
            // 移動した後の点を(nx, ny)とする
            int nx = p.first + dx[i], ny = p.second + dy[i];
            maze[nx][ny] = '#';
            // 移動が可能かの判定とすでに訪れたことがあるかの判定(d[nx][ny] != INFなら訪れたことがある)
            if(0 <= nx && nx < N && 0 <= ny && ny < M && d[nx][ny] == INF){
                // 移動できるキューに入れ、その点の距離をpから距離+1で確定する
                que.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
        ans = d[p.first][p.second];
        /*
        for(int i = 0; i < N; i++){
            for(int j = 0; j < M; j++){
                cout << maze[i][j];
            }
            cout << endl;
        }
        cout << endl;

        for(int i = 0; i < N; i++){
            for(int j = 0; j < M; j++){
                cout << d[i][j];
            }
            cout << endl;
        }
        cout << endl;
        */
    }
    return ans;
}

void solve(){
    int res = bfs();
    printf("%d\n", res);
}

int main(){
    cin >> N >> M;
    for(int n = 0; n < N; ++n){
        for(int m = 0; m < M; ++m){
            cin >> maze[n][m];
        }
    }
    solve();
    return 0;
}


Measured memory_bytes: 13840
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a, b, c;
    int K;
    cin >> a >> b >> c;
    cin >> K;

    int sum = a + b + c;
    int mx = max(a, max(b, c));
    sum -= mx;
    while (K-- > 0) {
        mx <<= 1;
    }
    sum += mx;
    cout << sum << '\n';

    


    return 0;
}

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

// Common file
#include <ext/pb_ds/assoc_container.hpp>
// Including tree_order_statistics_node_update
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>



#define pb push_back
#define F first
#define S second
#define rep(i,n) for(int i = 0; i < (n); i++)

using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ReadFile            freopen("input.in","r",stdin)
#define WriteFile           freopen("output.txt","w",stdout)
const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi=acos(-1);
const ld rad=Pi/180.0;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
            y = y>>1;
            x = (x*x) % p;
    }
    return res;
}
ll nCr (ll n,ll m)
{
    return(m == 0)?1:n*nCr(n-1,m-1)/m;
}

/*****************************************************/

const int N = 1005;
int a[N] , n , k , ans = 0;

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

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

    sort(a , a + n);

    for(int i = 0; i < k; ++i)
        ans += a[i];

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3608
/*g++ main.cpp -o main.out*/
/*./main.out*/
/*std::ios::sync_with_stdio(false);cin.tie(0);*/

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

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define ree(n,a) memset(n,a,sizeof(n));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    LL N,a=0,cnt=0;
    cin>>N;
    red(i,sqrt(N),1)if(N%i==0)
    {
        a=N/i;
        break;
    }
    while(a>0)
    {
        a/=10;
        cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

#define FREE -1
#define NOT_FREE 0
#define N 8
 
 
int row[N],col[N],pos[2*N-1],neg[2*N-1];
int sol[N];

void init(){
  for(int i=0;i<N;i++) sol[i] = row[i] = col[i] = FREE;
  for(int i=0;i<2*N-1;i++) pos[i]= neg[i] = FREE;
}

void printBoard(){
  int i,j;

  for (i=0;i<N;i++){
    if (sol[i] != FREE){
      if(sol[i] != row[i]) return;
    } 
  }
  
  for (i=0;i<N;i++){
    for (j=0;j<N;j++){
      if (row[i]==j) cout << "Q";
      else cout << ".";
    }
    cout << endl;
  } 
}

void nqueen(int i){
  int j;
  if (i == N){
    printBoard();
    return;
  }
  for (j = 0; j < N; j++){
    if(col[j] == NOT_FREE ||
       pos[i+j] == NOT_FREE ||
       neg[i-j+N-1]==NOT_FREE) continue;
    row[i] = j;
    col[j] = pos[i+j] = neg[i-j+N-1] = NOT_FREE;
    nqueen(i+1);
    col[j] = pos[i+j] = neg[i-j+N-1] = FREE;
  }
}

int main(){
  int k,r,c;
  
  init();
  cin >> k;
  
  for (int i = 0; i < k; i++){
    cin >> r >> c;
    sol[r]=c; 
  }
  nqueen(0);
  return 0;
}




Measured memory_bytes: 3108
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        x.abs()
    } else {
        gcd(y, x % y)
    }
}

fn main() {
    let N = read!(usize);
    let A = read![[i64]];

    let mut X = vec![0; N];
    let mut Y = vec![0; N];

    X[0] = A[0];
    for i in 0..N - 1 {
        X[i + 1] = gcd(X[i], A[i + 1]);
    }

    Y[N - 1] = A[N - 1];
    for i in (1..N).rev() {
        Y[i - 1] = gcd(Y[i], A[i - 1]);
    }

    // debug!(X, Y);

    let mut max_g = 0;
    for i in 0..N {
        let g = if i == 0 {
            Y[1]
        } else if i == N - 1 {
            X[N - 2]
        } else {
            gcd(X[i - 1], Y[i + 1])
        };
        max_g = max(max_g, g);
    }

    println!("{}", max_g)
}


Measured memory_bytes: 8444
#include <stdio.h>
#include <string.h>

int max(int a, int b)
{
    return (a > b ? a : b);
}

int main(void)
{
    int n, t, s;
    int a[3001], b[3001];
    int dp[3001];
    int res;
    int i, j;
    
    scanf("%d%d%d", &n, &t, &s);
    
    memset(dp, 0, sizeof(dp));
    
    res = 0;
    
    for (i = 0; i < n; i++){
        scanf("%d%d", &a[i], &b[i]);
        
        for (j = t - b[i]; j >= 0; j--){
            if (!(j < s && s < j + b[i])){
                dp[j + b[i]] = max(dp[j + b[i]], dp[j] + a[i]);
                res = max(dp[j + b[i]], res);
            }
        }
    }
    
    printf("%d\n", res);
    
    return (0);
}

Measured memory_bytes: 752
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int > pp;
typedef long long ll;
 
#define sz(x) (int)x.size() 
int const N=3e5+10,oo=1e9;
ll const OO=2e18;
double const eps=1e-8,PI=acos(-1);
int mod=oo+7;

int cum[N];
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin>>n;
  string s;
  cin>>s;
  for(int i=0;i<n;i++)cum[i+1]=cum[i]+(s[i]=='.');
  int an=min(cum[n],n-cum[n]);
  for(int i=0;i<n;i++)an=min(an,i+1-cum[i+1]+cum[n]-cum[i+1]);
  cout<<an;
  return 0;
}

Measured memory_bytes: 1300
using System;

namespace AOJ.Volume0
{
    public class SurfSmeltFishingContest
    {
        public static void Main()
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }

                int line_num = int.Parse(input);
                int id = line_num + 1;
                int count = 0;
                for (int i = 0; i < line_num; i++)
                {
                    input = Console.ReadLine();
                    var data = input.Split(' ');
                    int id_tmp = int.Parse(data[0]);
                    int count_tmp = int.Parse(data[1]);
                    if (count_tmp >= count)
                    {
                        if (count_tmp == count) { id = Math.Min(id, id_tmp); }
                        else { id = id_tmp; }
                        count = count_tmp;
                    }
                }

                Console.WriteLine(string.Format("{0} {1}", id, count));
            }
        }
    }
}

Measured memory_bytes: 9228
#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
const double pie  =3.141592653589793238463;
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define POP(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define ef else if
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(),A.end());
#define REV(A) reverse(A.begin(), A.end());
#define lenth length()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n" 
const ll dx[4] = { -1, 1, 0, 0};
const ll dy[4] = {0, 0, -1, 1};
ll XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
ll YY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
#define precise(x) cout<<fixed<<setprecision(x)
#define t1(x)                cerr<<#x<<": "<<x<<endl
#define t2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define t4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define t5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define t6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
void SieveOfEratosthenes(ll n) 
{ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // for (ll p=2; p<=n; p++) 
       // if (prime[p]) 
          // cout << p << " "; 
} 
ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
  
int main()
{
    fastio
    long long int t,i,j,k,l,m,n,a,x,b,y,z,c,h,d,f,e,p,o,nl,np,q,r,g;
    cin>>n;
    cout<<n*n*n<<endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
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; }
using namespace std;

int N;
string s;
map<string, int> m;

// x個の中から二つを選ぶ方法
int comb(int x) {
    return x * (x - 1) / 2;
}

int main() {
    cin >> N;
    ll ans = 0;
    rep(i, N) {
        cin >> s;
        sort(s.begin(), s.end());
        ans += m[s]++;
        // if (m.count(s) > 0) {
        //     m[s]++;
        // } else {
        //     m[s] = 1;
        // }
    }
    // for (const auto &x: m) {
    //     ans += comb(x.second);
    // }
    cout << ans << endl;
}


Measured memory_bytes: 11136
/*
Problem:AtCoder 084 c
Algorithm:Binary Search
Status:
*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <utility>
#include <list>
#include <ctime>
#include <memory.h>
#include <stack>
#include <stdio.h>
#include <string.h>

using namespace std;

const int INF=1e9+7;

int a[100005],b[100005],c[100005];

int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%d",&b[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%d",&c[i]);
	}
	sort(a,a+n);
	sort(b,b+n);
	sort(c,c+n); 
	
	long long ans=0;
	for(int j=0;j<n;j++){
		int i=lower_bound(a,a+n,b[j])-a;
		int k=upper_bound(c,c+n,b[j])-c;
		k=n-k;
		ans+=(long long)i*k;
	}
	cout<<ans;
	return 0;
}


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

int main()
{
    string S;
    cin >> S;
    int ans = 0;
    for (int i=0; i<S.size(); ++i){
        if (S[i] == 'o')
            ans++;
    }
    cout << 700 + ans * 100 << endl;
    return 0;
}

Measured memory_bytes: 256