akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T>
struct fenwick_tree {
	vector<T> x,lazy;
	fenwick_tree(int n) : x(n + 1, 0), lazy(n + 1, 0) { }
	T sum(int r) {
		T S = 0;

		for (int k = r; k > 0; k -= k&-k) {
			S += x[k] + lazy[k]*(k&-k);
			for (int cp = k + (k&-k); cp < x.size() && k - (k&-k) == cp - (cp&-cp); cp += cp&-cp)
				S += lazy[cp] * (r - (k - (k&-k)));
		}
		return S;
	}
	void add(int r, T a) {
		for (int k=r; k > 0; k -= k&-k) {
			lazy[k] += a;
			for (int cp = k + (k&-k); cp < x.size() && k-(k&-k) == cp-(cp&-cp); cp += cp&-cp)
				x[cp] += a * (r-(k - (k&-k)));
		}
	}
};


int main()
{
	int n, q;
	cin >> n >> q;
	fenwick_tree<ll> fen(n);

	REP(i, q) {
		int m;
		scanf("%d", &m);
		if (m) {
			int s, t;
			scanf("%d %d", &s, &t);

			printf("%lld\n", fen.sum(t) - fen.sum(s-1));
		}
		else {
			int s, t, x;
			scanf("%d %d %d", &s, &t, &x);

			fen.add(t,x);
			fen.add(s-1, -x);
		}
	}

	return 0;
}


Measured memory_bytes: 4412
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <sstream>
using namespace std;

// Is it a Right Triangle?(0003)
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		vector<int> dat(3);
		for (int j = 0; j < 3; ++j)
			cin >> dat[j];

		sort(dat.begin(), dat.end(), greater<int>());

		if (dat[0] * dat[0] == dat[1] * dat[1] + dat[2] * dat[2])
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		List<String> tmp = new ArrayList<>();

		while (scanner.hasNext()) {
			tmp.add(scanner.next());
		}
		String[] input = tmp.toArray(new String[tmp.size()]);
		Arrays.sort(input);
		System.out.println(Math.abs(minus(input[1], input[0]) + minus(input[2], input[1])));
	}

	private static int minus(String a, String b) {
		return Integer.parseInt(a) -  Integer.parseInt(b);
	}

}

Measured memory_bytes: 20948
import java.io.*;
import java.util.StringTokenizer;
   
class Main{
   
static final PrintWriter out=new PrintWriter(System.out);

static class binarySearchTree{

static class Node{
int id;
Node p;
Node l;
Node r;
int deg;
Node(int id){
this.id=id; this.p=null; this.l=null; this.r=null; this.deg=0;
}
}

private static Node root;

binarySearchTree(){
root=null;
}

private static void insert(int v){
if(root==null) root=new Node(v);
else __insert(new Node(v));
}

private static void __insert(Node z){
Node x=root;
Node y=null;
while(x!=null){
y=x;
if(z.id<x.id) x=x.l;
else x=x.r;
}
z.p=y;
if(z.id<y.id) y.l=z;
else y.r=z;
y.deg++;
}

private static boolean find(int v){
if(root==null) return false;
else return __find(v);
}

private static boolean __find(int v){
Node x=root;
while(x!=null){
if(x.id==v) return true;
else if(x.id>v) x=x.l;
else x=x.r;
}
return false;
}

private static void print(){
inorder(root);
out.println();
preorder(root);
out.println();
}

static void preorder(Node now){
if(now==null) return;
out.print(" "+now.id);
preorder(now.l);
preorder(now.r);
}
 
static void inorder(Node now){
if(now==null) return;
inorder(now.l);
out.print(" "+now.id);
inorder(now.r);
}
 
static void postorder(Node now){
if(now==null) return;
postorder(now.l);
postorder(now.r);
out.print(" "+now.id);
}
}

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
binarySearchTree tree=new binarySearchTree();
int num=Integer.parseInt(br.readLine());
for(int i=0;i<num;i++){
st=new StringTokenizer(br.readLine());
String command=st.nextToken();
int n;
if("insert".equals(command)){
n=Integer.parseInt(st.nextToken());
tree.insert(n);
}
else if("find".equals(command)) {
n=Integer.parseInt(st.nextToken());
out.println((tree.find(n))?"yes":"no");
}
else tree.print();
}
out.flush();
}
}

Measured memory_bytes: 151972
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i = (a); i < (b); i++)
#define pb push_back
#define fs first
#define sc second
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const double EPS = 1e-9;

int main() {
    cin.sync_with_stdio(false);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(a*c, max(a*d, max(b*c,b*d))) << endl;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    if (a[0] != 0) {
        cout << -1 << endl;
        return 0;
    }
    ll ans = 0;
    rep(i, n - 1) {
        if (a[i] + 1 == a[i + 1]) {
            ans++;
        } else if (a[i] + 1 < a[i + 1]) {
            cout << -1 << endl;
            return 0;
        } else {
            ans += a[i + 1];
        }
    }
    cout << ans << endl;
}

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


