akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {
        static Dictionary<Tuple<long, long>, long> dic = new Dictionary<Tuple<long, long>, long>();


        static void Main(string[] args)
        {

            var n = ReadLong();
            var ll = ReadLongArr();

            BitArr[] b = new BitArr[n];

            for(int i=0; i<n; i++)
            {
                b[i] = new BitArr(ll[i]);
            }

            long mod = 1000000007;
            long res = 0;
            long order = 1;
            for(int i=0; i<64; i++)
            {
                int bitcnt = 0;
                for(int j=0; j<n; j++)
                {
                    if(b[j].bitArr[i])
                    {
                        bitcnt++;
                    }
                }
                res += (((n - bitcnt) * bitcnt) % mod) * (order % mod);
                res = res % mod;
                order = order*2;
            }
            Console.WriteLine(res);
        }

        class BitArr
        {
            public bool[] bitArr = new bool[64];

            public BitArr(long l)
            {
                var ll = l;
                for(int i=0; i<64; i++)
                {
                    bitArr[i] = (ll % 2) == 1;
                    ll = ll / 2;
                }
            }
        }

        public static int Digit(long num)
        {
            // Mathf.Log10(0)はNegativeInfinityを返すため、別途処理する。
            return (num == 0) ? 1 : ((int)Math.Log10(num) + 1);
        }

        public static long nCm(long n, long m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            var a = n * nCm(n - 1, m - 1) / m;
            return a % 1000000007;
        }

        private static string ReadString()
        {
            return Console.ReadLine();
        }
        private static string[] ReadStringArr()
        {
            return Console.ReadLine().Split(' ');
        }
        private static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadLongArr()
        {
            string[] s = ReadStringArr();
            long[] l = new long[s.Length];
            for(int i=0; i<l.Length; i++)
            {
                l[i] = long.Parse(s[i]);
            }

            return l;
        }
    }

}


Measured memory_bytes: 80000
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;
fn main() {
    let (n, x): (usize, usize);
    input!(n, x);
    let mut v = input_vector::<usize>();

    let mut ans = 0;

    for i in 0..n {
        if v[i] > x {
            ans += v[i] - x;
            v[i] = x;
        }
    }

    for i in 0..n - 1 {
        if v[i] + v[i + 1] <= x {
            continue;
        }
        let must_eat = v[i] + v[i + 1] - x;
        v[i + 1] -= must_eat;
        ans += must_eat;
    }
    p(ans);
}

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

using ll = long long;

#define vl vector<long long>
using pll = pair<long long, long long>;
#define __ << '\n'
#define _ << ' '
#define all(x) (x).begin(), (x).end()

void error()
{
    cout << "-1";
    exit(0);
}

#define flush fflush(stdout)

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

    ll n, a, b;
    cin >> n >> a >> b;

    if (a > b)
        swap(a, b);

    cout << a _;

    a += b;
    if (a > n)
        cout << a - n;
    else
        cout << 0;
    
    return 0;
}


Measured memory_bytes: 256
def dist(ax,ay,bx,by):
    return ((bx-ax)**2 + (by-ay)**2)**0.5

x1,y1,r1 = map(float,input().split())
x2,y2,r2 = map(float,input().split())

d = dist(x1,y1,x2,y2)
if d > r1 + r2:
    print(4)
elif d == r1+r2:
    print(3)
elif d + r1 == r2 or d + r2 == r1:
    print(1)
elif d + r1 < r2 or d + r2 < r1:
    print(0)
else:
    print(2)

Measured memory_bytes: 7704
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    #n=int(input())
    a,b,c= map(int, sys.stdin.readline().split(' '))
    print(c,a,b)
    #a=list(map(int,sys.stdin.readline().split(' ')))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<int> V(N,0);
    vector<int> C(N,0);
    for(int i=0; i<N; i++){
        cin >> V[i];
    }
    for(int i=0; i<N; i++){
        cin >> C[i];
    }
    int ans=0;
    for(int i=0; i<N; i++){
        ans+=max(0,V[i]-C[i]);
    }
    cout << ans << endl;
}

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

int main()
{
	int N;
	string S, T, str;
	cin >> N >> S >> T;

	for (int i = 0; i < N; i++)
	{
		str.push_back(S[i]);
		str.push_back(T[i]);
	}
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto kt = readln.split.to!(int[]);
    auto K = kt[0];
    auto as = readln.split.to!(int[]);
    sort!"a > b"(as);
    writeln(max(0, as[0]*2 - K - 1));
}

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

using namespace std;
#define int long long
#define INF ((10e9)+7)
#define pb push_back

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N,K;
    cin>>N>>K;
    
    vector<int>dp(K+1,false);
    vector<int>A(N);
    for(int i=0;i<N;i++)cin>>A[i];
    for(int i=1;i<=K;i++)
    {
        for(int j=0;j<N;j++)
        {
            if(i-A[j]>=0)
            {
                dp[i]=dp[i]||(!dp[i-A[j]]);
            }
            else break;
        }
    }
    if(dp[K])
    {
        cout<<"First";
    }
    else cout<<"Second";
    
    
    return 0;
    
}

