akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
ll mod = 1e9 + 7;

int modPow(long long a, long long n, long long p = mod) {
  if (n == 0) return 1;  // 0乗にも対応する場合
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  long long t = modPow(a, n / 2, p);
  return (t * t) % p;
}

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

  cout << ((modPow(10, n) - 2 * modPow(9, n) + mod) % mod + modPow(8, n) +
           mod) %
              mod
       << endl;
}

Measured memory_bytes: 3628
// Math = ♥
// Sometimes it is people that no one imagines anything of who do things that no one can imagine
// After all this time? Always

#include <bits/stdc++.h>                        // uncomment before submission
//#include <ext/pb_ds/assoc_container.hpp>		// uncomment before submission
//#include <ext/pb_ds/tree_policy.hpp>			// uncomment before submission
//using namespace __gnu_pbds;					// uncomment before submission
using namespace std;
//<---------------------------------------------------Template----------------------------------------------------------->
#define int long long
#define ll long long
#define ld long double
const int INF = 1e5 + 7;
const int MAX = 1e2 + 7;
const int MOD = 1e9 + 7;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;                  // Vector of long long
typedef vector<vi> vvi;                 // Vector of vi
typedef vector<ii> vii;                 // Vector of pairs
typedef vector<vii> vvii;               // Vector of Vector of pairs
typedef vector<bool> vb;                // Vector of bool
#define pq priority_queue               // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                        // For pairs
#define ss second                       // For pairs
#define pb push_back                    // Pushback to vector
#define mp make_pair                    // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()   // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//<----------------------------------------------------------------------------------------------------------------------->

int w[MAX] = {0}, v[MAX] = {0};
int f[MAX][INF] = {0};
int N, W;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> W;

    for (int i = 1; i <= N; i++) cin >> w[i] >> v[i];

    for (int i = 0; i <= N; i++)
        for (int k = 0; k <= W; k++)

            if (i == 0 || k == 0)
                f[i][k] = 0;
            else if (w[i] <= k)
                f[i][k] = max(f[i - 1][k], f[i - 1][k - w[i]] + v[i]);
            else
                f[i][k] = f[i - 1][k];

    cout << f[N][W] << endl;
    return 0;
}


Measured memory_bytes: 80128
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      mut aa: [usize; n],
    }

    aa.sort();
    let ans = aa[n-1] - aa[0];
    puts!("{}\n", ans);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  int y, m, d;
  scanf("%d/%d/%d", &y, &m, &d);

  if (m >= 5) {
    cout << "TBD" << endl;
  } else {
    cout << "Heisei" << endl;
  }

  return 0;
}


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

inline char c_c(char a){
  return (char)(a+('A'-'a'));
}

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  cout << c_c(a.at(0)) << c_c(b.at(0)) << c_c(c.at(0)) << endl;
  return 0;
}


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

int main() {
  ll x,k,d;
  cin >> x >> k >> d;
  ll l = abs(x);
  ll ans = l%d;
  if(k-l/d <= 0){
    cout << l-k*d << endl;
    return 0;
  }
  if((k-l/d)%2 == 1) ans = abs(ans-d);
  cout << ans << endl;
}

Measured memory_bytes: 3648
a, b, c = map(int, input().split())
k = int(input())

ans = 0
for i in range(1000):
    if a >= b:
        ans += 1
        b *= 2
    else:
        break
for i in range(1000):
    if b >= c:
        ans += 1
        c *= 2
    else:
        break

