akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long[] A;
        public bool[] U;
        public long MOD = 1000000007;

        public void Run()
        {
            N = Input.ReadInt();
            A = Input.ReadLongArray();
            Array.Sort(A);

            U = new bool[N];
            for (int i = 0; i < N; i++)
            {
                U[i] = false;
            }

            int r = 0;
            for (int b = 40; b >= 0; b--)
            {
                long x = 1L << b;
                int j = 0;
                for (int i = N - 1; i >= 0; i--)
                {
                    if (U[i]) continue;
                    while (j < N)
                    {
                        if (!U[j] && i != j && A[i] + A[j] == x)
                        {
                            U[i] = true;
                            U[j] = true;
                            r++;
                            j++;
                            break;
                        }
                        else if (A[i] + A[j] > x)
                        {
                            break;
                        }
                        else
                        {
                            j++;
                        }
                    }
                }
            }

            Console.WriteLine(r);
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

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

int divide_times(int n){
    int divided = 0;
    while(n){
        if(n % 2 == 0){
            divided++;
            n /= 2;
        }else{
            break;
        }
    }
    return divided;
}

int main(){
    int N, A;
    cin >> N;
    int min = 1000000000;

    rep(i, N)
    {
        cin >> A;
        int divided = divide_times(A);
        if (min > divided) min = divided;
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 3640
import numpy as np

def main():
    n, k = map(np.int64, input().split(" "))
    #a1 = np.int64(np.floor(n // k))
    #a2 = np.int64(np.floor(n // k + 1))
    #b1 = abs(n - a1 * k)
    #b2 = abs(n - a2 * k)
    #print(a1, a2)
    #print(n - a1 * k, n - a2 * k)
    b1 = np.mod(n, k)
    b2 = np.mod(n, k) - k
    #print(b1, b2)
    ans = np.min([abs(b1), abs(b2)])
    print(ans)
    
if __name__ == '__main__':
    main()

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//都市iから伸びる道路の数=a,bに含まれるiの数
int main(){
 int N,M;
 cin >> N >> M;
 vector<int> a(M);
 vector<int> b(M);
 rep(i,M){
   cin >> a[i];
   cin >> b[i];
 }
 vector<int> num(N+1);//num[i]は都市iから伸びる道路の数
 for(int i = 0;i<M;i++){
   num[a[i]]++;
   num[b[i]]++;
 }
 

 for(int i = 1;i<=N;i++){
   cout << num[i] << endl;
 }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main 
{

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		int evenBalls = sc.nextInt();
		
		int oddBalls  = sc.nextInt();
		
		
		
		int evenAvailable = 0;
		
		for(int i=1; i<evenBalls; i++)
		{
			evenAvailable += i;
			
		}
		
		
		for(int i=1; i<oddBalls; i++)
		{
			evenAvailable += i;
			
		}
		
		System.out.println(evenAvailable);
		
		
		

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
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; }

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

bool dp1[8888][8888 * 2];
bool dp2[8888][8888 * 2];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string s;
    int x,y;
    cin>>s>>x>>y;
    int N = s.size();
    vector<int> v;
    int cnt = 0;
    rep(i,N){
        if(s[i] == 'F')cnt++;
        else{
            v.push_back(cnt);
            cnt = 0;
        }
    }
    v.push_back(cnt);
    //print(v);
    vector<int> dx;
    vector<int> dy;
    rep(i,v.size()){
        if(i % 2 == 0)dx.push_back(v[i]);
        else dy.push_back(v[i]);
    }

    print(v);
    print(dx);
    print(dy);



    rep(i,8888)rep(j,8888 * 2){
        dp1[i][j] = false;
        dp2[i][j] = false;
    }
    int base = 8005;
    dp1[0][base] = true;
    dp2[0][base] = true;
    bool first_flag = (s[0] == 'F');
    rep(i, (int)dx.size()){
        rep(j, base * 2){
            if(dp1[i][j]){
                if(i == 0){
                    dp1[i+1][j + dx[i]] = true;
                    if(!first_flag)dp1[i+1][j-dx[i]] = true;
                }
                else{
                    dp1[i+1][j + dx[i]] = true;
                    dp1[i+1][j - dx[i]] = true;
                }
            }
        }
    }
    rep(i, (int)dy.size()){
        rep(j, base * 2){
            if(dp2[i][j]){
                dp2[i+1][j + dy[i]] = true;
                dp2[i+1][j - dy[i]] = true;
            }
        }
    }
    if(dp1[(int)dx.size()][base + x] && dp2[(int)dy.size()][base + y]){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 308992
package main

import (
	"bytes"
	"fmt"
	"strconv"
)

func main() {

	// mainA()
	mainB()
}

func mainA() {
	var n int
	fmt.Scan(&n)
	var res = solveA(n)
	fmt.Println(res)
}

func solveA(n int) int {

	var odd = 0
	var even = 0
	for i := 1; i <= n; i++ {
		if i%2 == 0 {
			even++
		} else {
			odd++
		}
	}

	return even * odd
}

func mainB() {
	var x1, y1, x2, y2 int
	fmt.Scan(&x1, &y1, &x2, &y2)
	var res = solveB(x1, y1, x2, y2)
	fmt.Println(res)
}

func solveB(x1, y1, x2, y2 int) string {
	var x3 = x2 - (y2 - y1)
	var y3 = y2 + (x2 - x1)
	var x4 = x3 - (y3 - y2)
	var y4 = y3 + (x3 - x2)
	var buffer bytes.Buffer
	buffer.WriteString(strconv.Itoa(x3))
	buffer.WriteString(" ")
	buffer.WriteString(strconv.Itoa(y3))
	buffer.WriteString(" ")
	buffer.WriteString(strconv.Itoa(x4))
	buffer.WriteString(" ")
	buffer.WriteString(strconv.Itoa(y4))
	return buffer.String()

}


Measured memory_bytes: 640
using System;

namespace ABC107A
{
    class MainClass
    {
        public static void Main(string[] args)
        {


            string[] input1 = Console.ReadLine().Split(' ');
            int N = int.Parse(input1[0]);
            int i = int.Parse(input1[1]);

            Console.WriteLine(N - i + 1);

        }
    }
}


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

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

    int a[5];
    for(int i = 0;i < 5;i++) cin>>a[i];
    string s = "01234";
    int ans = INT_MAX;
    do {
        // cout<<s<<endl;
        int t = a[s[0] - '0'];
        for(int i = 1;i < 5;i++) {
            if(t % 10 != 0) {
                t = t + (10 - t%10);
            }
            t += a[s[i] - '0'];
        }
        ans = min(ans, t);
    } while(next_permutation(s.begin(), s.end()));
    cout<<ans;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
class UnionFind {
private:
  int siz;
  vector<int> a;

public:
  UnionFind(int x) : a(x, -1) {}

  int root(int x) {
    return a[x] < 0 ? x : a[x] = root(a[x]);
  }

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    siz--;
    if (a[x] > a[y]) swap(x, y);
    a[x] += a[y];
    a[y] =x;
    return true;
  }

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

  int size(int x) {
    return -a[root(x)];
  }
  
  int conneted_component() {
  	return siz;
  }
};
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n, r;
  cin >> n >> r;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  UnionFind uf(n);
  for (int i = 0; i < n; i++) {
    uf.unite(a[i], a[a[i]]);
  }
  vector<int> c;
  for (int i = 0; i < n; i++) {
    if (i == uf.root(i)) {
      c.push_back(uf.size(i));
    }
  }
  r = min(r, n - r);
  bitset<150002> dp;
  dp[0] = 1;
  for (int i : c) dp |= (dp << i);
  if (dp[r]) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}



Measured memory_bytes: 7260
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
int A,B;cin>>A>>B;
  if(A+B>=10)cout<<"error"<<endl;
  else cout<<A+B<<endl;
}





Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)


def f(x, N, K, A):
    now = 0
    for i in range(N):
        now += (A[i]-1)//x
    return now <= K


def main(input, print):
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    l = 0
    r = 10**9
    while(r-l > 1):
        x = (l+r) // 2
        if f(x, N, K, A):
            r = x
        else:
            l = x
    print(r)


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Measured memory_bytes: 103404
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
  string s;
  cin >> s;
  if (s == "Sunny") cout << "Cloudy" << endl;
  else if (s == "Cloudy") cout << "Rainy";
  else cout << "Sunny" << endl;
  return (0);
}