Measured memory_bytes: 1024
#include<stdio.h>
 main(){
   int h,w,i,j;
   while(1){
     scanf("%d%d",&h,&w);
     if(h==0 && w==0)
       break;
     for(i=0;i<h;i++){
       if(i>0 && i<h-1){
     for(j=0;j<w;j++){
       if(j>0 && j<w-1){
         printf(".");
       }else{
         printf("#");
       }
     }
       }
else{
     for(j=0;j<w;j++)
       printf("#");
       }
       printf("\n");
     }
     printf("\n");
   }
   return 0;
 } 

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

int main(){
    int n,q,z=0,ans=0;
    cin >>n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++){
        cin >>a[i];
        b[i] = a[i];
    }
    sort(b.begin(),b.end());
    for(int i=0;i<n;i++) if(a[i]==b[i]) z++;
    cin >>q;
    vector<int> x(q),y(q);
    for(int i=0;i<q;i++) {
        cin >>x[i]>>y[i];
        x[i]--;
        y[i]--;
    }
    
    if(z==n){
        cout <<ans<<endl;
        return 0;
    } 
    for(int i=0;i<q;i++){
        int d = (a[x[i]]==b[y[i]] ? 1 : 0)+(a[y[i]]==b[x[i]] ? 1 : 0)-(a[x[i]]==b[x[i]] ? 1 : 0)-(a[y[i]]==b[y[i]] ? 1 : 0);
        z += d;
        ans++;
        if(z==n){
            cout <<ans<<endl;
            return 0;
        } 
        swap(a[x[i]],a[y[i]]);

    }
    cout <<-1<<endl;

    return 0;
}