if ans <= k:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9184
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    X = I()
    year = 0
    yokin = 100
    while yokin<X:
        yokin = int(yokin*1.01)
        year += 1

    print(year)

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 9240
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    int a[110];
    cin >> N;
    rep(i,0,N){
        cin >> a[i];
    }
    sort(a, a+N);
    int color[8] = {};
    ll over_red = 0;
    rep(i,0,N){
        if(a[i] < 400) color[0]++;
        else if(a[i] < 800) color[1]++;
        else if(a[i] < 1200) color[2]++;
        else if(a[i] < 1600) color[3]++;
        else if(a[i] < 2000) color[4]++;
        else if(a[i] < 2400) color[5]++;
        else if(a[i] < 2800) color[6]++;
        else if(a[i] < 3200) color[7]++;
        else over_red++;
    }
    int variation = 0;
    rep(i,0,8){
        if(color[i] > 0) variation++;
    }
    if(over_red == 0){
        cout << variation << " " << variation << endl;
    }else if(variation == 0){
        cout << 1 << " " << over_red << endl;
    }else{
        cout << variation << " " << variation + over_red << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<ll> a,b;
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        a.push_back(x+y);
        b.push_back((x-y));
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    ll maxip = (a[n-1] - a[0]);
    ll maixn = (b[n-1] - b[0]) ;
    ll ans = max(maxip,maixn);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 6664
#include<bits/stdc++.h>
using namespace std;
#define gc() getchar()
#define pc(a) putchar(a)
#define int long long
#define inf (1ll<<60)
inline int read()
{
    int x=0,f=1;
    char c=gc();
    while(c>'9'||c<'0')
    {
        if(c=='-') f=-f;
        c=gc();
    }
    while(c>='0'&&c<='9') x=x*10+c-'0',c=gc();
    return x*f;
}
int Num[25];
inline void write(int x)
{
    if(!x) {pc('0');return;}
    if(x<0) x=-x,pc('-');
    int top=0;
    while(x) Num[++top]=x%10,x/=10;
    while(top) pc(Num[top--]+'0');
    return;
}
#define ma 300005

signed main()
{
   int n=read();
   int ans=0;
    for(int A=1;A<=n;A++)
		ans+=n/A-(n%A==0);
	write(ans);
}










Measured memory_bytes: 3632
// Code for D - Alter Altar
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,x,y) for(ll i=x;i<(ll)(y);i++)

#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

int main() {
  int N;
  string c;
  cin >> N;
  cin >> c;

  int rc = 0;
  int wc = 0;

  REP(i, N) {
    if (c[i] == 'R') {
      rc++;
    } else {
      wc++;
    }
  }

  int rcd = 0;
  int wcd = 0;
  REP(i, rc) {
    if (c[i] == 'W') {
      rcd++;
    }
  }

  REP(i, wcd) {
    if (c[rc + i] == 'R') {
      wcd++;
    }
  }

  cout << max(rcd, wcd) << endl;
  return 0;
}