Measured memory_bytes: 256
"""
組み合わせ(nCr)計算
https://qiita.com/derodero24/items/91b6468e66923a87f39f#%E7%95%AA%E5%A4%96%E7%B7%A8
逆元の求め方
http://drken1215.hatenablog.com/entry/2018/06/08/210000
解法@公式放送
https://www.youtube.com/watch?v=SS6kW-d-rJ0&feature=youtu.be&t=7376
"""


def cmb(n, r):
    return (fact[n] * finv_t[r] * finv_t[n - r]) % MOD


MOD = 10 ** 9 + 7

N, M, K = map(int, input().split())

fact = [1, 1]
inv_t = [0, 1]
finv_t = [1, 1]
for i in range(2, N * M - 2 + 1):
    fact.append((fact[-1] * i) % MOD)
    inv_t.append((-inv_t[MOD % i] * (MOD // i)) % MOD)
    finv_t.append((finv_t[-1] * inv_t[-1]) % MOD)

pat = cmb(N * M - 2, K - 2)

ans = 0

for i in range(M):
    ans += i * (M - i) * N ** 2

for i in range(N):
    ans += i * (N - i) * M ** 2

ans = (ans * pat) % MOD

print(ans)


Measured memory_bytes: 26868
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
	
	Scanner in = new Scanner(System.in);

	int a=0;
	int b,c;
	
	
	a = in.nextInt();	
	b= in.nextInt();
	c= in.nextInt();
	int[] aa={a,b,c};
	Arrays.sort(aa);
	System.out.println(aa[0]+aa[1]+aa[2]*10);
	}	
}

Measured memory_bytes: 22612
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	long long iAns=1, nFrac;
	register long long i;
	cin >> nFrac;
	for (i = 2; i <= nFrac; ++i){
		iAns *= i;
		iAns %= 1000000007;
	}
	cout << iAns << endl;
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split(' ')))
cnt = 0

