akhauriyash/Code-Regression huggingface dataset:
N=int(input())

factors = {num: 0 for num in range(2, N+1)}

def factorization(n, factors):
    arr = []
    temp = n
    for i in range(2, int(n**0.5)+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
            factors[i] += cnt

    if temp!=1:
        arr.append([temp, 1])
        factors[temp] += 1

    if arr==[]:
        arr.append([n, 1])
        factors[n] += 1

    return factors

for num in range(2, N+1):
    factors = factorization(num, factors)
    
ans = 1
MOD = 10**9+7
for num in range(2, N+1):
    ans *= (factors[num] + 1) % MOD
    ans %= MOD
print(ans % MOD)

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

int main() {
    int n, m, h, w; cin >> n >> m >> h >> w;

    if(n % h == 0 and m % w == 0) {
        cout << "No\n";
        return 0;
    }   

    cout << "Yes\n";

    vector<vector<int>> a(505, vector<int> (505, 0));
    
    bool flipped = false;

    auto flip = [&] () {
        flipped = true;
        vector<vector<int>> b = a;
        for(int i = 0; i < n; ++i)
            for(int j = 0; j < m; ++j)
                b[j][i] = a[i][j];
        a = b;
        swap(n, m);
        swap(h, w);
    };
    
    if(m % w == 0) {
        flip();
    }

    long long sum = 0;
    int cnt = 0;

    for(int i = 0; i < h; ++i)
        for(int j = 0; j < w; ++j)
            if(j >= m % w) {
                a[i][j] = -1e6;
                sum += 1e6;
            } else {
                cnt += 1;
            }

    long long mult = sum;
    mult -= mult % cnt;

    if(mult == sum) {
        mult -= cnt;
    }

    long long amount = mult / cnt;

    for(int i = 0; i < h; ++i)
        for(int j = 0; j < w; ++j) {
            if(j < m % w) {
                a[i][j] = amount;
            }
        }

    for(int i = 0; i < n; ++i)
        for(int j = 0; j < m; ++j)
            a[i][j] = a[i % h][j % w];
    
    if(flipped) {
        flip();
    }

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < m; ++j)
            cout << a[i][j] << " ";
        cout << "\n";
    }
}

Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    ll h, n; cin >> h >> n;

    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    ll total = accumulate(a, a+n, 0LL);

    if(total < h){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }

    return 0;
}

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