Measured memory_bytes: 3744
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	string S;
	cin >> S;

	int ans = 0;
	int N = S.size();
	int i = 0;
	int tmp;

	
	while (i < N) {

		int a = 1;
		if (i != 0 && S[i - 1] == S[i]&&tmp==1) {
			i++;
			a++;
		}
		//if (S[i - 1] == S[i] && i == N - 1)ans--;
		//cout << i << endl;
		//cout <<i<<" " << tmp << endl;
		tmp = a;
		ans++;
		if (i >= N)ans--;
		i++;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 720
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;

const ll MOD = 998244353;

int main()
{
    ll n;
    cin >> n;
    ll d[100002];
    ll b[100002] {0};
    ll lar = 0;
    for(int i = 0; i < n; i++){
        cin >> d[i];
        b[d[i]]++;
        lar = max(lar, d[i]);
    }
    if(d[0] != 0 || b[0] >= 2){
        cout << 0 << endl;
        return 0;
    }
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    ll ans = 1;
    for(int i = 1; i < n; i++){
        for(int j = 0; j < b[i]; j++) ans = ans * b[i - 1] % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
from collections import deque, Counter
n, x, y = map(int, input().split())
edge = [[] for i in range(n)]

for i in range(n-1):
    edge[i].append(i+1)
    edge[i+1].append(i)
edge[x-1].append(y-1)
edge[y-1].append(x-1)

def bfs(i):
    dq = deque([i])
    dist = [-1]*n
    dist[i] = 0
    while dq:
        now = dq.popleft()
        d = dist[now]
        for e in edge[now]:
            if dist[e]==-1:
                dist[e] = d + 1
                dq.append(e)
    return dist

c = Counter()
for i in range(n):
    c = c + Counter(bfs(i))

for i in range(1, n):
    print(c[i]//2)


Measured memory_bytes: 94684
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string a;
  cin>>a;
  int f=0,c=0;
  if(a[2]==a[3])
  	f=1;
  if(a[4]==a[5])
    c=1;
  if(f==1 && c==1)
    cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 256
use proconio::{input, fastout};

#[fastout]
fn main() {
    input!{
        p: i32,
        q: i32,
	r: i32,
    }
    let a = p + q;
    let b = q + r;
    let c = r + p;
    let v: Vec<i32> = vec![a, b, c];
    println!("{}", v.iter().min().unwrap());
}


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

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

  if(s[0] == *(s.end()-1)){
    if(s.size() % 2 == 0){
      cout << "First" << endl;
    }else{
      cout << "Second" << endl;
    }
  }else{
    if(s.size() % 2 == 1){
      cout << "First" << endl;
    }else{
      cout << "Second" << endl;
    }
  }

}


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

int main() {
    
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i < N;i++)cin >> A[i];
    
    //bool flag;
    for(int i = 0; i < K;i++){
        vector<int> B(N,0);
        for(int j = 0; j < N;j++){
            int l = max(0,j-A[j]);
            int r = min(N-1,j+A[j]);
            B[l]++;
            if(r+1<N)B[r+1]--;
        }
        int sum = B[0];
        for(int i = 1; i < N;i++){
            B[i]+=B[i-1];
            sum += B[i];
        }
        for(int i = 0; i < N;i++){
            A[i] = B[i];
        }
        
        if(sum == N*N)break;
    }
    
    for(int i = 0; i < N;i++){
        if(i!=N-1)cout <<A[i] <<" ";
        else cout << A[i] << endl;
    }
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  
  vector<queue<int>> x(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int a;
      cin >> a;
      x.at(i).push(a);
    }
  }
  
  int ans = n;
  vector<bool> used(m + 1, false);
  for (int i = 0; i < m; i++) {
    vector<int> count(m + 1);
    for (int j = 0; j < n; j++) {
      count.at(x.at(j).front())++;
    }
    int maximum = 0, value = 0;
    for (int j = 1; j <= m; j++) {
      if (count.at(j) > maximum) {
        maximum = count.at(j);
        value = j;
      }
    }
    used.at(value) = true;
    ans = min(ans, maximum);
    bool flag = false;
    for (int j = 0; j < n; j++) {
      while (!x.at(j).empty() && used.at(x.at(j).front())) {
        x.at(j).pop();
      }
      if (x.at(j).empty()) flag = true;
    }
    if (flag) break;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 768
import java.util.Scanner;
class Main{


	static char[][] map;

	static long[][] c;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0;i < n;i++){
			a[i] = sc.nextInt();
		}
		int[] ans = new int[n];
		ans[0] = 0;
		for(int i = 0;i < n;i++){
			if(i % 2 != 0){
				ans[0] -= a[i];
			}else{
				ans[0] += a[i];
			}
		}
		for(int i = 1;i < n;i++){
			ans[i] = (a[i-1] - ans[i-1]/2)*2;
	//		System.out.println(ans[i] + " " +i );

		}
		for(int i = 0;i < n;i++){
			System.out.print(ans[i] + " ");
		}

		
	}
	
	static boolean judge(int num){
		
		for(int i = 1;i*i <= num;i++){
			if(i*i == num){
				return true;
			}
		}
		
		return false;
		
		
	}


	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   end- otherpair.end;
	}







	static int find(int index,int current,int[] students,int ans,int[][] memo){
		if(current == index){
			return 1;
		}

		if(memo[current][index] != 0){
			return memo[current][index];
		}

		memo[current][index] = find(index, students[current]-1, students, ans+1, memo)+1;

		return memo[current][index];
	}



	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}






Measured memory_bytes: 63896
def main():
    NEG = -10**6
    H, W = map(int, input().split())
    S = [input() for _ in range(H)]
    T = [[NEG] * W for _ in range(H)]
    for w in range(W):
        b = NEG
        for h in range(H):
            if S[h][w] == '.':
                if b == NEG:
                    b = h
            else:
                if b != NEG:
                    for j in range(b, h):
                        T[j][w] = h - b
                    b = NEG
        if b != NEG:
            for j in range(b, h + 1):
                T[j][w] = h + 1 - b
    m = 0
    for s, t in zip(S, T):
        b = NEG
        for i in range(len(s)):
            if s[i] == '#':
                if b != NEG:
                    m = max(m, i - b - 1 + max(t[b:i]))
                    b = NEG
            else:
                if b == NEG:
                    b = i
        if b != NEG:
            m = max(m, i - b + max(t[b:i + 1]))
    print(m)

main()