for i in range(n):
    a = l[i]
    for j in range(n):
        b = l[j]
        for k in range(n):
            c = l[k]
            if i < j and j < k:
                m = [a,b,c]
                m = sorted(m)
                f = max(m)
                h = min(m)
                m.pop(0)
                m.pop(1)
                if f<m[0]+h and f != m[0] and m[0] != h:
                    cnt += 1
print(cnt)

Measured memory_bytes: 9208
# N, K = gets.split(" ").map(&:to_i)
S = gets.chomp

a = S[0...2].to_i
b = S[2...4].to_i

is_a = 1 <= a && a <= 12
is_b = 1 <= b && b <= 12
if is_a
  if is_b
    puts 'AMBIGUOUS'
  else
    puts 'MMYY'
  end
else
  if is_b
    puts 'YYMM'
  else
    puts 'NA'
  end
end


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

using namespace std;

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

using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

int main(){

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


    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    vector<int> water;
    vector<int> sugar;

    for(int i = 0; i <= 30; ++i){
        for(int j = 0; j <= 30; ++j){
            if(i == 0 and j == 0) continue;
            int tmp = 100*a*i+100*b*j;
            if(tmp > f) break;
            water.push_back(tmp);
        }
    }
    for(int i = 0; i <= 1000; ++i){
        for(int j = 0; j <= 1000; ++j){
            int tmp = c*i+d*j;
            if(tmp > f) break;
            sugar.push_back(tmp);
        }
    }

    double mx = -1;
    int sw = 0, sg = 0;
    rep(i, water.size()){
        rep(j, sugar.size()){
            if(water[i]+sugar[j] > f) continue;
            if(sugar[j]*100 > water[i]*e) continue;
            double con = (double)sugar[j]/(water[i]+sugar[j]);
            if(con > mx){
                mx = con;
                sw = water[i]+sugar[j];
                sg = sugar[j];
            }
        }
    }
    cerr << water << endl;
    cerr << sugar << endl;
    cout << sw << sp << sg << endl;

    return 0;
}


Measured memory_bytes: 1400
#[allow(dead_code)]
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(dead_code)]
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(dead_code)]
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")
    };
}

fn main() {
    input!{
        n: usize,
        sp: [(String, usize); n]
    }
    let mut spi: Vec<(String, usize, usize)> = sp.into_iter().enumerate().map(|(i, (s, p))| (s, p, i + 1)).collect();
    spi.sort_by(|&(ref ls, ref lp, _), &(ref rs, ref rp, _)| {
        match ls.cmp(&rs) {
            std::cmp::Ordering::Equal => rp.cmp(&lp),
            other => other
        }
    });
    for (_, _, i) in spi {
        println!("{}", i);
    }
}


Measured memory_bytes: 4352
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 123456789
//0x3f3f3f3f
#define INFL 10000000000000000
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
typedef pair<int,pii> pdii;
long long int MOD = 1000000007;
int main(){
	int a,b,c,d,e,f,g;
	cin>>a>>b>>c>>d>>e>>f>>g;
	ll ans=0;
	
	if(a>0&&d>0&&e>0){
		int cnt=0;
		if(a%2==1)cnt++;
		if(d%2==1)cnt++;
		if(e%2==1)cnt++;
		if(cnt==2)ans++;
		if(cnt==3)ans=ans+(ll)3;
		ans=ans+(a/2)*2+b+(d/2)*2+(e/2)*2;
	}else{
		ans=ans+(a/2)*2+b+(d/2)*2+(e/2)*2;
	}
	
	cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
//#include <math.h>
#include <cmath>

using namespace std;

string fmt(string str)
{
  string temp;
  if(str.size() < 6)
  {
    for(int i = 0; i < 6 - str.size(); i++)
    {
      temp.push_back('0');
    }
  }
  return temp + str;
}

int main()
{
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> cities(m), temp(m);
  for(int i = 0; i < m; i++)
  {
    int p, y;
    cin >> p >> y;
    cities[i] = {y, p};
  }
  temp = cities;
  sort(temp.begin(), temp.end());
  vector<int> mem(n, 0);
  map<pair<int, int>, string> result;
  for(int i = 0; i < m; i++)
  {
    int rank = ++mem[temp[i].second];
    string p_str = to_string(temp[i].second);
    string rank_str = to_string(rank);
    p_str = fmt(p_str);
    rank_str = fmt(rank_str);
    result[temp[i]] = p_str + rank_str;
  }
  for(int i = 0; i < m; i++)
  {
    cout << result[cities[i]] << endl;
  }
	return 0;
}


Measured memory_bytes: 15488
#include<iostream>
#include<cstdio>
#define INF 1<<30
#define FinishFunction return 0
#define MAX 1000000
using namespace std;
         
struct edge {
  int from,to,cost,k;
};
       
edge es[MAX];
       
int main(){
  int n,u,k,E,c,v;
  E = 0;
  scanf("%d",&n);
       
  for(int i=0;i<n;i++){
    scanf("%d %d",&u,&k);
          
    for(int j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      es[E].from = u;
      es[E].to = v;
      es[E++].cost = c;
    }
  }
       
  // Ika berumanfo-do
  int d[MAX];
  for(int i=0;i<n;i++)d[i] = INF;
  d[0] = 0;
  while(true){
    bool update = false;
    for(int i=0;i<E;i++){
      edge e = es[i];
      if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
    d[e.to] = d[e.from] + e.cost;
    update = true;
      }
    }
    if(!update)break;
  }
  for(int i=0;i<n;i++)cout << i << " " << d[i] << endl;
  FinishFunction;// return 0
}