int main(void) {
	int N, K;
	scanf("%d %d", &N, &K);
	int ans = 1;
	for (int i = 0; i < N; i++) {
		if (ans < K) ans *= 2;
		else ans += K;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3788
function main()
	a,b,c,d = split(chomp(readline()),"")
	a=parse(a)
	b=parse(b)
	c=parse(c)
	d=parse(d)
	if a+b+c+d == 7
		print(a, "+", b,"+", c,"+",d)
	elseif a+b+c-d == 7
		print(a, "+", b,"+", c,"-",d)
	elseif a+b-c+d == 7
		print(a, "+", b,"-", c,"+",d)
	elseif a+b-c-d == 7
		print(a, "+", b,"-", c,"-",d)
	elseif a-b+c+d == 7
		print(a, "-", b,"+", c,"+",d)
	elseif a-b+c-d == 7
		print(a, "-", b,"+", c,"-",d)
	elseif a-b-c+d == 7
		print(a, "-", b,"-", c,"+",d)
	else
		print(a, "-", b,"-", c,"-",d)
	end
	print("=7")
end

main()

Measured memory_bytes: 167160
n=int(input());A=[int(input()) for _ in range(n)];A.sort()
if n%2==1:print(max(2*sum(A[n-n//2:])-sum(A[n-n//2-2:n-n//2])-2*sum(A[:n-n//2-2]),-2*sum(A[:n//2])+sum(A[n//2:n//2+2])+2*sum(A[n//2+2:])))
else:print(-2*sum(A[:(n-2)//2])-A[(n-2)//2]+A[(n-2)//2+1]+2*sum(A[(n-2)//2+2:]))

Measured memory_bytes: 7508
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
bool a[10];
int b[10], d = 0;
vector<int>e[10];
int solve(int i,int s) {
	if (s == d) return 1;
	int sum = 0;
	for (int j = 0; j < e[i].size(); j++) {
		if (a[e[i][j]]) {
			a[e[i][j]] = false;
			sum += solve(e[i][j], s | b[e[i][j]]);
			a[e[i][j]] = true;
		}
	}
	return sum;
}
int main() {
	int n, m, p = 1;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		a[i] = true;
		b[i] = p;
		d += p;
		p *= 2;
	}
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	a[0] = false;
	cout << solve(0, b[0]) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static int Int(char a){
		int i=0;
		if(a=='+') {
		i=1;
		}
		else {
			i=-1;
		}
		return i;
	}
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String a=scan.next();
		int ans=0;
		ans+=Int(a.charAt(0));
		ans+=Int(a.charAt(1));
		ans+=Int(a.charAt(2));
		ans+=Int(a.charAt(3));
		System.out.println(ans);
	}
}

Measured memory_bytes: 23892
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String str = sc.nextLine();
    boolean N = false;
    boolean S = false;
    boolean E = false;
    boolean W = false;
    
    for(int i = 0; i < str.length(); i++){
      if(str.charAt(i) == 'N'){
        N = true;
      }else if(str.charAt(i) == 'S'){
        S = true;
      }else if(str.charAt(i) == 'E'){
        E = true;
      }else if(str.charAt(i) == 'W'){
        W = true;
      }
    }
    
    if(((N && S) || (!N && !S)) && ((E && W) || (!E && !W))){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21840
import java.util.Scanner;

public class Main {

	static void input(long[][] array,int y,int x,Scanner scan){
		for(int i=0;i<y;i++){
			for(int j=0;j<x;j++){
				array[i][j]=scan.nextInt();
			}
		}
	}
	
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int m=scan.nextInt();
		int l=scan.nextInt();
		long[][] A=new long[n][m];
		long[][] B=new long[m][l];
		long sum;
		input(A,n,m,scan);
		input(B,m,l,scan);
		for(int i=0;i<n;i++){
			for(int j=0;j<l;j++){
				
				sum=0;
				for(int k=0;k<m;k++){
					sum+=A[i][k]*B[k][j];
				}
				if(j==0){
					System.out.print(sum);
				}else{
					System.out.print(" "+sum);
				}
			}
			System.out.println();
		}
		scan.close();
	}

}

Measured memory_bytes: 45368
'''
https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_e
'''
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    cnt = [3] + [0]*n
    res = 1

    for i in a:
        res *= cnt[i] % mod
        cnt[i] -= 1
        cnt[i+1] += 1
        res %= mod

    print(res)
        
if __name__ == '__main__':
    main()

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

#define ll long long
#define mod 998244353
#define pll pair<long long,long long>
#define plll pair<pll,pll>
#define pdd pair<long double,long double>
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
priority_queue<ll,vector<ll>,greater<ll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;

ll result(ll a, ll b, ll p){
    ll ans=1;
    if(b==(-1))
        b=p-2;
    while(b){
        if(b&1){
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,c,l,r,s,q;
    ll n,t,k;
    cin>>n;
    vector<ll>arr(n),brr(n),dp(n);
    map<ll,ll>m;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        brr[arr[i]]++;
    }
    ll d=brr[0];
    if(d>1 || arr[0]){
        cout<<0;
        return 0;
    }
    k=1;
    ll ans=1;
    rep(i,n){
        if(i){
            if(brr[i]){
                ans=(ans*result(d,brr[i],mod))%mod;
                d=brr[i];
                k+=brr[i];
            }
            else{
                break;
            }
            //cout<<d<<" ";
        }
    }
    if(k==n){
        cout<<ans;
    }
    else{
        cout<<0;
    }
    return 0;
}


Measured memory_bytes: 2560
/* Bismillahirrahmanirrahim */
#include<bits/stdc++.h>
#define forA for(int i=0; i<a; i++)
using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	for(int i=1; i<=c; i++){
		if(i%2==1){
			if(a%2==1) a--;
			b+=a/2;
			a/=2;
		}
		else{
			if(b%2==1) b--;
			a+=b/2;
			b/=2;
		}
	}
	cout << a << " " << b;
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;
struct Node {
	int key;
	Node *right, *left, *parent;
};
Node *root, *NIL;
void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	//cout << "x: " << x << endl << "y: " << y << endl << "root: " << root << endl << "NIL: " << NIL << endl;
	while (x != NIL) {
		y = x;
		if (z->key < x->key)x = x->left;
		else x = x->right;
	}
	z->parent = y;
	if (y == NIL)root = z;
	else {
		if (z->key < y->key)y->left = z;
		else y->right = z;
	}
}
void inorder(Node *u) {
	if (u == NIL)return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if (u == NIL)return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}
int main() {
	int n, i, x;
	string com;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> com;
		if (com == "insert") {
			cin >> x;
			insert(x);
		}
		else if (com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 26768
//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <bits/stdc++.h>
 
#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}
 
using namespace std;                                                                                  

mt19937 mrand(random_device{}()); 
const ll mod = 1e9 + 7;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
 
typedef pair < int , int > pii ;                                            
typedef pair < long long  , long long > pll ;
const int N = 5e5 + 123;

int n, m, k;
int a[N] , b[N];
int pr1[N] , pr2[N];
string s,t;

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

	cin >> s;  	
	cin >> t;
	n = sz(s);
	m = sz(t);
	s = '$' + s;
	t = '$' + t;
	for(int i = 1; i <= n; i++)
		pr1[i] = pr1[i - 1] + (s[i] == 'A');
	for(int i = 1; i <= m; i++)
		pr2[i] = pr2[i - 1] + (t[i] == 'A');
	int q;	
	cin >> q;
	while(q--){
		int l , r;
		int tot1 = 0,tot2 = 0;
		cin >> l >> r;
		tot1 = (r - l + 1) * 2 - pr1[r] + pr1[l - 1];
		tot1 %= 3;
		cin >> l >> r;
		tot2 = (r - l + 1) * 2 - pr2[r] + pr2[l - 1];
		tot2 %= 3;
		if(tot1 == tot2)
			cout << "YES\n";
		else cout << "NO\n";

	}	

	



}
 


Measured memory_bytes: 5868
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cout << fixed << setprecision(10);
  int a,b;
  cin >> a >> b;
  cout << a*b << endl;
}


Measured memory_bytes: 3596
#include<stdio.h>
int main(){
    long long h,w;
    scanf("%lld %lld",&h,&w);
    if(h==1||w==1){
        printf("%d\n",1);
    }else{
        if((h*w)%2==0){
            printf("%lld\n",h*w/2);
        }else{
            printf("%lld\n",(h*w+1)/2);
        }
    }
    
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string S,T;
  cin>>N>>S>>T;
  int count=0;
  for(int i=0;i<N;i++){
    bool flag=true;
    for(int j=i;j<N;j++){
      if(S.at(j)!=T.at(j-i)){
        flag=false;
      }
    }
    if(flag){
      count=i;
      break;
    }
    if(i==N-1){
      count=N;
    }
  }
  cout<<N+count<<endl;
}
    


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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int h = fs.nextInt(), n = fs.nextInt();
		int mag[][] = new int[n][2];
		for(int i=0;i<n;i++) {
			mag[i][0] = fs.nextInt();
			mag[i][1] = fs.nextInt();
		}
		
		int dp[] = new int[h+10]; //hを倒すときの最小魔力
		Arrays.fill(dp, Integer.MAX_VALUE/2);
		dp[0] = 0;
		for(int i=1;i<=h;i++) {
			for(int j=0;j<n;j++) {
				int a = mag[j][0], b = mag[j][1];
				if(a>=i) {
					dp[i] = Math.min(dp[i], b);
				}else {
					dp[i] = Math.min(dp[i], dp[i-a] + b);
				}
			}
		}
		System.out.println(dp[h]);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 24916
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define M 5005
int main() {
	char S[10];
	bool flag=1;
	scanf("%s",S);
	for(int i=1; i<4&&flag; i++)flag=S[i]!=S[i-1];
	puts(flag?"Good":"Bad");
}

Measured memory_bytes: 256
class Seg
  def initialize ( n, init, &func)
    @tree = Array.new( 2**n - 1, init )
    @init = init
    @n    = 2**(n-1)
    @func = func || lambda{|x,y| x < y}
  end

  def update (i, x)
    i = @n - 1 + i
    @tree[i] = x

    while (i=parent(i))>=0
      a,b = kids(i).map{|x| @tree[x]}
      @tree[i] = @func.call(a, b) ? a : b
    end

  end

  def find ( s, t, k=0, i=0, j=@n-1)
    return @init if t<i || j<s
    return @tree[k] if s<=i && j<=t

    a, b = kids(k)
    a, b = find(s, t, a, i, (i+j)/2), find(s, t, b, (i+j)/2+1, j)
    @func.call(a, b) ? a : b
  end

  private
  def parent(i)
    (i-1)/2
  end

  def kids(i)
    [2*i+1, 2*i+2]
  end
end

n, q = gets.split.map(&:to_i)
i = 1
while 2**i-1 < n
  i += 1
end

seg  = Seg.new(i+5, 2**31-1) { |x,y| x < y }
q.times do
  com, x, y = gets.split.map(&:to_i)

  case com
  when 0
    seg.update(x, y)
  when 1
    puts seg.find(x,y)
  end
end

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

const int MOD = 1000000007;
const int INF = 1e9;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n, i##_len=(n); i>=0; i--)
#define FOR(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)

//最大公約数 
 ll gcd(ll a,ll b){
 if(b == 0) return a;
 return gcd(b,a%b);
 }

//最小公倍数
 ll lcm(ll a,ll b){
 ll g = gcd(a,b);
 return a / g * b; // Be careful not to overflow  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
} 




int main(){
int A, B;
cin >> A >> B;
int sum = A;
int cnt = 1;
if(B == 1){
  print(0);
  return 0;
}
while(sum < B){
sum += A - 1;
cnt++;
}

print(cnt);
}



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

using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a;
    cin>>a;
    string b;
    cin>>b;
    for(int i=0;i<b.size();++i)
    {
        if(b[i]=='.')
        {
            b.erase(b.begin()+i);
            break;
        }
    }
    int b1=stoi(b);
    cout<<(a*b1)/100;
    return 0;
}


Measured memory_bytes: 3656
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
/**
 * ??¶?´??????¶???????????????
 * @author B7078
 *
 */
class Exception{
	public static int ex(ArrayList<Integer> parse){
		int result = 1;
		if(parse.get(0)<1 || parse.get(0) > 4){
			result = 0;
		}
		else if(parse.get(1)<1 || parse.get(1) > 3){
			result = 0;
		}
		else if(parse.get(2)<1 || parse.get(2) > 10){
			result = 0;
		}
		else if(parse.get(3)<-9 || parse.get(3) > 9){
			result = 0;
		}
		return result;
	}
}
/**
 * ???????????????
 * @author B7078
 *
 */

public class Main {

	public static void main(String[] args) throws IOException{
		Exception ex1 = new Exception();
		int b, f, r, v; // b?£?,f???,r???????????¨?±?,v?????????
		int temp;
		int n;
		int count = 0;
		String str;
		ArrayList<String> st = new ArrayList<String>(); // ??\?????????????????????b,f,r,v
		ArrayList<Integer> parse = new ArrayList<Integer>(); // int??????
		int house[][][] = new int[4][3][10];
		/**
		 * ???????????\???
		 */
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt(); // ?????±??¶??°n?????\???

		for (int a = 0; a < n; ++a) { //??\?????¶??°????????????
			for (int t = 0; t < 4; t++) { // ??\??????????????????????????????????????????????´?
				st.add(scan.next());
			}

			for (int p = count; p < st.size(); ++p) {
				str = st.get(p);
				temp = Integer.parseInt(str);
				parse.add(temp);
				//System.out.println("parse["+p+"] = "+parse.get(p));
			}
			if(ex1.ex(parse) == 0){
				System.exit(0);
			}
			end:
			for (b = 1; b < 5; ++b) { // 4?£?
					for (f = 1; f < 4; ++f) { // 3????±?
							for (r = 1; r < 11; ++r) { // 1~10???????????¨?±?
								if(parse.get(count).equals(b) && parse.get(count+1).equals(f) && parse.get(count+2).equals(r)){
								house[b-1][f-1][r-1] += parse.get(count+3);
								}
								/*if(house[b-1][f-1][r-1] < 0 || house[b-1][f-1][r-1] > 9){ //?????¨?±?????????°??¶???
									System.out.println(" "+b+"?£?"+f+"???"+r+"???????????¨?±?????????°????????£??§??????????????????.");
									break end;
								}*/
								//System.out.print(" "+house[b-1][f-1][r-1]);
							}
							//System.out.println("");
						}
					//if(b<4)System.out.println("####################");
			}
			count += 4;
			}
		for(b = 1;b<5;++b){
			for(f = 1;f<4;++f){
				for(r = 1;r<11;++r){
					System.out.print(" "+house[b-1][f-1][r-1]);
				}
				System.out.println("");
			}
			if(b<4)System.out.println("####################");
		}
		}
		}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int now = 1;
    int cnt = 0;
    while (now < b) {
        cnt++;
        now += a - 1;
    }
    print(cnt);

    return 0;
}


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

int main(){
    vector<string> c(3);
    rep(i,3) cin >> c.at(i);

    cout << c.at(0).at(0) << c.at(1).at(1) << c.at(2).at(2)<< endl;
} 

Measured memory_bytes: 256
import copy
import sys
import math

def main():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    B = [0] * n

    for i in range(min(k, 41)):
        for j in range(n):
            l = max(0, j-A[j]) #座標iの電球が照らす範囲の左端
            r = min(n-1, j+A[j]) #座標iの電球が照らす範囲の右端
            B[l] += 1
            if (r+1 < n):
                B[r+1] -= 1 # 後ほど累積和にしたときに、照らす範囲の右端より外には影響が及ばないようにあらかじめ1引いておく

        for j in range(n-1):
            B[j+1] += B[j]

        A = copy.deepcopy(B)
        B = [0] * n

    print(*A)

if __name__ == '__main__':
    main()

Measured memory_bytes: 179448
import java.util.*;
import java.io.*;
import java.lang.*;
class Main{
  public static void main(String args[]){
    int id, l, r,root=0;
    StringBuilder build = new StringBuilder();
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Node node[] = new Node[n];

    for(int i = 0; i<n; i++){
      node[i] = new Node();
    }

    for(int i = 0; i<n; i++){
      id = sc.nextInt();
      l = sc.nextInt();
      r =  sc.nextInt();
      node[id].left = l;
      node[id].right = r;
      if(l != -1)node[l].parent = id;
      if(r != -1)node[r].parent = id;
    }

    for(int i = 0;i<n; i++){
      if(node[i].parent==-1)root = i;
    }
    setDepth(root,0,node);

    for(int i = 0 ; i < n; i++){
      build.append("node ").append(i).append(": parent = ").append(node[i].parent).append(", sibling = ").append(getSibling(i,node)).append(", degree = ").append(getDegree(i,node)).append(", depth = ").append(node[i].depth).append(", height = ").append(getHeight(i, node));
      if(node[i].parent==-1)build.append(", root\n");
      else if(node[i].right == -1 && node[i].left == -1)build.append(", leaf\n");
      else build.append(", internal node\n");
    }

    System.out.print(build);

  }

  static int getHeight(int u, Node node[]){
    int h1 = 0;
    int h2 = 0;
    if(node[u].right != -1)h1 = getHeight(node[u].right, node) +1;
    if(node[u].left != -1)h2 = getHeight(node[u].left, node) +1;

    return Math.max(h1,h2);
  }

  static void setDepth(int u,int d,Node node_d[]){
    if( u == -1)return;
    node_d[u].depth = d;
    setDepth(node_d[u].right,node_d[u].depth+1, node_d);
    setDepth(node_d[u].left, node_d[u].depth+1, node_d);
  }

  static int getSibling(int u, Node node[]){
    if(node[u].parent == -1)return (-1);
    if(node[node[u].parent].left != u && node[node[u].parent].left!=-1)return node[node[u].parent].left;
    if(node[node[u].parent].right != u && node[node[u].parent].right!=-1)return node[node[u].parent].right;
    return (-1);
  }

  static int getDegree(int u, Node node[]){
    int count=0;
    if(node[u].left != -1)count++;
    if(node[u].right != -1)count++;
    return count;
  }
}

class Node{
  int parent = -1;
  int left = -1;
  int right = -1;
  int depth = 0;
}


Measured memory_bytes: 26400
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 1000010

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll x,y;
  cin>>x>>y;

  make_fact(FACSIZE-2);
  make_invfact(FACSIZE-2);

  if( (x+y)%3LL != 0 ){
    cout << 0 << endl;
  }
  else{
    ll n=(x+y)/3LL;
    ll d=(x-y+n)/2LL;
    if( d<0 || d>n ){
      cout << 0 << endl;
    }
    else{
      ll ans= mod_mul( fac[n] , mod_mul( invfac[d] , invfac[n-d] ) );
      cout << ans << endl;
    }
  }

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

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

int main() {
    int n;
    std::cin >> n;
    long long pa, pb;
    std::cin >> pa >> pb;
    for (int i = 1; i < n; i++) {
        long long a, b;
        std::cin >> a >> b;
        if (pa > a || pb > b) {
            auto m = std::max(pa / a + (pa % a > 0), pb / b + (pb % b > 0));
            a *= m;
            b *= m;
        }
        pa = a;
        pb = b;
        // std::cout << pa << " " << pb << std::endl;
    }
    std::cout << pa + pb << std::endl;

    return 0;
}

Measured memory_bytes: 256
import sys
from itertools import accumulate

input = sys.stdin.readline

N = int(input())


def prime_boolean_table(n):
    primes = [True] * (n + 1)
    primes[0] = False
    primes[1] = False
    for i in range(2, n + 1):
        if primes[i]:
            for j in range(i + i, n + 1, i):
                primes[j] = False

    return primes


primes = prime_boolean_table(10**5)
A = [0] * 10**5
for i in range(1, 10**5):
    A[i] += A[i - 1]
    if primes[i] and primes[(i + 1) // 2]:
        A[i] += 1

for _ in range(N):
    l, r = map(int, input().split())
    print(A[r] - A[l - 1])


Measured memory_bytes: 7684
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll n,a,b,c,d;
std::map<ll, ll> mp;

ll solve(ll x){
	if(mp.count(x)){
		return mp[x];
	}
	if(!x){
		return mp[x] = 0ll;
	}
	mp[x] = INFLL;
	if(INFLL/d>=x){
		mp[x] = x*d;
	}
	mp[x] = std::min(mp[x],solve(x/2)+a+d*(x%2));
	if(x%2){
		mp[x] = std::min(mp[x],solve(x/2+1)+a+d*(2-x%2));
	}
	mp[x] = std::min(mp[x],solve(x/3)+b+d*(x%3));
	if(x%3){
		mp[x] = std::min(mp[x],solve(x/3+1)+b+d*(3-x%3));
	}
	mp[x] = std::min(mp[x],solve(x/5)+c+d*(x%5));
	if(x%5){
		mp[x] = std::min(mp[x],solve(x/5+1)+c+d*(5-x%5));
	}
	// printf("%lld %lld\n",x,mp[x]);
	return mp[x];
}

int main(void){
	int t,i,j,k;
	std::cin >> t;
	while(t--){
		std::cin >> n >> a >> b >> c >> d;
		std::cout << solve(n) << std::endl;
		mp.clear();
	}
	return 0;
}


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

int main(void){
    int a, b;
    cin >> a >> b;
    int komi1 = a*100*0.125;
    if(komi1*0.08 != a){komi1 += 1;}
    int mini = 1000000;
    if(komi1 / 10 == b){
        mini = min(mini, komi1);
    }
    
    int komi2 = b/0.1;
    if(komi2 * 8 /100 == a){
        mini = min(mini, komi2);
    }
    
    if(mini == 1000000){cout << -1 << endl; return 0;}
    cout << mini << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <string>
#include <iomanip>

int main()
{
  int N, K;
  std::vector<double> ps;
  std::cin >> N >> K;
  for (int i=0; i<N; ++i)
    {
      int tmp;
      std::cin >>tmp;
      ps.push_back(tmp);
    }

  long double cur_sum = 0;
  for (int i=0; i<K; i++)
    {
      cur_sum += (ps[i] + 1.0)/2.0;
    }
  //std::cout << cur_sum << std::endl;
  long double prev_sum = cur_sum;
  long double max = cur_sum;
  for (int i=K; i<N; ++i)
    {
      cur_sum = prev_sum + (ps[i]+1.0)/2.0 - (ps[i-K]+1.0)/2.0;
      //std::cout << cur_sum << std::endl;
      if (cur_sum > max) max = cur_sum;
      prev_sum = cur_sum;
    }
  std::cout << std::setprecision(10);
  std::cout << max << std::endl;
 }


Measured memory_bytes: 2420
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <vector>

using namespace std;
long long y[1000];
int main() {
  long long x;
  cin>>x;
  for(long long i=0;i<800;i++){
      y[i]=i*i*i*i*i;
  }
  for(int i=0;i<140;i++){
      for(int j=0;j<140;j++){
          if(y[i]-y[j]==x){
              cout<<i<<" "<<j<<endl;
              return 0;
          }
          if(y[i]+y[j]==x){
              cout<<i<<" "<<-j<<endl;
              return 0;
          }
      }
  }
  return 0;
}


Measured memory_bytes: 3600
from bisect import bisect_left, bisect_right
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
# print(a)

a_cs = [0] * (n + 1)
for i in range(n):
    a_cs[i + 1] = a_cs[i] + a[n - 1 - i]


def check(x):
    # M回の握手の幸福度の最小値をx以上にできるか
    # つまり、M回の任意の握手の幸福度をx以上にできるか
    cnt = 0
    for ai in a:
        idx = bisect_left(a, x - ai)
        cnt += n - idx
    return cnt >= m


lb = 1  # True
ub = 2 * 10**5 + 5  # False
while ub - lb > 1:
    mid = (ub + lb) // 2
    if check(mid):
        lb = mid
    else:
        ub = mid

# print(lb)

ans = 0
cnt = 0
for ai in a:
    idx = bisect_left(a, lb - ai)
    ans += ai * (n - idx) + a_cs[n - idx]
    cnt += n - idx
ans -= lb * (cnt - m)
print(ans)


Measured memory_bytes: 55268
N = int(input())
*H, = map(int, input().split())

dp = {i: 0 for i in range(N+1)}
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2]))
print(dp[N-1])

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int a, b;
    cin >> a >> b;
    if(a < 10 && b < 10)
        cout << a * b;
    else cout << -1;
    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int x = ni();
		int n = ni();

		HashSet<Integer> p = new HashSet<>();

		for (int i = 0; i < n; i++) {
			p.add(ni());
		}

		for (int i = 0; i < 100; i++) {
			if (!p.contains(x - i)) {
				out(x - i);
				break;
			}
			if (!p.contains(x + i)) {
				out(x + i);
				break;
			}
		}
	}

	/*
	 * 以下メソッド集
	 */

	static int ketasuu(int n) {
		String str = "" + n;
		return str.length();
	}

	static int abcount(String str) {
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if ("AB".equals(str.substring(i, i + "AB".length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

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

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static double min(double d, double e) {
		return Math.min(d, e);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 35908
import numpy as np
n,m = map(int,input().split())
data = np.array([[int(i) for i in input().split()]for j in range(n)])
ans = []
for i in data:
  for j in i[1:]:
    ans.append(j)
ans = np.array(ans)
count = 0
for i in range(1,m+1):
  if (ans==i).sum() == n:
    count +=1
    
print(count)

Measured memory_bytes: 21564
#include <stdio.h>

#define MAX_N 1000000
#define MAX_M 100
#define min(a,b) a < b ? a : b

void shellSort(int*,int);
void insertionSort(int*,int,int);
void print(int*,int*,int,int);

int cnt;

int main(){
  int N,i,a[MAX_N];

  scanf("%d" ,&N);
  for(i = 0 ; i < N ; i++){
    scanf("%d" ,a+i);
  }
  shellSort(a,N);

  return 0;
}

void shellSort(int a[],int N){
  int G[MAX_M],p = 0,m,i;
  cnt = 0;

  for(m = 1 ; m*3+1 < N ; m = m*3+1){};
  for(; m > 0 ; m /= 3){
    G[p++] = m;
  }

  p = min(p,100);
  for(i = 0 ; i < p ; i++){
    insertionSort(a,N,G[i]);
  }
  print(a,G,N,p);
}

void insertionSort(int a[],int N,int g){
  int i,v,j;

  for(i = g ; i < N ; i++){
    v = a[i]; j = i - g;
    while(j >= 0 && a[j] > v){
      a[j+g] = a[j];
      j -= g;
      cnt++;
    }
    a[j+g] = v;
  }
}

void print(int a[],int G[],int N,int m){
  int i;
  
  printf("%d\n" ,m);
  for(i = 0 ; i < m ; i++){
    if(i != m-1){
      printf("%d " ,G[i]);
    }else{
      printf("%d\n" ,G[i]);
    }
  }
  printf("%d\n" ,cnt);
  for(i = 0 ; i < N ; i++){
    printf("%d\n" ,a[i]);
  }
}


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

int main(){
    int N;
    cin >> N;
    long long int d[N];
    int i,j;
    long long int sum =0;
    for(i=0;i<N;i++)cin >> d[i];
    for(i=0;i<N-1;i++){
        for(j=i+1;j<N;j++){
            sum += d[i]*d[j];
        }
    }
    cout << sum << 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;
typedef pair <double,double> P;

int main() {
  int n,m;
  cin>>n>>m;
  string a[55],b[55];
  rep(i,n) cin>>a[i];
  rep(i,m) cin>>b[i];
  rep(i,n) {
    rep(j,n) {
      if (i+m-1>n-1) continue;
      if (j+m-1>n-1) continue;
      bool flag=true;
      rep(k,m) {
	if (a[i+k].substr(j,m)!=b[k].substr(0,m))
	  flag=false;
      }
      if (flag) {
	puts("Yes");
	return 0;
      }
    }
  }
  puts("No");
  return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        string s = ReadLine();
        string t = ReadLine();

        int[,] dp = new int[s.Length + 1, t.Length + 1];
        for(int i = 1; i <= s.Length; i++)
        {
            for(int j = 1; j <= t.Length; j++)
            {
                if (s[i - 1] == t[j - 1])
                    dp[i, j] = dp[i - 1, j - 1] + 1;
                dp[i, j] = Max(dp[i, j], dp[i - 1, j]);
                dp[i, j] = Max(dp[i, j], dp[i, j - 1]);
                //Write(dp[i, j]);
            }
            //WriteLine();
        }
        int y = s.Length, x = t.Length;
        StringBuilder sb = new StringBuilder();
        sb.Append("");
        while(y != 0 && x != 0)
        {
            if (dp[y, x] == dp[y - 1, x])
            {
                y--;
            }
            else if(dp[y, x] == dp[y, x - 1])
            {
                x--;
            }
            else
            {
                sb.Insert(0, s[y - 1]);
                y--;
                x--;
            }
        }
        WriteLine(sb.ToString());
    }
}

Measured memory_bytes: 46944
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    }
    public void solve() throws Exception {
        FastScan scan = new FastScan(System.in);
        int H = scan.scanInt();
        int W = scan.scanInt();
        int D = scan.scanInt();
        HashMap<Integer, Point> map = new HashMap<>();
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                int A = scan.scanInt();
                map.put(A, new Point(i, j));
            }
        }
        int[] s = new int[H*W+1];
        for (int i = 1; i <= H * W - D; i++) {
            Point p1 = map.get(i);
            Point p2 = map.get(i+D);
            s[i+D] = s[i]
                    + Math.abs(p1.i-p2.i)
                    + Math.abs(p1.j-p2.j);
        }
        int Q = scan.scanInt();
        for (int i = 0; i < Q; i++) {
            int L = scan.scanInt();
            int R = scan.scanInt();
            System.out.println(s[R]-s[L]);
        }
    }
    static class Point {
        int i;
        int j;
        Point(int i, int j) {
            this.i = i;
            this.j = j;
        }
    }
    static class FastScan {
        BufferedReader br;
        StringTokenizer st;
        FastScan(InputStream is) {
            InputStreamReader isr = new InputStreamReader(is);
            this.br = new BufferedReader(isr);
        }
        String next() throws IOException {
            while (this.st == null || !this.st.hasMoreTokens()) {
                this.st = new StringTokenizer(br.readLine().trim());
            }
            return st.nextToken();
        }
        long scanLong() throws IOException {
            return Long.parseLong(this.next());
        }
        int scanInt() throws IOException {
            return Integer.parseInt(this.next());
        }
        double scanDouble() throws IOException {
            return Double.parseDouble(this.next());
        }
        char scanCharacter() throws IOException {
            return this.next().charAt(0);
        }
        String nextLine() throws IOException {
            return br.readLine().trim();
        }
    }
}


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


int main()
{
	string s;
	cin >> s;
	int n = s.size();
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		if (s[i] == 'o')++ans;
	}
	ans += 15 - n;
	if (ans >= 8)cout << "YES";
	else cout << "NO";



	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll hpow(ll x,ll y){
    ll ans=1;
    ll i=x;
    if(y==0)return 1;
    while(y>0){
        if(y%2==1){
            ans=(ans*i)%i_7;
        }
        i=(i*i)%i_7;
        y=y/2;
        
    }
    return ans;
}

ll memop[2000000];
ll mkai(ll i){
    if(i==0){
        return 1;
    }
    if(memop[i]!=0){
        return memop[i];
    }else{
        ll ans=(mkai(i-1)*hpow(i,i_7-2))%i_7;
        memop[i]=ans;
        return ans;
    }
}

ll memok[2000000];
ll kai(ll i){
    if(i==0){
        return 1;
    }
    if(memok[i]!=0){
        return memok[i];
    }else{
        ll ans=(kai(i-1)*i)%i_7;
        memok[i]=ans;
        return ans;
    }
}

ll comb(ll n,ll k){
    if(n<k)return 0;
    ll ans=(kai(n)*mkai(k))%i_7;
    ans=(ans*mkai(n-k))%i_7;
    return ans;
}

int main(){fastio
    ll n;cin>>n;
    ll b[2];
    ll a[n+1];rep(i,1,n)a[i]=-1;
    rep(i,0,n){
        ll k;cin>>k;
        if(a[k]==-1){
            a[k]=i;
        }else{
            b[0]=a[k];
            b[1]=i;
            break;
        }
    }
    ll A,B,C;
    A=b[0];
    B=b[1]-b[0]-1;
    C=n-b[1];
    rep(i,1,n+1){
        ll res=0;
        res=mod(res+comb(n+1,i));
        res=mod(res-comb(A+C,i-1));
        cout<<mod(res)<<endl;
    }

    return 0;
}





Measured memory_bytes: 9064
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
 
n,k = LI()
a = LI()

min_val = 20000000000
for i in range(1 << (n-1)):
    count = 0
    val = 0
    pre = a[0]
    for j in range(n-1):
        if(i & (1 << j)):
            count += 1
            if(pre >= a[j+1]):
                val += pre - a[j+1] + 1
                pre = pre + 1
        if(pre < a[j+1]):
            pre = a[j+1]

    if(count >= k-1):
        if(min_val > val):
            min_val = val

print(min_val)

Measured memory_bytes: 41840
use std::f64::consts::PI;

fn main() {
	let r = readLine::<f64>();
	println!("{:.6} {:.6}", r * r * PI, 2. * PI * r)
}

fn readLine<T: std::str::FromStr>() -> T {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    line.trim().parse().ok().unwrap()
}


Measured memory_bytes: 5060