using namespace std;


int main()
{
  string o, e, a="";

  cin >> o;
  cin >> e;
  for (int i=0; i<e.length(); i++){
    a += o[i];
    a += e[i];
  }

  if (o.length() != e.length()) a += o.back();

  cout << a << endl;
  
  return 0;
}


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

using namespace std;

int main() {
	string s;
	int k;
	cin >> k >> s;
	
	if (k < s.length()) {
		cout << s.substr(0, k) << "...";
	}
	else {
		cout << s;
	}
	
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int S, W;
    cin >> S >> W;
    if (W >= S) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}


Measured memory_bytes: 3636
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 六 11/11 23:55:52 2017

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

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
const int MaxN = 1e5;

inline void OPEN(string s){
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

int n, a, b;
int num[MaxN + 5];

int main()
{
	while(~scanf("%d %d %d", &n, &a, &b)){
		for(int i = 1; i <= n; i++) scanf("%d", &num[i]);
		if(n == 1) printf("%d\n", abs(b - num[n]));
		else printf("%d\n", max(abs(num[n - 1] - num[n]),  abs(b - num[n])));
	}
    return 0;
}


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

import numpy as np
import scipy as sp

def main():
    try:
        li = list(map(int, input().split()))
        min_time = 1e100
        if li[0] + li[1] < min_time:
            min_time = li[0] + li[1]
        if li[1] + li[2] < min_time:
            min_time = li[1] + li[2]
        if li[2] + li[0] < min_time:
            min_time = li[2] + li[0]
        print(min_time)
    except:
        pass

if __name__ == '__main__':
    main()


Measured memory_bytes: 12536
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main()
{
    int num;
    cin >> num;
    vector<pair<int,int> > v;
    int currentx, currenty;
    for(int i=0;i<num;i++){
        cin >> currentx >> currenty;
        v.push_back(make_pair(currentx,currenty));
    }
    int p,q;
    int ans = num;
    for(int i=0;i<num;i++){
        for(int j=0;j<num;j++){
            if(i==j){
                continue;
            }
            p = v[i].first - v[j].first;
            q = v[i].second - v[j].second;
            int currentans = num;
            for(int k=0;k<num;k++){
                for(int l=0;l<num;l++){
                    if((v[k].first-v[l].first == p)&&(v[k].second-v[l].second == q)){
                        currentans --;
                        break;
                    }
                }
            }
            if(currentans<ans){
                ans = currentans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

static const int MAXN = 1e5 + 10;

int a , b , c;
int ans;

int main()
{
    scanf("%d%d%d" , &a , &b , &c);
    ans = a * 100 + b * 10 + c;
    if(ans % 4 == 0)
        printf("YES");
    else
        printf("NO");
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)

int main(void) {
  int N;
  std::cin >> N;

  std::map<std::string,int64_t> tbl;
  rep(i, N) {
    std::string S;
    std::cin >> S;
    std::sort(S.begin(), S.end());
    tbl[S]++;
  }

  std::int64_t ANS = 0;
  for (const auto& x : tbl){
    ANS += x.second * (x.second-1) / 2;
  }
  std::cout << ANS << std::endl;
  return 0;
}


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

int main() {
  ll N, K;
  cin >> N >> K;

  map<ll, ll> mp;
  rep(i,0,N-1) {
    ll a, b;
    cin >> a >> b;
    mp[a] += b;
  }

  ll sum = 0;
  for (auto p : mp) {
    sum += p.second;
    if (K <= sum) {
      cout <<  p.first << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 7504
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,now_time;
  cin >> n;
  ll a[n],b[n];
  P task[n];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    task[i] = P(b[i],a[i]);
  }
  sort(task,task+n,greater<P>());
  now_time = task[0].first;
  for(int i=0;i<n;i++){
    if(task[i].first<now_time){
      now_time = task[i].first;
    }
    now_time -= task[i].second;
  }
  if(now_time<0){
    cout << "No\n";
  }else{
    cout <<"Yes\n";
  }
}


Measured memory_bytes: 6528
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();

        List<Integer> list = new ArrayList<>();
        for(int i = 0; i < q; i++){
            list.add(sc.nextInt());
        }

        Collections.sort(list);
        int index = 0;
        for(int i = 0;i < n;i++){
            if(index < q && list.get(index) == (i+1)){
                int count = 0;
                while(index < q && list.get(index) == (i+1)){
                    index++;
                    count++;
                }
                if(count > q-k){
                    System.out.println("Yes");
                } else {
                    System.out.println("No");
                }
            } else {
                if(q < k){
                    System.out.println("Yes");
                } else {
                    System.out.println("No");
                }
            }
        }

    }
}

Measured memory_bytes: 89908
#include <queue>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (1e9), dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};

bool in_range(int a, int b){
  return a >= 0 && a < b;
}

void dfs(vector<string> &S, int x, int y, vector< vector<int> > &D){
  int H = S.size(), W = S[0].length();
  if(x == H-1 and y == W-1) return ;
  for(int i = 0; i < 4; ++i){
    int x_ = x + dx[i], y_ = y + dy[i];
    if((!in_range(x_,H)) or (!in_range(y_,W))) continue;
    if(S[x_][y_] == '#') continue;
    if(D[x_][y_] >  D[x][y]+1){
      D[x_][y_] = min(D[x_][y_], D[x][y]+1);
      dfs(S,x_,y_,D);
    }
  }
}

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for(int i = 0; i < H; ++i) cin >> S[i];
  int c = 0;
  for(int i = 0; i < H; ++i){
    for(int j= 0; j < W; ++j){
      c += (S[i][j] == '.');
    }
  }
  vector< vector<int> > D(H, vector<int>(W,INF));
  D[0][0] = 1;
  dfs(S,0,0,D);
  if(D[H-1][W-1] == INF){
    cout << -1 << endl;
    return 0;
  }
  cout << c - D[H-1][W-1] << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long int
#define c(a) ll a; cin>>a;
#define cs(a) string a; cin>>a;
#define ci(a) cin>>a;
#define co(a) cout<<a;
#define nl cout<<endl;
#define ca(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
#define f0(i,a,n) for(ll i=a;i>=n;i--)
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,a,n) for(ll i=a;i<n;i++)
#define T ll t=1; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main()
{
    fast;
    c(l) c(r) c(d) 
    ll count=0;
    f1(i,l,r+1) if(i%d==0) count++;
    co(count);
    return 0;
}

/*It's not who I am underneath, but what I do that defines me

MMMMMMMMMMMMMMMMMMMMM.                             MMMMMMMMMMMMMMMMMMMMM
 `MMMMMMMMMMMMMMMMMMMM           M\  /M           MMMMMMMMMMMMMMMMMMMM'
   `MMMMMMMMMMMMMMMMMMM          MMMMMM          MMMMMMMMMMMMMMMMMMM'
     MMMMMMMMMMMMMMMMMMM-_______MMMMMMMM_______-MMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
     .MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM.
    MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
                   `MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM'
                          `MMMMMMMMMMMMMMMMMM'
                              `MMMMMMMMMM'
                                 MMMMMM 
                                  MMMM
                                   MM
*/


Measured memory_bytes: 3532
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        a: i64, b: i64, c: i64
    }
    println!("{}", if a <= c && c <= b {"Yes"} else {"No"});
}

Measured memory_bytes: 4352
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();

        bool ok = true;
        ok &= s.Any(c => c == 'a');
        ok &= s.Any(c => c == 'b');
        ok &= s.Any(c => c == 'c');

        return ok ? Yes : No;
    }


    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


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