Measured memory_bytes: 9400
#include <bits/stdc++.h>
using namespace std;
int main() {
	int q,t,x;
	cin >> q;
	set<int> set;
	for (int i = 0; i < q; ++i) {
		cin >> t >> x;
		switch (t) {
		case 0: set.insert(x);
			cout << set.size() << std::endl;
			break;
		case 1:
			cout << set.count(x) << std::endl;
			break;
		default:
			set.erase(x);
		}
	}
}


Measured memory_bytes: 12480
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var h = new HashSet<string>();
		for(int i = 0; i < n; i++)
		{
			var s = Console.ReadLine();
			if(!h.Contains(s))
			{
				h.Add(s);
			}
		}
		Console.WriteLine(h.Count);
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

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

long long int a ;
long long int b ;
char str[100] ;

int main ( )
{
	while ( scanf ( "%lld %lld" , &a , &b ) == 2 ) {
		sprintf ( str , "%lld" , a + b ) ;
		printf ( "%d\n" , strlen ( str ) ) ;
	}
	return 0 ;
}

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

const ll MOD = 1e9 + 7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n, m;
	cin >> n >> m;
	char tbl[n+1][m+1];
	ll dp[n+1][m+1];
	for(ll i=1; i<=n; i++)
		for(ll j=1; j<=m; j++){
			cin >> tbl[i][j];
			dp[i][j] = 0;
		}
	for(ll j=0; j<=m; j++)
		dp[0][j] = 0;
	for(ll j=0; j<=n; j++)
		dp[j][0] = 0;
	for(ll i=1; i<=n; i++)
		for(ll j=1; j<=m; j++){
			if(tbl[i][j] != '#'){
				if(i == 1 and j == 1)
					dp[i][j] = 1;
				else
					dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
			}
		}
	cout << dp[n][m];
	return 0;
}

Measured memory_bytes: 12332
def warshall_floyd(n,d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

def examD():
    N, M = LI()
    D = [[float("inf") for i in range(N)] for i in range(N)]
    # d[u][v] : 辺uvのコスト(存在しないときはinf)
    XY = [[0,0]]*M
    for i in range(M):
        x, y, z = map(int, input().split())
        XY[i] = [x-1,y-1]
        D[x - 1][y - 1] = z
        D[y - 1][x - 1] = z
    for i in range(N):
        D[i][i] = 0  # 自身のところに行くコストは０
    d = copy.deepcopy(D)
#    print(warshall_floyd(N, d))
    W = warshall_floyd(N, d)
    cur = int(0)
    for i in range(M):
        if D[XY[i][0]][XY[i][1]]>W[XY[i][0]][XY[i][1]]:
            cur += 1
    print(cur)

import sys
import copy
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()


Measured memory_bytes: 4292
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"log"
	"os"
	"strconv"
)

// const abcd = "abcdefghijklmnopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var dr = [...]int{0, 1, 1, 1, 0, -1, -1, -1, 0}
var dc = [...]int{1, 1, 0, -1, -1, -1, 0, 1, 0}