Measured memory_bytes: 165876
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
 
int main() {
    int n;
    cin>>n;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
t[99],h[99];
main(i,s,N,T,L){
for(scanf("%d%d%d%d",&N,&T,&L,&L),i=0;i<N;i++)scanf("%d%d",t+i,h+i);
for(i=s=0;;i=(i+1)%N)if(t[i]){
    t[i]--;
    if(++T>L)break;
    if(++s==9)s=0;
}else if(h[i]){
    h[i]--;s++;
    if(T<s)break;
    t[i]=s;T-=s;s=0;
}else break;
printf("%d\n",i+1);exit(0);}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
#define fi first
#define se second
#define mod 1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
map<string,ll> mp;
int main()
{
	ios;
	ll n,i;
	string s;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>s;
		mp[s]++;
	}
	cout<<mp.size()<<endl;
}


Measured memory_bytes: 19280
n = int(input())

if n % 2 == 0:
    n5 = 1
    y = 10
    c = []

    while y <= n:
        c.append(n//y)
        if len(c) > 1:
            c[-2] -= c[-1]
        y *= 5

    cnt = 0
    for i in range(len(c)):
        cnt += c[i]*(i+1)

    print(cnt)
else:
    print(0)

Measured memory_bytes: 9064
N,M = map(int,input().split())
h = list(map(int,input().split()))
bri = [[0]*2 for i in range(M)]
lis = [1]*N
for i in range(M):
    a,b = map(int,input().split())
    bri[i][0] = a
    bri[i][1] = b

for i in range(M):
    if h[bri[i][0]-1] > h[bri[i][1]-1]:
        lis[bri[i][1]-1] = 0
    elif h[bri[i][0]-1] < h[bri[i][1]-1]:
        lis[bri[i][0]-1] = 0
    else:
        lis[bri[i][0]-1] = 0
        lis[bri[i][1]-1] = 0




print(sum(lis))



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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    unordered_map<char, vector<int> > m;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='R'){
            m['R'].push_back(i);
        }
        else if(s[i]=='B'){
            m['B'].push_back(i);
        }
        else{
            m['G'].push_back(i);
        }
    }
    ll ans=0;
    for(int i=0; i<m['G'].size(); i++){
        for(int j=0; j<m['R'].size(); j++){
            int left = m['R'][j];
            int right = m['G'][i];
            if(left>right){
                swap(left, right);
            }
            ans+=m['B'].size();
            if(binary_search(m['B'].begin(), m['B'].end(), left-(right-left))){
                ans-=1;
            }
            if(binary_search(m['B'].begin(), m['B'].end(), right+(right-left))){
                ans-=1;
            }
            if(((right-left)%2==0)&&(binary_search(m['B'].begin(), m['B'].end(), (left+(right-left)/2)))){
                ans-=1;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

string S;

signed main(){
    cin>>S;
    if(S=="ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;



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

	int a[20][20];
	int b[20];

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

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int check = 0;
		for (int j = 0; j < m; j++) {
			check += a[i][j] * b[j];
		}
		if (check + c > 0) { ans++; }
	}

	cout << ans << endl;










}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    ll n; cin >> n;
    ll m = 1;
    vector<ll> v(n);
    ll ans = 0;
    REP(i,n) {
        cin >> v[i];
        ans += v[i]-1;
    }

    cout << ans << '\n';


    return 0;
}

Measured memory_bytes: 256
from collections import deque

n = int(input())
t = [list() for _ in range(n)]
color = [0] * (n-1)

for i in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    t[a].append((b, i))
q = deque([(0, 0)])
while q:
    v, pc = q.popleft()
    nc = 0
    for nv, edge in t[v]:
        nc += 1
        if nc == pc:
            nc += 1
        color[edge] = nc
        q.append((nv, nc))

print(max(color))
print(*color, sep="\n")


Measured memory_bytes: 65952
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int h,w;cin >> h >> w;
  vector<vector<char>> s(h,vector<char>(w));
  rep(i,h) rep(j,w) cin >> s[i][j];

  vector<vector<int>> dp(h,vector<int>(w,1e+9));
  if(s[0][0] == '#') dp[0][0] = 1;
  else dp[0][0] = 0;
  rep(i,h) rep(j,w){
    if(i+1<h){
      if(s[i][j] == '.' && s[i+1][j] == '#') dp[i+1][j] = min(dp[i+1][j],dp[i][j]+1);
      else dp[i+1][j] = min(dp[i+1][j],dp[i][j]);      
    }
    if(j+1<w){
       if(s[i][j] == '.' && s[i][j+1] == '#') dp[i][j+1] = min(dp[i][j+1],dp[i][j]+1);
      else dp[i][j+1] = min(dp[i][j+1],dp[i][j]);      
    }    
  }

  cout << dp[h-1][w-1] << "\n";
  
  return 0;
}


Measured memory_bytes: 256
//In the name of Allah
#include <bits/stdc++.h>
using namespace std;
#define MAX 200011
#define mod 1000000007
#define inf 1000000000000000
#define ll long long
#define endl '\n'
ll dp[MAX];
int h[MAX],w[MAX];
void update(int i,ll v){
	for(; i < MAX; i += (i&(-i)))dp[i] = max(dp[i],v);
}
ll get(int i){
	ll ans = 0;
	for(; i > 0 ; i -= (i&(-i)))ans = max(ans,dp[i]);
	return ans;
}

int main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i = 0; i < n; i++)cin>>h[i];
	for(int i = 0; i < n; i++)cin>>w[i];
	update(h[0],w[0]);	
	for(int i = 1; i < n; i++)
		update(h[i],get(h[i] - 1) + w[i]);
	cout<<get(n);
	return 0; 
} 