int main() {

	int n, m; cin >> n >> m;

	int ans = 0;
	int tmp = pow(2, m);

	ans += m * 1900 * tmp + (n - m) * 100 * tmp;

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

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

N = int(input())

m = [[] for _ in range(N)]
for i in range(N):
    a = int(input())
    for _ in range(a):
        m[i].append(list(map(int, input().rstrip().split())))
        
def dfs(i, state):
    if i == N:
        for j, s in enumerate(state):
            if s == 1:
                for x, y in m[j]:
                    if y == 1 and state[x-1] == 0:
                        return 0
                    elif y == 0 and state[x-1] == 1:
                        return 0
        return sum(state)
        
    max_honest = 0
    max_honest = max(max_honest, dfs(i+1, state + [0]))
    max_honest = max(max_honest, dfs(i+1, state + [1]))
    
    return max_honest
    
print(dfs(0, []))

Measured memory_bytes: 48472
// vim:ts=4:sts=4:sw=4:et
// MOSCOW IPT JINOTEGA
// Table #14
#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;
typedef long long i64;

int gcd(int x, int y) {
    while (x) {
        y %= x;
        swap(x, y);
    }
    return y;
}



int main() {
#ifdef LOCAL
    assert(freopen("a.in", "r", stdin));
#endif
    //ios_base::sync_with_stdio(false);
    //
    
    int n, k;
    int g = 0, mx = 0;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        g = gcd(g, x);
        mx = max(mx, x);
    }

    if (k % g == 0 && k <= mx) {
        cout << "POSSIBLE\n";
    } else {
        cout << "IMPOSSIBLE\n";
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using ull = unsigned long long int;

int main() {
  using namespace std;
  ull x;
  cin >> x;
  ull y = 100;
  for(ull i=1;;i++) {
    y = y * 1.01;
    if( y >= x ) {
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 3624
import sys
import itertools

NM = input()
N = NM.split()[0]
M = NM.split()[1]
N = int(N)
M = int(M)

if (N<0 or 100<N ):
    sys.exit()
if ( M<0 or 100<M ):
    sys.exit() 
if ( N+M<2 ):
    sys.exit()

even = list(itertools.combinations(range(N),2))
odd  = list(itertools.combinations(range(M),2))

print (len(even) + len(odd))

    
    
    



Measured memory_bytes: 3700
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#define MN 100005
#define INF 1000000007
using namespace std;
long long n,s;
long long f(long long b, long long n) {
	if (n < b) return n;
	return f(b, n / b) + n % b;
}
int main() {
	scanf("%lld%lld", &n, &s);
	if (n == s) {
		printf("%lld", n + 1);
		return 0;
	}
	long long root_n = sqrt(n);
	for (int i = 2; i <= root_n; i++) {
		if (f(i, n) == s) {
			printf("%d", i);
			return 0;
		}
	}
	long long st = n/(root_n+1);
	for (int i = st; i >= 1; i--) {
		long long left = n / (i+1)+1,right=n/i;
		while (left <= right) {
			long long b = (left + right) / 2;
			if (n / b + n % b == s) {
				printf("%lld", b);
				return 0;
			}
			else if (n / b + n % b > s) left = b + 1;
			else right = b - 1;
		}
	}
	printf("-1");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
    int K, A, B;
    cin >> K >> A >> B;
    bool j = false;
    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            j = true;
            break;
        }
    }
    cout << (j ? "OK" : "NG") << endl;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String[] args) {
        HashSet<String> seen = new HashSet<>();
        Scanner sc = new Scanner(System.in);
        int tests = sc.nextInt();
        for (int t = 0; t < tests; t++) seen.add(sc.next());
        System.out.println(seen.size());

    }
}

Measured memory_bytes: 76808
#include<iostream>
using namespace std;
int L, A, B, C, D;
int rA = 0, rB = 0;
int main(){
cin >> L >> A >> B >> C >> D;
if( A - (A/C) * C > 0) { rA = 1;}
if( B - (B/D) * D > 0) { rB = 1;}
cout << L - max((A/C) + rA,(B/D) +rB ) << endl;
return 0;
}

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

const int INF = 1001001001;

int a[12][12];

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  rep(i,n) {
    cin >> c[i];
    rep(j,m) cin >> a[i][j];
  }

  int ans = INF;
  rep(s,1<<n) {//sは部分集合,1<<nで1を左にnずらす(2^n)
    int cost = 0;
    vector<int> d(m);
    rep(i,n) {
      if (s>>i&1) {//sのiビット目が立っているか
        cost += c[i];
        rep(j,m) d[j] += a[i][j];
      }
    }
    bool ok = true;
    rep(j,m) if (d[j] < x) ok = false;
    if (ok) ans = min(ans, cost);
  }
  if (ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


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

typedef long long ll;
#define PI 3.1415926535897932384626433
#define mod 1000000007

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

int lcm(int a, int b) { return a * b / gcd(a, b); }

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


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
  long a[200010],sum[200010],mina;
  int n;
  scanf("%d",&n);
  scanf("%ld",&sum[0]);
  for(int i=1;i<n;i++){
    scanf("%ld",&a[i]);
    sum[i]=sum[i-1]+a[i];
  }
  mina=labs(sum[n-1]-2*sum[0]);
  for(int i=1;i<n-1;i++)
    mina=min(mina,labs(sum[n-1]-2*sum[i]));
  printf("%ld\n",mina);
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<tuple>
#include<string>
typedef unsigned long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(ll i=(a);i>(b);i--)
#define F first
#define S second
using namespace std;
const ll INF = 1e12;
const double PI = 3.1415926535897932;
const int i_INF = 2147483647;
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; }


int main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min({ a,b }) << " " << max({ 0,a + b - n }) << endl;
	return 0;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	set<string>s;
	string w;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>w;
		s.insert(w);
	}
	cout<<s.size()<<endl;
	return 0;
}


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

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& vec) {
    out << "[";
    for (int x : vec) out << x << ", ";
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    #define dbg_var(x) cerr << #x << ": " << x << endl;
#endif
typedef unsigned long long ULL;

const LL MOD = 1000000007;

LL modpow(LL a, LL b){
    if(b == 0) return 1;
    LL k = modpow(a, b/2);
    k = k*k%MOD;
    if(b%2) k = k*a%MOD;
    return k;
}

LL inversem(LL x){
    return modpow(x, MOD - 2);
}

LL factt[1000100];
LL ifactt[1000100];
LL p[1000100];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n; cin >> n;
    
    factt[0] = 1;
    for(int i=1; i<=n + 50; i++) factt[i] = factt[i-1] * i % MOD;
    for(int i=0; i<=n + 50; i++) ifactt[i] = inversem(factt[i]);
    
    for(int k=(n+1)/2; k<n; k++) p[k] = factt[k-1] * factt[k] % MOD * ifactt[2*k-n] % MOD;
    
    //~ for(int k=1; k<n; k++) cout << k << ' ' << p[k] - p[k-1] << endl;
    
    LL ans = 0;
    for(int k=1; k<n; k++) ans = (ans + (p[k] + MOD - p[k-1]) * k % MOD) % MOD;
    cout << ans << '\n';
}