func main() {
	log.SetFlags(log.Lshortfile)
	nextReader = NewScanner()
	N := nextInt()
	K := nextInt()
	cnt := 0
	for a := 1; a <= N; a++ {
		le := a % K
		less := (K - le) % K
		sz := (N + less) / K
		if (less+less)%K == 0 {
			cnt += sz * sz
		}
	}
	fmt.Println(cnt)
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

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

func printInts(out []int, str string) {
	var bb bytes.Buffer
	for i := range out {
		bb.WriteString(strconv.Itoa(out[i]))
		bb.WriteString(str)
	}
	fmt.Println(bb.String())
}

var nextReader func() string

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline

goal, m = map(int, input().split())
sa = set()
sb = set()

for i in range(m):
  a, b = map(int, input().split())
  if a==1:
    sb.add(b)
  if b==goal:
    sa.add(a)
print("IMPOSSIBLE" if len(sa&sb)==0 else "POSSIBLE")    
    
  

Measured memory_bytes: 18892
#include <iostream>
#include <vector>
#define rep(i, n) for (int i=0; i < (n); i++)
using namespace std;

int main() {
    int n, l;
    cin >> n >> l;
    vector<int> a(n);
    rep(i, n) {
        a[i] = l + i;
    }

    int sum = 0;
    rep(i, n) sum += a[i];
    int ans = 1e9;

    rep(i, n) {
        int t = sum -a[i];
        if (abs(t-sum) < abs(ans - sum)) ans = t;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


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


  char c;
  cin>>c;
  cout<<(char)(c+1)<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
  string s;
  cin >> s;
  cout <<s[0]<<s[1]<<s[2]<<s[3]<<s[4]<<" "<<s[6]<<s[7]<<s[8]<<s[9]<<s[10]<<s[11]<<s[12]<<" "<<s[14]<<s[15]<<s[16]<<s[17]<<s[18]<<endl;
}

Measured memory_bytes: 256
from collections import deque

k = int(input())
ans = deque([str(i) for i in range(1, 10)])
que = deque(ans)
while que:
    num = que.popleft()
    if num[-1] == '0':
        que.append(num + '0')
        que.append(num + '1')
        ans.append(num + '0')
        ans.append(num + '1')
    elif num[-1] in [str(i) for i in range(1, 9)]:
        n_last = int(num[-1])
        que.append(num + str(n_last-1))
        que.append(num + str(n_last))
        que.append(num + str(n_last + 1))
        ans.append(num + str(n_last - 1))
        ans.append(num + str(n_last))
        ans.append(num + str(n_last + 1))
    else:
        que.append(num + '8')
        que.append(num + '9')
        ans.append(num + '8')
        ans.append(num + '9')
    if len(ans) >= k:
        print(ans[k-1])
        exit()



Measured memory_bytes: 15464
import java.util.Scanner;

public class Main{
	public static void main(String[] arg){
		//データの入力の準備
		Scanner sc  = new Scanner(System.in);
		
		while(true){
			//データの入力
			int h = sc.nextInt();
			int w = sc.nextInt();
			
			if(h == 0 && w == 0){
				break;
			}
			
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					if(i == 0 || i == h - 1 || j == 0 || j == w -1){
						System.out.print('#');
					}else{
						System.out.print('.');
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
}


Measured memory_bytes: 36980
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#define graph_from1 true
#define graph_tree true
#define graph_weight false
#define mod 1000000007
typedef long long ll;
using namespace std;

class Graph_func
{
public:
	int N;
	int N_edge;
	int K;
	int paintini;
	ll ans;
	vector<pair<int, int> > edgelist;
	vector<int> edgeweight;
	vector<vector<int> > adjlist;
	vector<vector<int> > adjlistweight;
	vector<int> adjnum;

	vector<int> xdist;

	vector<bool> x_fixed;

	void read_edge();
	void adjini();
	ll paint(int n, int n_old);

	bool xydist_def = false;
};

void Graph_func::read_edge()
{
	cin >> N >> K;
	if (graph_tree)
		N_edge = N - 1;// graph
	else
		cin >> N_edge;
	edgelist.resize(N_edge);
	edgeweight.resize(N_edge);
	adjnum.resize(N);
	xdist.resize(N);
	adjlist.resize(N);
	if (graph_weight)
		adjlistweight.resize(N);
	//cout << N << " " << N_edge << endl;
	for (int i = 0; i < N_edge; i++)
	{
		if (graph_weight)
			cin >> edgelist[i].first >> edgelist[i].second >> edgeweight[i];
		else
			cin >> edgelist[i].first >> edgelist[i].second;
		if (graph_from1)
		{
			edgelist[i].first--;
			edgelist[i].second--;
		}
	}
	return;
}

void Graph_func::adjini()
{
	for (int i = 0; i < N; i++)
		adjnum[i] = 0;
	for (int i = 0; i < N_edge; i++)
	{
		int x = edgelist[i].first;
		int y = edgelist[i].second;
		int xyweight = edgeweight[i];
		adjlist[x].push_back(y);
		adjlist[y].push_back(x);
		if (graph_weight)
		{
			adjlistweight[x].push_back(xyweight);
			adjlistweight[y].push_back(xyweight);
		}
		adjnum[x]++;
		adjnum[y]++;
	}
	return;
}


ll Graph_func::paint(int n, int n_old) // included adjini()
{
	int Nsum = adjnum[n];
	int count = 0;
	for (int i = 0; i < Nsum; i++)
	{
		int n_new = adjlist[n][i];
		if (n_new != n_old)
		{
			int paintN = K - 2 - count;
			if (n == paintini)
				paintN++;
			paintN = max(0, paintN);
			paintN %= mod;
			ans *= paintN;
			ans %= mod;
			count++;
			paint(n_new, n);
		}
	}
}

int main(void)
{
	Graph_func graph;
	graph.read_edge();
	graph.adjini();
	graph.ans = graph.K;
	int Nsta = 0;
	graph.paintini = Nsta;
	graph.paint(Nsta, mod);
	cout << graph.ans << endl;

	return 0;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  map<ll, ll> mp;
  rep(i, n){
    int a, b;
    cin >> a >> b;
    mp[a] += b;
  }

  ll cnt = 0;
  for(pair<ll, ll> p : mp){
    cnt += p.second;
    if(cnt >= k){
      cout << p.first << endl;
      return 0;
    }
  }

  return 0;
}



Measured memory_bytes: 4224
n, m = map(int, input().split())
info = []
for _ in range(m):
    l, r = map(int, input().split())
    info.append([l, r])
# print(info)
L = 0
R = 10**5 + 1
for l, r in info:
    # Lb, Rb = True, True
    if l < L:
        pass
    elif L <= l <= R:
        L = l
    else:
        print(0)
        exit()
    if R < r:
        pass
    elif L <= r <= R:
        R = r
    else:
        print(0)
        exit()
    # if not (Lb or Rb):
    #     print(0)
    #     exit()
    # print(L, R)

print(R - L + 1)
    

Measured memory_bytes: 19600
N,C=map(int,input().split())

L=[]
for i in range(N):
    x,y=map(int,input().split())
    L.append([x,y])
    
l=L[::-1]
L=[[0,0]]+L
R=[]

for i in range(N):
    R.append([C-l[i][0],l[i][1]])
R=[[0,0]]+R


#print(L)
#print(R)
TS=[0]
TW=[0]
RS=[0]
RW=[0]

for i in range(N):
    TS.append(TS[i]-L[i+1][0]+L[i][0]+L[i+1][1])
    TW.append(TW[i]-2*(L[i+1][0]-L[i][0])+L[i+1][1])
    RS.append(RS[i]-R[i+1][0]+R[i][0]+R[i+1][1])
    RW.append(RW[i]-2*(R[i+1][0]-R[i][0])+R[i+1][1])
    
MTS=[0]
MRS=[0]
for i in range(1,N+1):
    MTS.append(max(MTS[i-1],TS[i]))
    MRS.append(max(MRS[i-1],RS[i]))

ans=0
for i in range(N+1):
    if i>0 and L[i-1][0]*2>C:
        break
    else:
        if ans<TW[i] + MRS[N-i]:
            ans=TW[i] + MRS[N-i]
            
for i in range(N+1):
    if i>0 and R[i-1][0]*2>C:
        break
    else:
        if ans<RW[i]+MTS[N-i]:
            ans=RW[i]+MTS[N-i]
print(ans)

Measured memory_bytes: 58556
# coding: utf-8
N, X = map(int, input().split())
L = list(map(int, input().split()))
L.insert(0, 0)

dp = 0
i = 0
count = 0

for i in range(N+1):
    dp += L[i]
    if dp <= X:
        count += 1
print(count)

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

void func143b() {
  int n, d[50] = {};
  int i, j, x, y, cnt = 0;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> d[i];
  for (i = 1; i < n; i++) {
    x = d[i];
    //cout << "takoyaki_" << i << ": " << x << endl;
    for (j = i + 1; j <= n; j++) {
      y = d[j];
      cnt += x * y;
      //cout << "takoyaki_" << j << ": " << y << endl;
      //cout << "x * y: " << x * y << endl;
      //cout << "cnt: " << cnt << endl;
    }
  }
  cout << cnt;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,ans=0,a,b,aa=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    if(aa<a){
      aa=a;
      ans=a+b;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main(void)
{
    string s;
    
    cin >> s;
    
    int len = s.length();
    string bef = s.substr(0, (len-1)/2);
    string aft = s.substr((len+1)/2, (len-1)/2);
    if (bef != aft) { cout << "No" << endl; return 0; }
    reverse(bef.begin(), bef.end());
    if (bef != aft) { cout << "No" << endl; return 0; }
    cout << "Yes" << endl;
    
    return 0;
}


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

using namespace std;
int main(int argc, const char * argv[]) {
    int h, w, i, j, cnt;
    cin >> h >> w;
    int map[h][w];
    int ans[h*w][4];
    cnt = 0;
    for(i = 0;i < h;i++){
        for(j = 0;j < w;j++){
            cin >> map[i][j];
            ans[i][j] = -1;
        }
    }
    for(i = 0;i < h;i++){
        for(j = 0;j < w;j++){
            if(j != w-1 && map[i][j] % 2 == 1){
                ans[cnt][0] = i+1;
                ans[cnt][1] = j+1;
                ans[cnt][2] = i+1;
                ans[cnt][3] = j+2;
                map[i][j]--;
                map[i][j+1]++;
                cnt++;
            }else if(j == w-1 && map[i][j] % 2 == 1 && i != h-1){
                ans[cnt][0] = i+1;
                ans[cnt][1] = j+1;
                ans[cnt][2] = i+2;
                ans[cnt][3] = j+1;
                map[i][j]--;
                map[i+1][j]++;
                cnt++;
            }
        }
    }
    printf("%d\n", cnt);
    for(i = 0;i < cnt;i++){
        printf("%d %d %d %d\n", ans[i][0], ans[i][1], ans[i][2], ans[i][3]);
    }
    
    
    return 0;
}

Measured memory_bytes: 7040
#include <iostream>
#include <cstdio>
#include <string.h>
using namespace std;

int main()
{
    char s[1234];

    scanf("%s",s);

    int len=strlen(s);

    printf("%c%d%c\n",s[0],len-2,s[len-1]);
    return 0;
}


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

#define ll long long
#define vi vector<int>
#define REP(i, n) for (int i = 0; i < n; i++)
#define check cout << "OK" << endl

int main() {
  int x, n;
  cin >> x >> n;
  vi p(300, 0);
  REP(i, n) {
    int a;
    cin >> a;
    p[a + 150] = 1;
  }

  REP(i, 150) {
    if (p[x - i + 150] == 0) {
      cout << x - i << endl;
      break;
    } else if (p[x + i + 150] == 0) {
      cout << x + i << endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std; 
#define all(c) c.begin(),c.end()
#define REP(i,a,b) for(int i=a;i<=b;++i)
#define tr(container,it) \
for(auto it=container.begin();it!=container.end();++it)
typedef long long ll ; 
typedef vector<int> vi;
#define mod 1000000007 

int main()
{
  //  freopen("input.txt","r",stdin);
   ios::sync_with_stdio(0);
   // cin.tie(0);
  ll n;
  cin>>n;
vector<ll>v(n);
   REP(i,0,n-1)
   cin>>v[i];
 //  sort(all(v));
vector<ll>pre(n);
pre[0]=v[0];
for(ll i=1;i<n;++i)
pre[i]=(pre[i-1]%mod+v[i]%mod)%mod;
ll sum=0;
for(ll i=1;i<n;++i)
sum=(sum+((v[i]%mod)*(pre[i-1]%mod))%mod)%mod;
cout<<sum;



    return 0;
}

Measured memory_bytes: 6424
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
//#include <ostream>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  vector<int> num(3);
  rep(i,3)cin >> num[i];
  sort(num.begin(),num.end());
  bool hantei = false;
  if(num[0]==num[1]&&num[1]!=num[2]) hantei = true;
  if(num[0]!=num[1]&&num[1]==num[2]) hantei = true;
  if(hantei)cout << "Yes" <<  endl;
  else  cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,x,y,h[100001],ans,a[100001];
vector<int> v[100001];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>h[i];
	for(int i=1;i<=m;i++)
	{
		cin>>x>>y;
		a[x]++;
		a[y]++;
		v[x].insert(v[x].begin()+a[x]-1,y);
		v[y].insert(v[y].begin()+a[y]-1,x);
	}
	for(int i=1;i<=n;i++)
	{
		int fl=1;
		if(v[i].size()==0)
		{
			ans++;
			continue;
		}
		for(int j=0;j<=v[i].size()-1;j++)
		{
			if(h[i]<=h[v[i][j]])
			{
				fl=0;
				break;
			}
		}
		ans+=fl;
	}
	cout<<ans;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    int k;
    string ss;
    cin>>k>>s;
    if(s.length()>k){
        for(int i=0; i<k; i++){
            ss += s[i];
        }
        ss+="...";
    }
    else {
        ss =s;
    }
    cout<<ss;
    return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define mp make_pair
const int mod=1e9+7;
void solve()
{
  long long int a,b,k;
     cin>>a>>b>>k;
     vector<ll> A(a);
     vector<ll> B(b);
     for(int i=0;i<a;i++){
     	cin>>A[i];
	 }
	 for(int j=0;j<b;j++){
	 	cin>>B[j];
	 }
	 vector<long long int> temp;
	 vector<long long int> temp2;
	 ll sum=A[0];
	 ll i=0;
	 while(sum<=k&&i<a){
	 	temp.push_back(sum);
	 	i++;
	 	sum+=A[i];
	 }
	 sum=B[0];
	 i=0;
	 while(sum<=k&&i<b){
	 	temp2.push_back(sum);
	 	i++;
	 	sum+=B[i];
	 }
	 ll ans=0;
	 ll j=temp.size();
	 ans=max(ans,j);
	 j=temp2.size();
	 ans=max(ans,j);
	 for(ll i=0;i<temp.size();i++){
	 	sum=k-temp[i];
	 	long long int index=upper_bound(temp2.begin(),temp2.end(),sum)-temp2.begin();
		ans=max(ans,i+1+index);
	 }
	 cout<<ans<<"\n";
}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 11008
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
// #include <stdio.h>

int main(){
	int h, w, k;
	std::cin >> h >> w >> k;
	std::string s;
	std::vector< std::vector<int> > a(h);

	//intialize
	for(int ih=0; ih<h; ih++){
		a[ih].resize(w);
		for(int iw=0; iw<w; iw++){
			a[ih][iw] = 0;
		}
	}

	//input
	int c = 0;
	for(int ih=0; ih<h; ih++){
		std::cin >> s;
		if ((int)s.find("#") == -1) continue;
		int sc = 0;
		c++;
		for(int iw=0; iw<w; iw++){
			if(s[iw]=='#'){
				sc++;
				if(sc>=2) c++;
			}
			a[ih][iw] = c;
		}
	}

	//follow
	int follow = -1;
	std::vector<int> p(h);
	for(int ih=0; ih<h; ih++){
		if(a[ih][0]!=0){
			if(follow==-1){
				for(int ih2=0; ih2<ih; ih2++){
					p[ih2] = ih;
				}
			}
			follow = ih;
		}
		p[ih] = follow;
	}
	for(int ih=0; ih<h; ih++){
		if(a[ih][0]!=0) continue;
		for(int iw=0; iw<w; iw++){
			a[ih][iw] = a[p[ih]][iw];
		}
	}

	//output
	for(int ih=0; ih<h; ih++){
		for(int iw=0; iw<w; iw++){
			std::cout << a[ih][iw];
			if(iw==w-1) std::cout << std::endl;
			else std::cout << " ";
		}
	}

	return 0;
}


Measured memory_bytes: 1152
#include<string>
#include<cstdlib>
#include<iostream>

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

using namespace std;

typedef long long ll;

int var[128];

ll expr(const string &,int &);
ll term(const string &,int &);
ll factor(const string &,int &);
ll primary(const string &,int &);
ll number(const string &,int &);

ll expr(const string &s,int &idx){
	ll a=term(s,idx);
	while(idx<s.length() && (s[idx]=='+' || s[idx]=='-')){
		char op=s[idx++];
		if     (op=='+') a+=term(s,idx);
		else if(op=='-') a-=term(s,idx);
	}
	return a;
}

ll term(const string &s,int &idx){
	ll a=factor(s,idx);
	while(idx<s.length() && s[idx]=='*'){
		idx++;
		a*=factor(s,idx);
	}
	return a;
}

ll factor(const string &s,int &idx){
	ll a=primary(s,idx);
	if(idx<s.length() && s[idx]=='^'){
		idx++;
		ll b=primary(s,idx);
		ll apowb=1;
		rep(i,b) apowb*=a;
		a=apowb;
	}
	return a;
}

ll primary(const string &s,int &idx){
	ll a;
	if(s[idx]=='('){
		idx++;
		a=expr(s,idx);
		idx++;
	}
	else a=number(s,idx);
	return a;
}

ll number(const string &s,int &idx){
	ll a;
	if(isalpha(s[idx])) a=var[s[idx++]];
	else{
		for(a=0;idx<s.length()&&isdigit(s[idx]);idx++) a=10*a+(s[idx]-'0');
	}
	return a;
}

ll parse(const string &s){
	int idx=0;
	return expr(s,idx);
}

void normalize(string &s){
	string t;
	int n=s.length();
	// óð
	// ½¾µAóªÈ¢ÆÓ¡ªÏíéÆ±ë (_) ÉÍ ~ ðÍ³Þ
	rep(i,n) if(s[i]!=' ') {
		if(i>0 && s[i-1]==' ' && !t.empty()){
			if(isdigit(*t.rbegin()) && isdigit(s[i])) t+='*';
		}
		t+=s[i];
	}

	// BNF É¤æ¤É ~ ðÍ³Þ
	s.clear();
	n=t.length();
	rep(i,n){
		if(i>0){
			if(isdigit(t[i-1]) && isalpha(t[i])
			|| isdigit(t[i-1]) && t[i]=='('
			|| isalpha(t[i-1]) && isdigit(t[i])
			|| isalpha(t[i-1]) && isalpha(t[i])
			|| isalpha(t[i-1]) && t[i]=='('
			|| t[i-1]==')' && isdigit(t[i])
			|| t[i-1]==')' && isalpha(t[i])
			|| t[i-1]==')' && t[i]=='(') s+='*';
		}
		s+=t[i];
	}
}

int main(){
	for(string ex0;getline(cin,ex0),ex0!=".";){
		normalize(ex0);
		while(1){
			string ex; getline(cin,ex);
			if(ex==".") break;
			normalize(ex);

			bool ok=true;
			rep(_,100){
				for(int c='a';c<='z';c++) var[c]=rand()%7;
				if(parse(ex0)!=parse(ex)){ ok=false; break; }
			}
			puts(ok?"yes":"no");
		}
		puts(".");
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

typedef long long ll;

using namespace std;


int main(){

    string s,t,u;
    int a,b;

    cin >> s >> t;
    cin >> a >> b;
    cin >> u;

    if(s == u){
        cout << a- 1 << " " << b << endl;
    }else{
        cout << a << " " << b - 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define nl '\n'

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int , int> pi;


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int s, w;
	cin>>s>>w;
	if(w >= s) 
	{
		cout<<"unsafe\n";
	}
	else
	{
		cout<<"safe\n";
	}
	
	return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String strA = sc.nextLine();
		int intA = Integer.parseInt(strA);
		int[] arrayInt =  new int[intA];
		int max = 0;
		int min = 0;
		long intSumCount = 0;

		for(int i = 0; i < intA; i++) {
			arrayInt[i] = sc.nextInt();
			intSumCount = intSumCount + arrayInt[i];
		}
		max = arrayInt[0];
		min = arrayInt[0];
		for(int j = 0; j < arrayInt.length; j++) {
			if(max < arrayInt[j]) {
				max = arrayInt[j];
			}
			if(arrayInt[j] < min) {
				min = arrayInt[j];
			}
		}
		System.out.printf("%d %d %d%n",min, max, intSumCount);
	//	System.out.println("?????§?????? : "+max);
	//	System.out.println("????°??????? : "+min);
	//	System.out.println("????¨??????? : "+ intSumCount);
	}
}

Measured memory_bytes: 41816