Measured memory_bytes: 3328
from collections import Counter
class uf(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
    def is_same(self, x, y):
        return self.find(x) == self.find(y)

def alte(h,w,s):
    ufa=uf(h*w)

    for x in range(h):
        for y in range(w):
            if s[x][y]!=s[min(x+1,h-1)][y]:
                ufa.union(x*w+y,x*w+y+w)
            if s[x][y]!=s[x][min(y+1,w-1)]:
                ufa.union(x*w+y,x*w+y+1)

    cnta=Counter()
    cntb=Counter()

    for x in range(h):
        for y in range(w):
            k = x*w+y
            if s[x][y] == '.':
                cnta[ufa.find(k)] += 1
            else:
                cntb[ufa.find(k)] += 1

    cnt=0
    for i in range(h*w):
        cnt+=cnta[i]*cntb[i]

    return cnt

h,w=map(int,input().split())
print(alte(h,w,[input() for i in range(h)]))

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

int main(){
    int H, W;
    int a[600][600], b[600][600];
    cin >> H >> W;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> a[i][j];
            b[i][j]=a[i][j];
        }
    }
    
    int sum[600], sum2[600]; //各行の和
    for(int i=0; i<H; i++){
        sum[i]=0;
        for(int j=0; j<W; j++){
            sum[i] += a[i][j];
        }
        sum[i] %=2;
        sum2[i]=sum[i];
    }

    int cnt =0;
    for(int i=0; i<H; i++){
        for(int j=0; j<W-1; j++){
            if(a[i][j]%2==1){
                a[i][j]--;
                a[i][j+1]++;
                cnt++;
            }
        }
    }
    for(int i=0; i<H-1; i++){
        if(sum[i]%2==1){
            sum[i+1]=1-sum[i+1];
            cnt++;
        }
    }

    cout << cnt <<endl;

    for(int i=0; i<H; i++){
        for(int j=0; j<W-1; j++){
            if(b[i][j]%2==1){
                b[i][j]--;
                b[i][j+1]++;
                cout << i+1 << " " << j+1 << " " << i+1 << " " << j+2 << endl; 
            }
        }
    }
    for(int i=0; i<H-1; i++){
        if(sum2[i]%2==1){
            sum2[i+1]=1-sum2[i+1];
            cout << i+1 << " " << W << " " << i+2 << " " << W << endl;    
        }
    }
}