Measured memory_bytes: 21632
#include<stdio.h>
typedef struct{
  char sign;
  int value;
}Card;
void BubbleSort(Card*,int);
void SelectionSort(Card*,int);
int isStable(Card*,Card*,int);
void output(Card*,int,int);
 
int main()
{
  Card a[36],b[36];
  int i,j,n;
 
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf(" %c%d",&a[i].sign,&a[i].value);
    b[i] = a[i];
  }
 
  BubbleSort(a,n);
  SelectionSort(b,n);
  output(a,n,0);
  output(b,n,isStable(b,a,n));
 
  return 0;
}
   
void BubbleSort(Card a[],int n)
{
  int i,j;
  Card tmp;
 
  for(i=0; i<n; i++) 
    for(j=n-1; j>i; j--) 
      if(a[j].value < a[j-1].value){
    tmp = a[j];
    a[j] = a[j-1];
    a[j-1] = tmp;
      }
}
 
void SelectionSort(Card b[],int n)
{
  int i,j,minj;
  Card tmp;
 
  for(i=0; i<n-1; i++) {
    minj = i;
    for(j=i; j<n; j++) 
      if(b[j].value < b[minj].value) minj = j;
    if(minj != i) {
      tmp = b[i];
      b[i] = b[minj];
      b[minj] = tmp;
    }
  }
}
 