Measured memory_bytes: 7640
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    A = LIST()
    M = 0
    b = []
    yaku = [0] * N;
    for i in range(N):
        n = N - i
        if (yaku[n-1] + A[n-1]) % 2:
            b.append(n)
            M += 1
            for i in range(1, int(n**0.5)+1):
                if n % i == 0:
                    yaku[i - 1] += 1
                    if i != n // i:
                        yaku[n//i - 1] += 1
    b.reverse()
    print(M)
    if M != 0:
        print(*b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 65768
#include <bits/stdc++.h>
using namespace std;
int s,t[105];
int main (){
       int n;
       cin >> n;
       for (int i  = 1; i<=n; i++)
              cin >> t[i],s+=t[i];
       
       int m;
       cin >> m;
       for(int i = 1; i <= m; i++){
              int p,x;
              cin >> p >> x;
              cout<<s - t[p] + x<<"\n";
       }
}

Measured memory_bytes: 256
n=gets.to_i
 h=gets.chomp.split(" ").map(&:to_i)
  dp=[]
 dp[0]=0
 dp[1]=(h[1]-h[0]).abs
 for i in 2..n-1
   way1=dp[i-1]+(h[i]-h[i-1]).abs
   way2=dp[i-2]+(h[i]-h[i-2]).abs
   if(way1<way2)
     dp[i]=way1
   else
     dp[i]=way2
   end
end
puts dp[n-1]

Measured memory_bytes: 10956
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define nt _int128
#define mod 1000000007
int main()
{
// #ifndef ONLINE_JUDGE
//        freopen("input.txt","r",stdin);
//     freopen("output.txt","w",stdout);
// #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    // cin >> t;
    t  = 1;
    while(t--)
    {
        ll n;
        cin>>n;
        ll ans=0;
        for(ll i=1;i<=n;i++)
        {
            ll x;
            cin>>x;
            if(i%2==1 and x%2==1)
                ans++;
        }
        cout<<ans;
    }

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <numeric>
#include <vector>
#include <map>

template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

using lint = long long;

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

    std::map<std::pair<lint, lint>, std::vector<int>> cnt;
    mint zero = 0;

    while (n--) {
        lint x, y;
        std::cin >> x >> y;

        if (x == 0 && y == 0) {
            zero += 1;
            continue;
        }

        if (x < 0 || (x == 0 && y < 0)) {
            x = -x, y = -y;
        }

        int side = 0;
        if (y <= 0) {
            side = 1;
            auto nx = -y;
            auto ny = x;
            x = nx, y = ny;
        }

        if (x == 0) {
            y /= y;
        } else if (y == 0) {
            x /= x;
        } else {
            auto g = std::gcd(x, y);
            x /= g, y /= g;
        }

        std::cerr << x << " " << y << std::endl;

        auto p = std::make_pair(x, y);
        if (!cnt.count(p)) cnt[p] = std::vector(2, 0);
        cnt[p][side] += 1;
    }

    mint ans = 1;
    for (const auto& p : cnt) {
        ans *= mint(2).pow(p.second[0]) + mint(2).pow(p.second[1]) - 1;
    }
    ans += zero;

    std::cout << ans - 1 << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 29720
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    ll d = inf-1;
    ll n,k,s;
    cin>>n>>k>>s;
    if( d == s ) d --;
    for( ll i=0;i<k;i++){
	if( i!= 0) cout<<' ';
	cout<<s;
    }
    for( ll i=k;i<n;i++){
	if( k == 0 && i == 0 ) ;
	else cout<<' ';
	cout<<d;
    }
    cout<<endl;
    return 0;
}


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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define ll long long
#define OK puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 1e5 + 10;
const int inf = 1e9 + 7;

int n, k, c, ans, l, cn;
int a[N];

main()
{
    scanf("%d%d%d", &n, &c, &k);
    for(int i = 1; i <= n; i++)
        scanf("%d", a + i);
    sort(a + 1, a + n + 1);
    l = a[1] + k;
    cn = 1;
    for(int i = 2 ; i <= n ; i ++)
    {
        if(cn == c || l < a[i])
        {
            ans ++;
            l = a[i] + k;
            cn = 1;
        }
        else
            cn ++;
    }
    cout << ans + 1 << endl;


}





Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    s+='S';
    int cot=0,count1=0;
    for(int i=0;i<4;i++)
    {
        if(s[i]=='R')
            cot++;
        else
        {
           count1=max(count1,cot);
           cot=0;
        }
    }
    cout<<count1<<endl;
}

Measured memory_bytes: 3604
def b():
    a = {}
    for i in range(3):
        arr = list(map(int, input().split()))
        for j in range(3):
            a[i, j] = arr[j]

    N = int(input())
    for n in range(N):
        b = int(input())
        keys = [k for k, v in a.items() if v == b]
        # print(b, keys)
        for l in keys:
            a[l] = 0

    # print(a)
    for i in range(3):
        if (
            (a[i, 0] + a[i, 1] + a[i, 2] == 0)
            or (a[0, i] + a[1, i] + a[2, i] == 0)
        ):
            print('Yes')
            return
    if (
        (a[0, 0] + a[1, 1] + a[2, 2] == 0)
        or (a[0, 2] + a[1, 1] + a[2, 0] == 0)
    ):
        print('Yes')
        return

    print('No')
    return


##########
b()


Measured memory_bytes: 3064
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect
from decimal import *

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

a, b, c = map(int, input().split())
if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
    print("Yes")
else:
    print("No")


Measured memory_bytes: 6436
#include <bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 2000005
#define MOD 1000000007
#define MOD2 998244353
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vp vector<pii>
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

ll mexp(ll a, ll b){
    ll ans=1;
    a%=MOD;
    while(b){
        if(b&1) ans=ans*a%MOD;
        b>>=1;
        a=a*a%MOD;
    }
    return ans;
}

ll f[100005];

int main(){
    IOS

    f[0]=1;
    FOR(i,1,100005){
        f[i]=f[i-1]*i%MOD;
    }

    int n,m;
    cin>>n>>m;
    if(abs(n-m)>1){
        cout<<0;
        return 0;
    }
    if(n-m==0){
        cout<<2*f[n]*f[m]%MOD;
    }
    else{
        cout<<f[n]*f[m]%MOD;
    }


    cerr<<"Time: "<<1.0/CLOCKS_PER_SEC<<" ms"<<endl;
    return 0;
}

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

int main(){
  long long N,K,sum;
  cin >> N >> K;
  long long H[N];
  for(int i=0;i<N;i++){
    cin >> H[i];
  }
  sort(H,H+N);
  sum = 0;
  for(int i = 0;i<N-K;i++){
    sum = sum + H[i];
  }
  cout << sum << endl;
  
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  if( s.at(2) == s.at(3) && s.at(4) == s.at(5) ){
    cout << "Yes" << endl;
  }
  else{
    cout << "No"<< 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;
typedef long long ll;

int main() {
  int a,b;
  cin >> a >> b;
  int c;
  if (a < b) {
    c = a;
    for (int i = 1; i < b; i++) {
      c = c*10 + a;
    }
    cout << c << endl;
  } else {
    c = b;
    for (int i = 1; i < a; i++) {
      c = c*10 + b;
    }
    cout << c << endl;
  }
}

Measured memory_bytes: 256
import java.util.BitSet;
import java.util.NoSuchElementException;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.TreeSet;
import java.util.stream.IntStream;

class Main{
	private static final int n=1000001;
	static Scanner s=new Scanner(System.in);
	static int gInt() {return Integer.parseInt(s.next());}
	static long gLong() {return Long.parseLong(s.next());}

	public static void main(String[]$){
		BitSet rabbit=new PrimeIterator(n).bs;
		TreeSet<Integer>treeone=new TreeSet<>();

		IntStream.range(1,n)
		.filter(i->i%2==1&&rabbit.get(i)&&rabbit.get((i+1)/2))
		.forEach(treeone::add);

		for(int q=gInt();q>0;--q)
			System.out.println(treeone.subSet(gInt(),gInt()+1).size());
	}
	public static class PrimeIterator implements Iterable<Integer>,PrimitiveIterator.OfInt{
		private BitSet	bs;
		private int		curv,limit;

		public PrimeIterator(int limit){
			curv=0;
			bs=new BitSet(limit+1);
			this.limit=limit;
			constructBS();
		}
		private final void constructBS(){
			bs.set(0,limit+1);
			bs.clear(0);
			bs.clear(1);
			if(limit<2) return;

			int i=1;
			while(sieve(i=bs.nextSetBit(i+1)))
				;
		}
		protected boolean sieve(int v){
			if((long)v*v>limit)
				return false;
			for(int i=v*v;i<=limit;i+=v)
				bs.clear(i);
			return true;
		}
		@Override
		public boolean hasNext(){
			int r=getNextValue();
			return 0<=r&&r<=limit;
		}
		private int getNextValue(){
			return bs.nextSetBit(curv+1);
		}
		@Override
		public int nextInt(){
			int r=getNextValue();
			if(r<0||limit<r) throw new NoSuchElementException();
			return curv=r;
		}
		@Override
		public OfInt iterator(){
			return this;
		}
		public BitSet getClonedBitSet(){
			return (BitSet)bs.clone();
		}
	}
}


Measured memory_bytes: 53152
import java.util.*;

public class Main  {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int alp[][] = new int[N][26];
		for (int i = 0; i < N; i++) {
			for (char c: sc.next().toCharArray()) {
				alp[i][c-'a']++;
			}
		}
		String ans = "";
		for (int i = 0; i < 26; i++) {
			int min = 1 << 29;
			for (int j = 0; j < N; j++) {
				min = Math.min(min, alp[j][i]);
			}
			for (int j = 0; j < min; j++) {
				ans += (char)(i + 'a');
			}
		}
		System.out.println(ans);
	}
}


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

typedef long long ll;

int n,m;
int a[55];
ll ans,sum,d[55][2505];

int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    sort(a+1,a+n+1);
    d[0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=i;j>=1;j--)
            for(int k=sum;k>=a[i];k--)
                d[j][k]+=d[j-1][k-a[i]];
        /*if(i>3) continue;
        for(int j=1;j<=i;j++)
            for(int k=1;k<=sum;k++)
                printf("%d %d %d:%I64d\n",i,j,k,d[j][k]);*/
    }
    for(int i=1;i<=n&&m*i<=sum;i++)
        ans+=d[i][m*i];
    printf("%lld",ans);
}