Measured memory_bytes: 4864
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<map>
#include<stack>
#include<vector>
#include<queue>
using namespace std;
int main(){
	int n;
	cin>>n;
	int sum=0;
	for(int i=1;i<=n;i=i+2){
		int ans=0;
			for(int j=1;j<=n;j++){
				if(i%j==0)
				ans++;
			}
			if(ans==8)
			sum++;
	}
	printf("%d",sum);
	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <ctype.h>
using namespace std;

typedef long long ll;

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

int m[1010];

int main() {
  int a, b;
  cin >> a >> b;
  double ave = (a + b) / 2.0;
  cout << ceil(ave) << endl;
  return 0;
}


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

int main()
{
	int n;
	cin>>n;
	vector<int>h(n);
	for(auto& e:h){
		cin>>e;
	}
	for(int i=n-2;i>=0;i--){
		int right=h.at(i+1);
		int& m=h.at(i);
		int left;
		if(i==0){
			left=0;
		}else{
			left=h.at(i-1);
		}
		if(m-right>=2){
			cout<<"No"<<endl;
			return 0;
		}else if(m-right==1){
			m--;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;
const int MAX_N = (int)1e5 + 10;

int N,M;
// Graph (隣接リスト)
vector<int> G[MAX_N];

// dp[v]: ノードvを始点としたときのGの有向パス長のmax
int dp[MAX_N];
// メモ化再帰
int rec(int v)
{
  if (dp[v] != -1) return dp[v]; //計算済み(1度以上？？)

  int res = 0;
  // vに隣接する全ノード
  for (auto u : G[v]) {
    chmax(res, rec(u) + 1);
  }
  // 更新は最後にする
  dp[v] = res;
  return res;
}

int main()
{
  cin >> N >> M;
  REP(i,0,M) {
    int x,y;
    cin >> x >> y;
    --x; --y;
    // xからyへの有向辺
    G[x].push_back(y);
  }

  REP(i,0,N) dp[i] = -1; // 未計算は-1

  // G の有向パスのうち、最長のものの長さ
  int ans = -1;
  // トポロジカルソートで最初になる頂点vが現れた時点で計算は終わる
  REP(v,0,N) chmax(ans, rec(v));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int cnb = 0;
  int cnw = 0;
  for(int i = 0; i < s.length(); i++){
    if(i%2 == 0){
      if(s[i] == '1')
        cnb++;
      else
        cnw++;
    }
    else{
      if(s[i] == '0')
        cnb++;
      else
        cnw++;
    }
  }
  cout << min(cnb, cnw) << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <math.h>
#include <cmath>
#include <ctime>
#include <stdlib.h>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define m_t make_tuple
#define rep(i,n)  for(int i=0; i<(int) (n); i++)

const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 1000000021;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	return lower_bound(all(vec), xx) - vec.begin();
}
template<typename T>void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>void vecin(vector<TT>& vec) {
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}
template<class tt> struct counter {
	map<tt, int>mp;
	bool add(tt t, int xx) {
		if (!mp.count(t)) {
			mp[t] = xx;
			return true;
		}
		mp[t] += xx;
		if (!mp[t]) {
			mp.erase(t);
		}
		return false;
	}

};

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
long long modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

bool chmax(int& xx, int yy) {
	if (xx < yy) {
		xx = yy;
		return true;
	}
	return false;
}
bool chmin(int& xx, int yy) {
	if (xx > yy) {
		xx = yy;
		return true;
	}
	return false;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx <= 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}

vector<vector<int>>vec(1004, vector<int>(1004));

signed main() {
	int n,ans=0;
	cin >> n;
	for (int i = 1; i <= n; i+=2) {
		int c = 0;
		for (int j = 1; j <= n; j++) {
			if (i % j == 0)c++;
		}
		if (c == 8)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 11516
D = int(input())
C = list(map(int,input().split()))
 
s = [[] for _ in range(D)]
last = [0]*26
 
for i in range(D):
    s[i] = list(map(int,input().split()))

def evaluation(d, x, y, z):
    P = [0]*26
    for i in range(26):
        P[i] += x[i]
        for j in range(26):
            if i == j:
                continue
            P[i] -= z[j] * (d+1 - y[j])
    return P.index(max(P))
 
 
for d in range(D):
    d_maxP = evaluation(d, s[d], last, C)
    last[d_maxP] = d+1
    print(d_maxP + 1)

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

int main() {
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  int beg = max(a, c), en = min(b, d);
  int ans = en - beg;
  if(ans < 0) ans = 0;
  cout << ans;
}

Measured memory_bytes: 3768
#include <stdio.h>
#include <stdlib.h>
int main( int argc, char *argv[] )
{
	int N;
	long long int ans;
	int *cnt;
	cnt=(int *)calloc(N,sizeof(int));
	scanf("%d",&N);
	for(int i=0; i<N; i++){
		int tmp;
		scanf("%d",&tmp);
		cnt[(int)(tmp/2)]++;
	}
	ans=1;
	if(N%2==1){
		if(cnt[0]!=1)ans=0;
		else{
			for(int i=1; i<(N+1)/2; i++){
				if(cnt[i]!=2){
					ans=0;
					break;
				}
				else ans=(ans*2)%1000000007;
			}
		}
	}
	else{
		for(int i=0; i<N/2; i++){
				if(cnt[i]!=2){
					ans=0;
					break;
				}
				else ans=(ans*2)%1000000007;
			}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 16512
num = [int(i) for i in input()]
if num[0] > num[1]:
    print(111*num[0])
elif num[0] == num[1]:
    if num[1] >= num[2]:
        print(111*num[0])
    else:
        print(111 * (num[0] + 1))
else:
    print(111*(num[0]+1))

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var str = GetStrArray();
            var N = GetIntArray();
            var U = GetStr();
            if (str[0] == U) { N[0]--; }
            else { N[1]--; }

            Console.WriteLine(N[0]+" "+N[1]);
        }

        


        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 13268
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll H, W, A, B;
    cin >> H >> W >> A >> B;

    for (ll i = 0; i <= H; i++) {
        for (ll j = 0; j <= W; j++) {
            //行で見た1の個数
            ll row1 = A * (H - i) + (W - A) * i;

            //列で見た1の個数
            ll col1 = B * (W - j) + (H - B) * j;

            if (row1 != col1) {
                continue;
            }

            //同じだとここが答えにできそう
            vector<ll> row_need(H, A);
            for (ll k = 0; k < i; k++) {
                row_need[k] = W - A;
            }

            vector<ll> col_need(W, B);
            for (ll k = 0; k < j; k++) {
                col_need[k] = H - B;
            }

            priority_queue<pair<ll, ll>> pq;
            for (ll k = 0; k < W; k++) {
                pq.push({col_need[k], k});
            }

            vector<vector<ll>> ans(H, vector<ll>(W, 0));

            for (ll k = 0; k < H; k++) {
                vector<pair<ll, ll>> one;
                for (ll l = 0; l < row_need[k]; l++) {
                    auto top = pq.top();
                    pq.pop();
                    one.push_back(top);
                    assert(top.first > 0);
                }

                for (pair<ll, ll>& p : one) {
                    ans[k][p.second] = 1;
                    p.first--;
                    pq.push(p);
                }
            }

            for (ll k = 0; k < H; k++) {
                for (ll l = 0; l < W; l++) {
                    cout << ans[k][l];
                }
                cout << endl;
            }

            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}

//cin.tie(0);ios::sync_with_stdio(false);



signed main(){
    int n;cin>>n;
    ll ans=0;
    vector<ll> v(n);rep(i,0,n)cin>>v[i];
    rep(i,0,n)rep(j,i+1,n){
        ans+=v[i]*v[j];
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[] a = new int[n];
		
		for(int i = 0; i < n; i++) {
			a[i] = stdIn.nextInt();
		}
		
		int[] b = a.clone();
		
		Arrays.sort(b);
		
		for(int i = 0; i < n; i++) {
			if(a[i] == b[n-1]) {
				System.out.println(b[n-2]);
			}else {
				System.out.println(b[n-1]);
			}
		}
		
		
	}

}


Measured memory_bytes: 89044
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int n,h,w;cin>>n>>h>>w;
  cout<<(n-h+1)*(n-w+1)<<endl;
  return 0;
}

Measured memory_bytes: 3596
from fractions import gcd
def lcm(arr, n):
    ans = arr[0]
    for i in range(1, n):
        ans = ((arr[i] * ans) // gcd(arr[i], ans))
    return int(ans)

n, m = [int(x) for x in raw_input().split()]
arr = [int(x) for x in raw_input().split()]
v = []
for x in arr:
    y = x
    cnt = 0
    while y % 2 == 0:
        y = y // 2
        cnt += 1
    v.append(cnt)
mx = max(v)
mn = min(v)
if mx != mn:
    print(0)
else:
    strt = lcm(arr, n) // 2
    if strt > m:
        print(0)
    else:
        print(int(1 + int((m - strt)) // int((2 * strt))))


Measured memory_bytes: 13136
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double a = sc.nextDouble();
		double b = sc.nextDouble();
		double x = sc.nextDouble();

		double p1, p2;

		if (2 * x <= a * a * b) {
			p1 = a * b * b;
			p2 = 2 * x;
		} else {
			p1 = 2 * (a * a * b - x);
			p2 = a * a * a;
		}

		double sit = Math.atan(p1 / p2);

		System.out.println(Math.toDegrees(Math.atan(p1 / p2)));
	}

}


Measured memory_bytes: 23124
N = int(input())
X = list(map(int, input().split()))

A = []
for P in range(1,101):
    for i in range(N):
        A.append((X[i]-P)**2)
    if sum(A[0:N]) <= sum(A[N:2*N]) or len(A) == N:
        A = A[0:N]
    else:
        A = A[N:2*N]
print(sum(A))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int co[26];
#define MAXNUM 111111
char s[MAXNUM];
const int mod=1e9+7;
int main()
{
    int n;scanf("%d%s",&n,s);
    for(int i=0;i<n;i++)co[s[i]-'a']++;
    int r=1;
    for(int i=0;i<26;i++)r=r*1ll*(co[i]+1)%mod;
    printf("%d\n",(r-1+mod)%mod);
}

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  string s;
  cin >> s;
  stack<char> sta;
  rep(i, 0, s.size()) {
    if(s[i] == 'B' && !sta.empty()) sta.pop();
    else if(s[i] != 'B') sta.push(s[i]);
  }

  string ans;
  while(!sta.empty()) {
    ans += sta.top();
    sta.pop();
  }
  reverse(all(ans));
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,j,c,n,k,a[101][101];
	char map[101][101];
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%s",map[i]);
		for(j=0;j<k;j++)a[i][j]=-1;
	}
	for(i=0;i<n;i++){
		c=-1;
		for(j=0;j<k;j++){
			if(map[i][j]=='c')c=0;
			else if(c>=0)++c;
			a[i][j]=c;
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<k;j++){
			printf("%d",a[i][j]);
			if(j<k-1)printf(" ");
			else printf("\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 10005
#define ba 47
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    	out(x / 10);
    }
    putchar('0' + x % 10);
}
struct node {
    int to,next;
}E[MAXN * 2];
int sumE,head[MAXN],N;
int c[MAXN],ans;
int p[MAXN],tot;
void add(int u,int v) {
    E[++sumE].to = v;
    E[sumE].next = head[u];
    head[u] = sumE;
}
void dfs(int u,int fa) {
    p[u] = c[tot--];
    for(int i = head[u] ; i ; i = E[i].next) {
        int v = E[i].to;
        if(v != fa) {
            dfs(v,u);
        }
    }
}
void Solve() {
    read(N);
    int a,b;
    for(int i = 1 ; i < N ; ++i) {
        read(a);read(b);add(a,b);add(b,a);
    }
    for(int i = 1 ; i <= N ; ++i) read(c[i]);
    sort(c + 1,c + N + 1);
    for(int i = 1 ; i < N ; ++i) ans += c[i];
    tot = N;
    dfs(1,0);
    out(ans);enter;
    for(int i = 1 ; i <= N ; ++i) {
        out(p[i]);space;
    }
    enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, K; cin >> N >> K;
    vector<ll> x(N), y(N); 
    for(int i=0; i<N; i++) cin >> x[i] >> y[i];

    ll ans = (1LL<<62);
    for(int a=0; a<N; a++){
        for(int b=0; b<N; b++){
            for(int c=0; c<N; c++){
                for(int d=0; d<N; d++){
                    int x1 = min(x[a], x[b]), x2 = max(x[a], x[b]);
                    int y1 = min(y[c], y[d]), y2 = max(y[c], y[d]);

                    int cnt = 0;
                    for(int i=0; i<N; i++) if(x1 <= x[i] && x[i] <= x2 && y1 <= y[i] && y[i] <= y2) cnt++;
                    if(cnt == K) ans = min(ans, (ll)(x2-x1)*(y2-y1));

                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  string s;
  cin>>s;
  string ans="";
  for (int i= 0 ;i < s.size(); ++i) {
  	if (s[i] == '0') ans.push_back('0');
    else if (s[i] == '1') ans.push_back('1');
    else if (ans.size() > 0) ans.pop_back();
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256