int isStable(Card in[],Card out[],int n) 
{
  int i,j,a,b;
  for(i=0; i<n; i++) 
    for(j=i+1; j<n; j++)
      for(a=0; a<n; a++)
    for(b=a+1; b<n; b++)
      if(in[i].value == in[j].value && in[i].sign == out[b].sign && in[j].sign == out[a].sign && in[i].value == out[b].value && in[j].value == out[a].value)
        return 1;
  return 0;
}
 
void output(Card a[], int n,int result)
{
  int i;
   
  for(i=0; i<n; i++) {
    printf("%c%d",a[i].sign,a[i].value);
    if(i<n-1) printf(" ");
  }
  if(!result) printf("\nStable\n");
  else printf("\nNot stable\n");
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i < (n)i++)
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define abs(a) llabs(a)
#define int int64_t
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{
   cin.tie(0);
   ios::sync_with_stdio(false);
   int i, j, k;
   int x;
   cin >> x;

   if (x == 2)
   {
      cout << 2 << '\n';
      return 0;
   }

   for (i = 3; i <= 10e5; i += 2)
   {
      k = 0;
      for (j = 3; j <= sqrt(i); j += 2)
      {
         if (i % j == 0)
         {
            k = 1;
            break;
         }
      }

      if (k == 0 && i >= x)
      {
         cout << i << '\n';
         return 0;
      }
   }

   return 0;
}

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int num = 0;
    num = B / A;
    if (num < C) {
        cout << num << endl;
    } else {
        cout << C << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	string s;
	cin>>s;
	if((s[0]==s[1] && s[2]==s[3] && s[0]!=s[2]) || (s[0]==s[2] && s[1]==s[3] && s[0]!=s[1]) || (s[0]==s[3] && s[1]==s[2] && s[0]!=s[1]))
		cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

const ll INF = 1e15;
typedef vector<vector<ll>> Matrix;
void warshall_floyd(Matrix& d) {
  ll n = SZ(d);
  REP(i, n) REP(j, n) REP(k, n) d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int main() {
  ll n, m, l;
  cin >> n >> m >> l;
  vector<vector<ll>> to(n, vector<ll>(n, INF));
  REP(i, n) to[i][i] = 0;
  REP(i, m) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    to[a][b] = c;
    to[b][a] = c;
  }
  warshall_floyd(to);
  REP(i, n) REP(j, n) {
    if (to[i][j] <= l)
      to[i][j] = 1;
    else
      to[i][j] = INF;
  }
  REP(i, n) to[i][i] = 0;
  warshall_floyd(to);
  ll q;
  cin >> q;
  REP(i, q) {
    ll s, t;
    cin >> s >> t;
    s--;
    t--;
    if (to[s][t] == INF)
      cout << -1 << endl;
    else
      cout << to[s][t] - 1 << endl;
  }
}


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


// Useful container manipulation / traversal macros
#define fori(i,a,b)    for(int i=a;i<=b;i++)
#define ford(i,a,b)   for(int i=a;i>=b;i--)
#define all(a)        a.begin(), a.end()
#define in(a,b)       ( (b).find(a) != (b).end())
#define tr(c,i)       for(auto i = (c).begin(); i != (c).end(); i++)
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define pb             push_back
#define fill(a,v)      memset(a, v, sizeof a)

typedef long long int lli;
typedef vector<int> vi;
typedef vector<long long int> vlli;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	
    if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }

    int n, k;
    cin>>n>>k;

    vlli h(n+1);

    fori(i, 1, n)
    cin>>h[i];

    sort(all(h));

    vlli diff;

    fori(i, 1, n-1){
        diff.pb(h[i+1] - h[i]);
    }

    //sort(all(diff));

    lli ans = INT64_MAX;

    fori(i, 0, n-k){
        lli val = accumulate(diff.begin()+i, diff.begin()+i + k - 1, 0);

        ans = min(ans, val);
    }

    cout<<ans;

}