Measured memory_bytes: 1152
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
int comp(const void *a, const void *b)
{
	if (*((float*)a) < 0 && *((float*)b) > 0){
		return -1;
	} else if (*((float*)a) > 0 && *((float*)b) < 0){
		return 1;
	}
	float ans = *((float*)b + 1) / *((float*)b) - *((float*)a + 1) / *((float*)a);
	if (ans > 0){
		return 1;
	} else if (ans == 0){
		return 0;
	} else{
		return -1;
	}
}

int main(){
	int n, w, cnt;
	float a[100000][2];
	double ans = 0, sum = 0;

	cin >> n >> w;
	for (int i = 0; i < n; i++){
		int b, c;
		cin >> b >> c;
		if (b >= 0 && c <= 0){
			i--;
			n--;
			continue;
		} else if (b <= 0 && c <= 0){
			sum += b;
			ans += c;
			b *= -1;
			c *= -1;
		}
		a[i][0] = (float)b;
		a[i][1] = (float)c;
	}
	qsort(a, n, sizeof(float) * 2, comp);
	for (cnt = 0; cnt < n; cnt++){
		sum += a[cnt][0];
		if (sum > w){
			sum -= a[cnt][0];
			break;
		}
	}
	for (int i = 0; i < cnt; i++){
		ans += a[i][1];
	}
	if (cnt < n){
		if ((w - sum) / a[cnt][0] > 1){
			ans += a[cnt][1];
		} else{
			double tmp = (w - sum) * a[cnt][1];
			tmp /= a[cnt][0];
			ans += tmp;
		}
	}
	printf("%.4f\n", ans);
	return 0;
}

Measured memory_bytes: 1396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const ll MAX = 1e7 + 20;
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define rrep(i,a,n)     for(int i=a;i<=n;i++)
#define per(i,n,a)      for(int i=n;i>=a;i--)
#define pf(n)           printf("%lld",n)
#define pfi(n)          printf("%d",n)
#define sp              printf(" ")
#define ln              "\n"

#define pi acos(-1.0)
#define mod 1000000007

///Library
#define mem(a,b) memset(a,b,sizeof(a))
#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define SortA(ar,s) sort(ar,ar+s)
#define SortD(ar,s) sort(ar,ar+s,greater<int>())
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sq(x) (x)*(x)


///vector
#define Lower_bound(vec,value) lower_bound(vec.begin(),vec.end(),value)
#define Upper_bound(vec,value) upper_bound(vec.begin(),vec.end(),value)


//template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
//template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }


int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/

    fast

    ll a,flag,c;
    cin>>a;
    ll b[a];
    ll l=0;
    for(int i=0; i<a; i++)
    {
        cin>>c;
        if(c%2==0)
        {
            b[l]=c;
            l++;
        }
    }
    for(int i=0; i<l; i++)
    {
        if(b[i]%2==0 && (b[i]%3==0 || b[i]%5==0))
        {
            flag=0;
        }
        else
        {
            flag=1;
            break;
        }
    }
    if(flag)
    {
        cout<<"DENIED"<<endl;
    }
    else
    {
        cout<<"APPROVED"<<endl;
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a,b="CODEFESTIVAL2016";
int c;
int main()
{
    cin>>a;
    for(int i=0;i<16;i=-~i)
    	c+=(a[i]==b[i])?1:0;
    cout<<16-c<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n,m;
    cin >> n >> m;
    int q[n] = {};
    bool r[n] = {};
    for(int i = 0;i < m;i++)
    {
        int p;
        string s;
        cin >> p >> s;
        if(s == "AC")
        {
            r[p - 1] = true;
        }
        else if(!r[p - 1] && s == "WA")
        {
            q[p - 1]++;
        }
    }
    int correct = 0,pena = 0;
    for(int i = 0;i < n;i++)
    {
        if(r[i])
        {
            correct++;
            pena += q[i];
        }
    }
    cout << correct << " " << pena << "\n";
    
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define N 100005
using namespace std;

typedef long long ll;

int n, A[N], ans=1;
vector<int> G[N];

ll dfs(int x, int px){
  
  vector<ll> v;
  
  for(int i=0;i<G[x].size();i++)
    if(G[x][i]!=px) v.push_back(dfs(G[x][i], x));
  
  if(v.empty()) return A[x];
  
  ll res=0;
  
  for(int i=0;i<v.size();i++) res+=v[i];
  
  sort(v.begin(),v.end());
  
  ll q=res-A[x], sum=0;
  
  if(v[v.size()-1]*2<=res) sum=res/2;
  else sum=(res-v[v.size()-1]);
  //if(x==1) cout<<q<<' '<<sum<<' '<<v[1]<<' '<<res<<endl;
  if(q<0) ans=0;
  
  if(q>sum) ans=0;
  else res-=q*2;
  
  if(px==-1&&A[x]!=res) ans=0;
  
  return res;
}

int main(){
  
  cin>>n;
  
  for(int i=0;i<n;i++) scanf("%d", &A[i]);
  
  int a, b;
  
  for(int i=0;i<n-1;i++){
    scanf("%d %d", &a, &b);
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }
  
  int root;
  
  for(int i=0;i<n;i++)
    if(G[i].size()==1){
      root=i;
      break;
    }
  
  dfs(root, -1);
  
  if(ans) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  
  return 0;
}


Measured memory_bytes: 17024
x, n = map(int, input().split())
s = list(map(int, input().split()))
for j in range(n):
    s[j] = s[j] - x

i = 0
while True:
    if -i not in s:
        print(x-i)
        exit()
    if i not in s:
        print(x+i)
        exit()
    i += 1






Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  vector<string> S(2);
  cin >> S[0] >> S[1];
  ll ans = 3;
  if (S[0][0] != S[1][0]) ans += 3;
  for (int i = 1; i < N; i++) {
    if (S[0][i - 1] == S[1][i - 1]) {
      ans *= 2;
      ans %= MOD;
      if (S[0][i] != S[1][i]) i++;
    } else {
      if (S[0][i] != S[1][i] && i != 1) {
        ans *= 3;
        i++;
        ans %= MOD;
      }
    }
  }
  if (N == 1) ans = 3;
  cout << ans << endl;
}

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

int main()
{
	auto yymm = [](string &t) {
		int y = stoi(t.substr(0, 2)), m = stoi(t.substr(2, 2));
		return (1 <= m && m <= 12);
	};

	auto mmyy = [](string &t) {
		int m = stoi(t.substr(0, 2)), y = stoi(t.substr(2, 2));
		return (1 <= m && m <= 12);
	};

	string s;
	cin >> s;
	if (yymm(s) && mmyy(s))
	{
		cout << "AMBIGUOUS" << endl;
	}
	else if (yymm(s))
	{
		cout << "YYMM" << endl;
	}
	else if (mmyy(s))
	{
		cout << "MMYY" << endl;
	}
	else
	{
		cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
#include<stack>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
struct UnionFind {
	vector<int> par, s;
	UnionFind(int N) : par(N), s(N, 1) { rep(i, 0, N)par[i] = i; }
	int root(int x) { return par[x] == x ? x : par[x] = root(par[x]); }
	void unite(int x, int y) { x = root(x), y = root(y); if (x == y)return; if (s[x] < s[y])swap(x, y); s[x] += s[y]; par[y] = x; }
	bool same(int x, int y) { return root(x) == root(y); }
	int size(int x) { return s[root(x)]; }
	map<int, int> cnt() { map<int, int> cnt; rep2(v, par)cnt[root(v)]++; return cnt; }
};
#define P pair<int, int>
int main()
{
	ll n, m, a, b;
	cin >> n >> m;
	vector<P> br(m);
	for (int i = 0; i < m; ++i)
	{
		cin >> a >> b;
		a--; b--;
		br[i] = P(a, b);
	}

	reverse(br.begin(), br.end());
	UnionFind uf(n);

	stack<ll> ans;
	ll e_cnt = n * (n - 1) / 2;
	for (const auto& p : br)
	{
		ans.push(e_cnt);
		if (!uf.same(p.first, p.second))
		{
			e_cnt -= uf.size(p.first) * uf.size(p.second);
			uf.unite(p.first, p.second);
		}
	}

	while (!ans.empty())
	{
		cout << ans.top() << endl;
		ans.pop();
	}
	return 0;
}

Measured memory_bytes: 5584
import sys

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

root = None

def insert(key):
    global root
    x, y = root, None
    while x: x, y = x.left if key < x.key else x.right, x
    if y is None: root = Node(key)
    elif key < y.key: y.left = Node(key)
    else: y.right = Node(key)

def inorder(node):
    return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
def preorder(node):
    return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''

input()
for e in sys.stdin:
    if e[0] == 'i': insert(int(e[7:]))
    else: print(inorder(root)); print(preorder(root))


Measured memory_bytes: 63328
eval"A,B,C,D,E,F="+gets.split*?,;d={};f=->a,b{d[[a,b]]||=a*100+b>F||a*E<b ?-1:[b.quo(a),f[a+A,b],f[a+B,b],f[a,b+C],f[a,b+D]].max};f[A,0];f[B,0];a,b=d.max_by{|_,v|v}[0];puts"#{a*100+b} #{b}"

Measured memory_bytes: 4860
from string import ascii_lowercase


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


def solve(s):
    indices = {c: [] for c in ascii_lowercase}
    for i, c in enumerate(s):
        indices[c].append(i)

    n = len(s)
    center = n // 2
    bubbles = [-1] * n
    odd_flag = False
    lefts, rights = [], []
    for c, ids in indices.items():
        cnt = len(ids)
        if cnt & 1:
            if odd_flag:
                return -1
            odd_flag = True
            bubbles[ids[cnt // 2]] = center + 1
        for i in range(cnt // 2):
            li, ri = ids[i], ids[-i - 1]
            if li < center:
                lefts.append((li, ri))
            else:
                rights.append((li, ri))
    lefts.sort()
    rights.sort()
    r_itr = iter(rights)
    for i, (li, ri) in enumerate(lefts):
        bubbles[li] = i + 1
        bubbles[ri] = n - i
    for i in range(len(lefts), center):
        li, ri = next(r_itr)
        bubbles[li] = i + 1
        bubbles[ri] = n - i

    ans = 0
    bit = Bit(n)
    for i, m in enumerate(bubbles):
        ans += i - bit.sum(m)
        bit.add(m, 1)
    return ans


print(solve(input()))


Measured memory_bytes: 31204
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (int i=(m)-((m)>(n));i!=(n)-((m)>(n));i+=2*((m)<(n))-1)
#define test(x) cout << #x << ' ' << x << endl;
#define eb emplace_back
#define pb push_back
#define mp make_pair 

double dp[301][301][301],n;

double find(int a, int b, int c) {
	if (a<0 or b<0 or c<0) return 0;
	if (dp[a][b][c]!=-1) return dp[a][b][c];
	dp[a][b][c]=(find(a-1,b,c)*a+find(a+1,b-1,c)*b+find(a,b+1,c-1)*c+n)/(a+b+c);
	return dp[a][b][c];
}


int main() {
	int a[3]={0,0,0},tmp;
	cin >> n;
	fop (i,0,n) {
		cin >> tmp;
		a[tmp-1]++;
	}
	fop (i,0,n+1) {
		fop (j,0,n+1) {
			fop (k,0,n+1) {
				dp[i][j][k]=-1;
			}
		}
	}
	dp[0][0][0]=0;
	cout << setprecision(10) << find(a[0],a[1],a[2]) << endl;
}

Measured memory_bytes: 213504
#include <iostream>
#include <string>

int main() {
  std::string s, t;
  std::cin >> s >> t;
  for (size_t i = 0; i < s.size(); ++i) {
    if (s.at(i) != t.at(i)) {
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 3044
N = int(input())
l = list(map(int, input().split()))
a = 0
b = 0
l.sort(reverse=True)
for i in range(len(l)):
    if i % 2 == 0:
        a += l[i]
    else:
        b += l[i]
total = a - b
print(total)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var NP = ReadLine().Split().Select(long.Parse).ToArray();
        long N = NP[0], P = NP[1];
        long ans = 1;
        if (N == 1) { WriteLine(P);return; }
        for (int i = 2; i < Sqrt(P)+1; i++)
        {
            long p = P;
            int cnt = 0;
            while (p % i == 0) { p /= i;cnt++; }
            if (cnt >= N) ans = i;
        }
        WriteLine(ans);
    }
}


Measured memory_bytes: 28236
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<map>

using namespace std;
#define endl '\n'
#define pb push_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vii;

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

void solve() {

	int N;
	cin >> N;
	vi a(N);

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

	int cnt = 0;
	for (int i = 1; i < N; i++) {
		if (a[i] == a[i - 1]) {
			a[i] = a[i - 1] + a[i + 1];
			cnt++;
		}
	}

	out(cnt);
	
	return;

}

int main() {

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

	solve();

	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int Y = scanner.nextInt();
        if(X >= 2 * Y) {
            System.out.println("No");
            return;
        }
        for(int i = 0; i <= X; i++) {
            if(Y == (i * 2) + ((X - i) * 4)){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

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


int main()
{
	int N;
	cin >> N;
	vector<vector<int> > H(N,vector<int>(3)), dp(N,vector<int>(3,0));
	for(int i=0 ; i<N ; i++)
		for(int j=0 ; j<3 ; j++)
			cin >> H[i][j];
	for(int i=0 ; i<3 ; i++)
		dp[0][i] = H[0][i];
	for(int i=1 ; i<N ; i++)
	{
		vector<pair<int,int> > P(3);
		for(int k=0 ; k<3 ; k++)
			P[k] = {dp[i-1][k],k};
		sort(P.begin(), P.end());
		for(int j=0 ; j<3 ; j++)
		{
			if(j==P[2].second)
				dp[i][j] = H[i][j] + dp[i-1][P[1].second];
			else
				dp[i][j] = H[i][j] + dp[i-1][P[2].second];
		}
	}
	cout << max(max(dp[N-1][0],dp[N-1][1]),dp[N-1][2]) << endl;

}

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

int main() {
	int h, w;
	cin >> h >> w;
	char ans[50][50];
	int count[50][50] = {};
	char s[50][50];
	for (int i = 0;i < h;++i) {
		for (int j = 0;j < w;++j)cin >> s[i][j];
	}
	for (int i = 0;i < h;++i) {
		for (int j = 0;j < w;++j) {
			if (s[i][j] == '#') {
				ans[i][j] = '#';continue;
			}
			for (int k = -1;k <= 1;++k) {
				for (int l = -1;l <= 1;++l) {
					if (i + k < 0 || j + l < 0 || i + k == h || j + l == w || (k == 0 && l == 0))continue;
					if (s[i + k][j + l] == '#')++count[i][j];
				}
			}ans[i][j] = '0'+count[i][j];
		}
	}
	for (int i = 0;i < h;++i) {
		for (int j = 0;j < w;++j)cout << ans[i][j];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
 
#define mp make_pair
#define x first
#define y second
#define pb push_back
using namespace std;

const int maxn = 5e5 + 5;
string s;
int g[2 * maxn + 5], l[2 * maxn + 5], n;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> s;
	n = (int)s.size();
	
	g[1] = s[0] == '>' ? 1 : -1;
	for (int i = 1; i < n; ++i) {
		if (s[i] == '>') g[i * 2 + 1] = i * 2 + 1;
		else g[i * 2 + 1] = g[i * 2 + 1 - 2];
	}
	
	l[2 * n + 1] = 2 * n + 1;
	for (int i = n - 1; i >= 0; --i) {
		if (s[i] == '<') l[2 * i + 1] = 2 * i + 1;
		else l[2 * i + 1] = l[2 * i + 1 + 2];
	}
	
	long long ans = 0;
	for (int i = 0; i <= n; ++i) {
		long long x = 0;
		//~ if (i == 1) cerr << (l[2 * i + 1] - 1 - 2 * i) / 2 << '\n';
		if (i != 0) x = max(x, (2ll * i - g[i * 2 - 1] - 1) / 2ll);
		if (i != n) x = max(x, (l[i * 2 + 1] - 1 - 2ll * i) / 2ll);
		ans += x;
		//~ cerr << x << ' ';
	}
	
	cout << ans;
	return 0;
}


Measured memory_bytes: 8732
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++) {
    cin>>vec.at(i);
  }
  int sum =0;
  for(int i=0;i<N;i++) {
    for(int j=N-1;j>i;j--) {
	  sum+=vec.at(i)*vec.at(j);
    }
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
import os

import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

a, b = sys.stdin.buffer.readline().decode().rstrip().split()
a = int(a)
b = round(float(b) * 100)
print(a * b // 100)


Measured memory_bytes: 9236
#include<stdio.h>
#define A 200000
int main(void){
    int n,i,j,k;
    int R[A];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&R[i]);
    }
    for(i=0;i<n-1;i++){
       if(i==0 || j>R[i]){
           j=R[i];
       }
       if(i==0 || k<R[i+1]-j){
           k=R[i+1]-j;
       }
    }
    printf("%d\n",k);
    return 0; 
 }


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

#define _USE_MATH_DEFINES
#define reb(i,b,n)         for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n)           reb(i,0,n)
#define each(it,v)         for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v)        for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vsort(v)           sort((x).begin(), (x).end()
#define rvsort(v)          sort((x).rbegin(), (x).rend()
#define mp(a, b)           make_pair(a, b)
#define fi                 first
#define se                 second
#define pb                 push_back
#define dbg(x)             cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;
#define dbgArr(table, n)   rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define dbg2Arr(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}

using namespace std; using std::stringstream;

typedef long long       ll; typedef unsigned long long ull; typedef long double     ld;
typedef pair <int, int> P;  typedef pair <int, P>      PP;
typedef vector<int>     vi; typedef vector<vi>         vvi; typedef vector<ll>      vl;
typedef vector<P >      vP; typedef vector<char>       vc;  typedef vector<string>  vs;

static const int    INF  = 0x3f3f3f3f;
static const ll     INFL = 0x3f3f3f3f3f3f3f3fLL;
static const double EPS  = 1e-9;
static const ll     MOD  = 1000000007LL;

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

int main(int argc, char *argv[])
{
    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    ll ans = 0;

    ans += (min(A, K) * 1);
    K -= A;
    if (K <= 0) {
        cout << ans << endl;
        return 0;
    }

    K -= B;
    if (K <= 0) {
        cout << ans << endl;
        return 0;
    }

    ans -= (min(C, K) * 1);
    cout << ans << endl;

    return 0;
}


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

int main(){
    int n;  cin >> n;
    vector<pair<ll, ll>> t(n);
    ll now=0;
    for(int i=0; i<n; i++)
        cin >> t.at(i).second >> t.at(i).first;
    sort(t.begin(), t.end());
    string ans = "Yes";
    for(int i=0; i<n; i++){
        now += t.at(i).second;
        if(now<=t.at(i).first) continue;
        ans = "No";
        break;
    } 
    cout << ans << endl;
}

Measured memory_bytes: 3328
// 個数制限なしナップザック
#include <bits/stdc++.h>
using namespace std;

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

    string s, t;
    cin >> s >> t;
    // if (s == t) {
    //     cout << "Yes" << '\n';
    //     return 0;
    // }
    int s_length = s.length();
    char s_rep[s_length];
    for (int i = 0; i < s_length; ++i) {
        bool same = true;
        for (int j = 1; j <= s_length; ++j) {
            if (i + j < s_length) {
                s_rep[i + j] = s[j - 1];
            } else {
                s_rep[i + j - s_length] = s[j - 1];
            }
        }
        string str(s_rep);
        for (int j = 0; j < s_length; ++j) {
            if (s_rep[j] != t[j]) {
                same = false;
                break;
            }
        }
        if (same) {
            cout << "Yes" << '\n';
            return 0;
        }
    }

    cout << "No" << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N;
    string s, t;
    cin >> N >> s >> t;
    int ans = 2 * N;
    REP(i, N) {
        bool f = true;
        REP(j, N - i) {
            if (s[i + j] != t[j]) {
                f = false;
                break;
            }
        }
        if (f)
            chmin(ans, N + (int)i);
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
main(){
	int n;
	while(cin>>n){
		int sum=0;
		for(int a=0;a<=9;++a)
			for(int b=0;b<=9;++b)
				for(int c=0;c<=9;++c)
					for(int d=0;d<=9;++d)
						if(a+b+c+d==n)++sum;
		cout<<sum<<endl;
	}
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N;
    cin >> N;
    string Si;
    ll c_Bxx = 0;
    ll c_xxA = 0;
    ll c_BxA = 0;
    ll c_AB = 0;
    for(int i=0;i<N;i++){
        cin >> Si;
        if(Si.back()=='A' && Si.front()=='B') c_BxA++;
        if(Si.back()=='A') c_xxA++;
        if(Si.front()=='B') c_Bxx++;
        for(int j=0;j<Si.size()-1;j++){
            if(Si[j]=='A' && Si[j+1]=='B') c_AB++;
        }
    }
    if(c_BxA > 0 && c_xxA == c_BxA && c_Bxx == c_BxA){
        cout<<(c_AB + min(c_xxA, c_Bxx) - 1)<<endl;
    }else{
        cout<<(c_AB + min(c_xxA, c_Bxx))<<endl;
    }

    return 0;
}

Measured memory_bytes: 256