Measured memory_bytes: 2168
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=200010;
int n,m,a[N],tr[2][N*4],now[2];
ll ans;
void build(int o,int l,int r){
	if(l==r){
		tr[0][o]=tr[1][o]=n;
		return;
	}
	tr[0][o]=tr[1][o]=0x7fffffff;
	int mid=(l+r)>>1;
	build(o<<1,l,mid);
	build(o<<1|1,mid+1,r);
	return;
}
void update(int o,int l,int r,int L,int R,int idx,int v){
	if(L<=l&&r<=R){
		tr[idx][o]=min(tr[idx][o],v);
		return;
	}
	int mid=(l+r)>>1;
	if(L<=mid)
		update(o<<1,l,mid,L,R,idx,v);
	if(R>mid)
		update(o<<1|1,mid+1,r,L,R,idx,v);
	return;
}
int query(int o,int l,int r,int x,int idx){
	if(l==r)
		return tr[idx][o];
	int mid=(l+r)>>1;
	if(x<=mid)
		return min(tr[idx][o],query(o<<1,l,mid,x,idx));
	return min(tr[idx][o],query(o<<1|1,mid+1,r,x,idx));
}
int main(){
	scanf("%d%d",&n,&m);
	build(1,1,n);
	now[0]=now[1]=n;
	for(int i=1;i<=m;i++){
		int opt,x;
		scanf("%d%d",&opt,&x);
		opt--;
		update(1,1,n,1,now[opt],opt^1,x);
		now[opt^1]=min(now[opt^1],x);
		update(1,1,n,x,x,opt,1);
	}
	for(int i=2;i<n;i++)
		ans+=max(query(1,1,n,i,0)-2,0)+max(query(1,1,n,i,1)-2,0);
	for(int i=2;i<n;i++){
		int tmp=query(1,1,n,i,0);
		if(tmp==1)
			break;
		ans-=tmp-2;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 7324
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

const double PI = acos(-1);

// galat hai

signed main(){
    IOS;
    int a, b, x;
    cin >> a >> b >> x;
    double t = 2.0*(a*a*b - x)/a/a/a;
    double theta = atan(t);
    if (0.5 * a * a * b <= x) cout << fixed << setprecision(10) << theta*180.0/PI << endl;
    else {
        theta = atan(2.0*x/a/b/b);
        cout << fixed << setprecision(10) << 90-theta*180.0/PI << endl;
    }
    return 0;
}

Measured memory_bytes: 640
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    return divisors


def F(a, b):
    return max(len(str(a)), len(str(b)))


N = int(input())
min_num = 10**9
for divisor in make_divisors(N):
    min_num = min(min_num, F(divisor, N // divisor))
print(min_num)


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

int div_time(int64_t hp) {
	int cnt;
	while (hp > 1) {
		hp /= 2;
		cnt++;
	}
	return cnt;
}

int64_t pow(int base, int time) {
	int64_t ans = 1;
	for (int i = 0; i < time; i++) {
		ans *= base;
	}
	return ans;
}

int main() {
	int64_t h;
	cin >> h;

	int time = div_time(h);
	cout << pow(2, time + 1) - 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n, m, d, ans = 0;
	string f[100];
	cin >> n >> m >> d;
	for (int i = 0; i < n; ++i) {
		cin >> f[i];
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			bool h = true, w = true;
			for (int k = 0; k < d; ++k) {
				if (i + k >= n || f[i + k][j] != '.')
					h = false;
				if (j + k >= m || f[i][j + k] != '.')
					w = false;
			}
			if (h)ans++;
			if (w)ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,n,m) for(int i=n;i<=m;i++)
#define read(n) cin>>n;
#define write(n) cout<<n;
using namespace std;
double n,a,b,c;
int main()
{
	read(n);
	a=b=c=n/3;
	n=a*b*c;
	printf("%.10f",n);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int N;cin >> N;
    int kisu=1;
    for(int i=0;i<N;i++){
        int n; cin >> n;
        if(n%2==0) kisu*=2;
    }
    cout << pow(3,N)-kisu << endl;
}


Measured memory_bytes: 256
N = int(input())

def dfs(s):
  #文字列sで始まる七五三数の個数
  if int(s) > N:
    return 0
  
  # s自体が七五三数なら+1
  ret = 1 if all(s.count(c) > 0 for c in '753') else 0
  
  for c in '753':
    ret += dfs(s+c)
  
  return ret

print(dfs('0'))

Measured memory_bytes: 9092
#include<iostream>
using namespace std;
int main () {
  char s;
  cin >> s;
  if (s == 'A') cout << 'T' << endl;
  if (s == 'T') cout << 'A' << endl;
  if (s == 'G') cout << 'C' << endl;
  if (s == 'C') cout << 'G' << endl;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
long long int n, arr[N], cs[N];
int main(){
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    long long int ans = 0, mod = 1e9 + 7, sum = arr[0];
    for(int i = 1 ; i < n; i++){
        ans += sum * arr[i] % mod;
        ans %= mod;
        sum += arr[i];
        sum %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5192
#include <iostream>
#include <cmath>
using namespace std;
int main(void) {
	int n, m;
	cin >> n >> m;
	int AC = (n - m) * 100;
	int TLE = 1900 * m;
	int num = pow(2, m);
	cout << (AC + TLE) * num << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define long long long
#define pll pair < long , long >
#define vll vector < pll >
#define ml map < long , long >
#define mll map < pll , long >
#define x first
#define y second
#define vl vector < long >
#define io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
vl a[100005];
long g[100005]={0};
void dfs(long node , long par)
{
    long i;
    for(i=0;i<a[node].size();++i)
    if(a[node][i]!=par)
    {
        dfs(a[node][i],node);
        g[node]^=(g[a[node][i]]+1);
    }
}
int main()
{
    io
    long n,x,y,i;
    cin>>n;
    n--;
    while(n--)
    {
        cin>>x>>y;
        a[x].pb(y);
        a[y].pb(x);
    }
    dfs(1,-1);
    if(g[1]==0) cout<<"Bob";
    else cout<<"Alice";
    return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> init(int size){
  vector<int> par(size,-1);
  return par;
}

int root(int x, vector<int>& par){
  if(par[x] < 0){
    return x;
  }else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x, int y, vector<int>& par){
  return root(x, par) == root(y, par);
}

void unite(int x, int y, vector<int>& par){
  x = root(x, par), y = root(y, par);
  if(same(x,y, par))return;
  par[x] += par[y];
  par[y] = x;
}

int size(int x, vector<int>& par){
  return -par[root(x, par)];
}

int pow(int x, int n){
  if(n == 0)return 1;
  if(n % 2 == 0)return pow(x * x % MOD, n/2);
  else return x * pow(x, n-1) % MOD;
}

vector< int > divisor(int n) {
  vector< int > ret(2);
  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret[0] = i;
      ret[1] = n / i;
    }
  }
  return (ret);
}

signed main(){
  int s;cin>>s;int x,y,xx,yy;int r = ceil(sqrt(s));
  cout << "0 0 " << r << " "<< 1 << " " << r*r-s << " "<< r << endl;
}


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;

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

const ll MOD = 1e9 + 7;

ll powmod(ll a, ll b){
	if(b == 0) return 1;
	if(b & 1) {
		return a * powmod(a, b - 1) % MOD;
	} else {
		ll d = powmod(a, b / 2) % MOD;
		return d * d % MOD;
	}
}


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

	ll n;
	cin >> n;

	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	ll s = 0;
	rep(i, n) {
		s += a[i];
		s %= MOD;
	}

	ll ss = 0;
	rep(i, n) {
		ss += a[i] * a[i] % MOD;
		ss %= MOD;
	}

	ll ans = s * s % MOD + (MOD - ss) % MOD;
	ans %= MOD;
	ans *= powmod(2ll, MOD - 2);
	ans %= MOD;

	cout << ans << endl;
}


Measured memory_bytes: 4780
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
// 293206GT
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <stack>
#include <string>
#include<algorithm>
#include <random>
#include <bitset>
#include <chrono>

typedef long long ll;
#define int ll
using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) (x) * (x)
typedef pair<int, int> pii;
typedef long double ld;
typedef pair<ld, ld> pld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<pii> vpii;
#define rep(x, y, a) for (int x = (y); x < (int)(a); ++x)
#define all(a) a.begin(), a.end()
#define chkmax(a, b) a = max(a, (b))
#define chkmin(a, b) a = min(a, (b))
#define prev asasdasd
#define next aasdasda
#define left asdasdasdasd
#define right asnabsdkasdl
#define rank asdasdknlasd
#define move asdasdas

namespace IO {

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a);

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a);

    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a) {
        for (pair<A, B> x: a)
            out << x.first << " " << x.second << '\n';
        return out;
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a) {
        for (A x: a) out << x << ' ';
        return out;
    }

    template<class A, class B>
    istream &operator>>(istream &in, pair<A, B> &a) {
        in >> a.first >> a.second;
        return in;
    }

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x: a) in >> x;
        return in;
    }
}
using namespace IO;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve() {
    int n;
    cin >> n;
    put(n^1);
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(30);
//    freopen("input.txt", "r", stdin);
    int q = 1;
//    cin >> q;

    while (q--) solve();
}


Measured memory_bytes: 3172
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int A, B;
    cin >> A >> B;
    if (A <= 8 && B <= 8) cout << "Yay!" << endl;
    else cout << ":(" << endl;
    return 0;
}

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

int main()
{
  string s;
  cin >> s;
  
  if(s[0]=='R' && s[1]=='R' && s[2]=='R' )
  {
    cout << 3;
    return 0;
  }else if(s[0]=='S' && s[1]=='S' && s[2]=='S' )
  {
    cout << 0;
    return 0;
  }else if(s[0]=='S' && s[1]=='R' && s[2]=='R' )
  {
    cout << 2;
    return 0;
  }else if(s[0]=='R' && s[1]=='R' && s[2]=='S' )
  {
    cout << 2;
    return 0;
  }else{
    cout << 1;
    return 0;
  }

}

Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  int sz = log2(*max_element(a.begin(), a.end())+*max_element(b.begin(), b.end()));
  int ans = 0;
  rep(i, sz+1) {
    int mod = pow(2, i+1);
    auto v = b;
    rep(j, n) v[j] %= mod;
    sort(v.begin(), v.end());
    int cnt = 0;
    rep(j, n) {
      int A = a[j]%mod, T = mod/2;
      cnt += distance(lower_bound(v.begin(), v.end(), T-A), lower_bound(v.begin(), v.end(), T*2-A));
      cnt += distance(lower_bound(v.begin(), v.end(), T*3-A), lower_bound(v.begin(), v.end(), T*4-A));
    }
    if (cnt%2)
      ans |= 1<<i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;
public class Main{
 public static void main(String[] args) {
  Scanner kbd = new Scanner(System.in);
   int k=kbd.nextInt();
   int[] su = new int[32];
   su[0]=su[1]=su[2]=su[4]=su[6]=su[10]=su[12]=su[14]=su[16]=su[18]=su[22]=su[28]=su[30]=1;
   su[3]=su[5]=su[8]=su[9]=su[13]=su[20]=su[21]=su[24]=su[25]=2;
   su[27]=su[29]=4;
   su[7]=su[11]=su[17]=su[19]=su[26]=5;
   su[15]=14;
   su[23]=15;
   su[31]=51;
  System.out.println(su[k-1]);
}
}


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

int n, g, ans=0;
vector<int> a(500000);
vector<int> l(500000);
vector<int> r(500000);


int gcd(int a, int b) {
    if (a < b) return gcd(b, a);
    while(b!=0){
        int r = a%b;
        a = b;
        b = r;
    }
    return a; 
}


int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a.at(i);

    l.at(0) = 0; 
    for (int i = 1; i <= n; ++i)
    {
        l.at(i) = gcd(l.at(i-1), a.at(i-1));
    }

    r.at(n) = 0; 
    for (int i = n-1; i >= 0; --i)
    {
        r.at(i) = gcd(r.at(i+1), a.at(i));
    }

    for (int i = 0; i < n; ++i)
    {
        ans = max(gcd(l.at(i), r.at(i+1)), ans);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
int main(){
	ll k, a, b;
	cin >> k >> a >> b;
	if(b - a <= 2){
		cout << k + 1;
		return 0;
	}
	else if(a - 1 >= k){
		cout << k + 1 << endl;
	}else{
		ll rest = k - (a - 1);
		ll ans = a;
		ans += (rest / 2) * (b - a);
		if(rest % 2 == 1)ans++;
		cout << ans;
	}
	
    return 0;
}


Measured memory_bytes: 3588
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		char[] s = br.readLine().toCharArray();
		int q = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		int[] k = new int[q];
		for (int i = 0; i < q; i++) {
			k[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < q; i++) {
			long d = 0;
			long m = 0;
			long dm = 0;
			long ans = 0;
			for (int j = 0; j < n; j++) {
				if (j >= k[i]) {
					if (s[j - k[i]] == 'D') {
						d--;
						dm -= m;
					} else if (s[j - k[i]] == 'M') {
						m--;
					}
				}
				if (s[j] == 'D') {
					d++;
				} else if (s[j] == 'M') {
					m++;
					dm += d;
				} else if (s[j] == 'C') {
					ans += dm;
				}
			}
			pw.println(ans);
		}
		pw.flush();
	}
}


Measured memory_bytes: 34140