akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String abcd = scanner.next();
		int num[] = new int[4];
		num[0] = abcd.charAt(0)-'0';
		num[1] = abcd.charAt(1)-'0';
		num[2] = abcd.charAt(2)-'0';
		num[3] = abcd.charAt(3)-'0';
		int ans = -1 ,type = -1;
		while(true){
			type++;
			switch (type) {
				case 0:
					ans = num[0] + num[1] + num[2] + num[3];
					if(ans==7){
						System.out.println(num[0] +"+"+ num[1] +"+"+ num[2] +"+"+ num[3]+"=7");
						return;
					}
					break;
				case 1:
					ans = num[0] + num[1] + num[2] - num[3];
					if(ans==7){
						System.out.println(num[0] +"+"+ num[1] +"+"+ num[2] +"-"+ num[3]+"=7");
						return;
					}
					break;
				case 2:
					ans = num[0] + num[1] - num[2] + num[3];
					if(ans==7){
						System.out.println(num[0] +"+"+ num[1] +"-"+ num[2] +"+"+ num[3]+"=7");
						return;
					}
					break;
				case 3:
					ans = num[0] + num[1] - num[2] - num[3];
					if(ans==7){
						System.out.println(num[0] +"+"+ num[1] +"-"+ num[2] +"-"+ num[3]+"=7");
						return;
					}
					break;
				case 4:
					ans = num[0] - num[1] + num[2] + num[3];
					if(ans==7){
						System.out.println(num[0] +"-"+ num[1] +"+"+ num[2] +"+"+ num[3]+"=7");
						return;
					}
					break;
				case 5:
					ans = num[0] - num[1] + num[2] - num[3];
					if(ans==7){
						System.out.println(num[0] +"-"+ num[1] +"+"+ num[2] +"-"+ num[3]+"=7");
						return;
					}
					break;
				case 6:
					ans = num[0] - num[1] - num[2] + num[3];
					if(ans==7){
						System.out.println(num[0] +"-"+ num[1] +"-"+ num[2] +"+"+ num[3]+"=7");
						return;
					}
					break;
				case 7:
					ans = num[0] - num[1] - num[2] - num[3];
					if(ans==7){
						System.out.println(num[0] +"-"+ num[1] +"-"+ num[2] +"-"+ num[3]+"=7");
						return;
					}
					break;
			}
		}
	}
}

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    char c;
    cin >> c;

    if(c=='A')
        cout << "T" << endl;
    else if(c=='T')
        cout << "A" << endl;
    else if(c=='G')
        cout << "C" << endl;
    else if(c=='C')
        cout << "G" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <complex>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
	ll W,H;
	cin >> W >> H;
	vector<P> cost(W+H);
	for(int i=0;i<W;i++){
		ll p;
		cin >> p;
		cost[i]=P(p,0);
	}
	for(int i=W;i<H+W;i++){
		ll q;
		cin >> q;
		cost[i]=P(q,1);
	}
	sort(cost.begin(),cost.end());
	ll ans=0;
	ll w=W+1;
	ll h=H+1;
	for(int i=0;i<cost.size();i++){
		ll c,f;
		tie(c,f)=cost[i];
		if(f){
			ans+=w*c;
			h=max(h-1,(ll)0);
		}else{
			ans+=h*c;
			w=max(w-1,(ll)0);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		boolean fl;
		int mark = 0;
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}
			int[] square = new int[n];
			square[0] = n;
			System.out.println(n);
			while(true){
				fl = true;
				for(int i = n-1;i >= 0;i--){
					if(square[i] > 1){
						fl = false;
						square = init2(square,n,i);
						print(square,n);
						break;
					}
				}
				if(fl){
					break;
				}
			}
		}
	}
	public static void print(int[] square,int n){
		System.out.print(square[0]);
		for(int i = 1;i < n;i++){
			if(square[i] != 0){
				System.out.print(" " + square[i]);
			}else{
				break;
			}
		}
		System.out.println();
	}
	public static int[] init2(int[] square,int n,int mark){
		square[mark] -= 1;
		for(int i = mark+1;i < n;i++){
			square[i] = 0;
		}
		int t = n;
		for(int i = 0;i <= mark;i++){
			t -= square[i];
		}
		int i = mark+1;
		while(t > 0){
			square[i] = (t > square[mark]) ? square[mark] : t;
			t -= square[mark];
			i += 1;
		}
		return square;
	}
}

Measured memory_bytes: 38384
#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>;

int main() {
  int a, b;
  cin >> a >> b;
  if (a < 1 || 9 < a || b < 1 || 9 < b) {
    cout << -1 << endl;
    return 0;
  }
  cout << a * b << endl;
  return 0;
}

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

typedef long long int ll;


int main()
{
	ll i,j,k,l,m,n,u,v;

	string ans;

	cin >> n;

	


	while(n>0)
	{
		n = n-1;
		ans += (n%26)+'a';
		n = n/26;
	}

	reverse(ans.begin(),ans.end());

	cout << ans << '\n';
	
	


}

Measured memory_bytes: 3604
from sys import stdin

N = int(input())
# print(N)

bcs = [list(x.split()) for x in stdin.readlines()]

for i in range(N):
	bcs[i][1] = int(bcs[i][1])
	bcs[i].append(int(i+1))
	# print(bcs[i])

bcs.sort(key=lambda x:x[1], reverse=True)
bcs.sort(key=lambda x: x[0])

# print(bcs)
for i in range(N):
	print(bcs[i][2])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi >
#define vvvi vector<vvi >
#define INF 1e9
#define MOD 1e9+7
typedef long long llong;
using namespace std;

int main(){
	int n,k;
	cin>>n>>k;
	
	int res=n-k+1;
	
	
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
int main(){
	int N;
	cin>>N;
	int V=0;
	int E=0;
	vector<int> h(N);
	for(int i=0;i<N;i++){
		cin>>h[i];
		V+=h[i];
	}
	for(int i=1;i<N;i++){
		E+=min(h[i-1],h[i]);
	}
	cout<<V-E<<endl;
    return 0;
}

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

int main() {
  int D, G;
  cin >> D >> G;
  vector<int> p(D), c(D);
  for (int i = 0; i < D; i++) cin >> p[i] >> c[i];
  //入力
  
  int count = -1;
  for (int i = 0; i < (1 << D); i++) { //D桁bit全探索
    //1なら全部解く
    int score = 0;
    int solved = 0;
    int unsolve_max = -1;

    for (int j = 0; j < D; j++) { //j桁目が1か
      if ((i >> j) & 1) { //iをj個右シフトして&1したらj桁目が1番右に来て0001と&
        score += 100 * (j+1) * p[j] + c[j];
        solved += p[j];
      }
      else {
        unsolve_max = j;
      }
    }

    if (score < G) { //足りていないとき最大の解いていない問題で埋める
      int need = (G - score + 100 * (unsolve_max + 1) - 1) / (100 * (unsolve_max + 1));
      if (need >= p[unsolve_max]) { //全部解いてはいけない
        continue;
      }
      else {
        solved += need;
      }
    }
    
    if ((count == -1) || (solved < count)) {
      count = solved;
    }
  }

  cout << count << endl;
}

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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr int INF = 1001001001;

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

int main() {
    int l, r;
    cin >> l >> r;
    
    if (r - l > 2019) {
        cout << 0 << endl;
        return 0;
    } 
    
    int ans = 2019;
    rep (i, l, r) rep (j, i+1, r+1)
        chmin(ans, (int)(((ll)i*j) % 2019));
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3544
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	int num, i, ans = 0;
	cin >> num;
	vector<pair<int, int>> d(num);
	for (i = 0; i < num; i++) {
		scanf("%d", &d[i].first);
		d[i].second = i;
	}
	sort(d.begin(), d.end());
	for (i = 0; i < num; i += 2) {
		if (d[i].second & 1)
			ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1024
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    n,m= map(int, sys.stdin.readline().split())

    visited = [False for i in range(n)]
    matrix = [[False for i in range(n)] for j in range(n)]

    a =[]
    b = []

    #dfsで連結判定
    def dfs(v):
        visited[v] = True
        for v2 in range(n): #頂点v2：vに隣接かつ未訪問の頂点
            if matrix[v][v2] == False:#頂点に隣接
                continue
            if visited[v2] == True:#未訪問
                continue
            dfs(v2) #

    #隣接行列
    for i in range(m):
        _a,_b = map(int,input().split())
        a.append(_a -1)
        b.append(_b -1)
        matrix[a[i]][b[i]] = True
        matrix[b[i]][a[i]] = True
        # a,b = map(int, input().split())
        # matrix[a-1][b-1] = matrix[b-1][a-1] = True
        # print(matrix)
        # print(a[i])
        # print(b)

    #グラフから辺を取り除いて連結するかはんてい
    ans = 0
    for i in range(m):#辺を一個ずつ取り除いていく
        matrix[a[i]][b[i]] = False#辺を取り除く
        matrix[b[i]][a[i]] = False
        # matrix[i][i]=False

        visited = [False for i in range(n)]#すべての辺を未訪問にする。
        # print(visited)
        dfs(0)#頂点を訪問していく操作を実行。再帰で辺をvisitedを更新。
        # print("after:",visited)

        bridge = False#橋判定。一個でも未訪問に
        for j in range(n):
            if(visited[j] == False):#すべての頂点が訪問済みになってれば連結、そうでなければ非連結
                bridge=True#一個でも訪問できなければ、その辺は橋
        # print(visited)
        if(bridge):
            ans +=1
        matrix[a[i]][b[i]] = matrix[b[i]][a[i]] = True #辺を戻す
        # matrix[i][i] = True
    print(ans)



Measured memory_bytes: 5076
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
	int X; cin >> X;
	cout << (X == 7 || X == 5 || X == 3 ? "YES" : "NO") << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

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

	string S;
	cin >> S;

	Int ans = 0;
	for (Int i = 0; i < 4; i++) {
		if ('+'==S[i]) {
			ans++;
		}
		else {
			ans--;
		}
	}

	cout << ans << "\n";

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e5+10;
const ll MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
vector<int>adj[MAX];
int main() 
{
	double r;
	cin>>r;
	double pi=(22.0)/(7.0);
	cout<<setprecision(20)<<2*(M_PI)*r;
	
	
}

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

int main(){
    int N;
    cin>>N;
    int D,X;
    cin>>D>>X;
    int A[100];
    int  cnt=0;
    for(int i=0;i<N;i++){
        cin>>A[i];
        for(int j=1;j<=D;j+=A[i]){
            cnt++;
        }
    }
    cout<<cnt+X<<endl;
    return 0; 
}

Measured memory_bytes: 256
#include<stdio.h>

int solve(int i, int m, int n, int A[]){
	if(m == 0){
		return 1;
	}
	if(i >= n){
		return 0;
	}
	int rest = solve(i + 1, m, n, A) || solve(i + 1, m - A[i], n, A);
	return rest;
}

int main(void){
	int i,n,m,q;
	scanf("%d",&n);
	int A[n];
	for(i = 0; i < n; i++){
		scanf("%d",&A[i]);
	}
	scanf("%d",&q);
	for(i = 0; i < q; i++){
		scanf("%d",&m);
		if(solve(0, m, n, A)){
			printf("yes\n");
		}
		else{
			printf("no\n");
		}
	}
	return 0;
}



Measured memory_bytes: 2124
#include <iostream>
#include <cmath>

int main() {
    int inNum, dist;
    int nx, ny;      // 入力バッファ
    int ret = 0;         // 結果

    std::cin >> inNum >> dist;

    for (int i = 0; i < inNum; i++) {
        std::cin >> nx >> ny;
        if ( std::sqrt( std::pow(nx, 2) + std::pow(ny, 2) ) <= dist ) ret++;
    }

    std::cout << ret << std::endl;

}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
int main(void){
    int n;
    cin>>n;
    map<int,bool>m;
    vector<int>d(n,0);
    int ans=0;
    for (int i=0;i<n;i++){
        cin>>d[i];
        if(m[d[i]]==false){
            ans++;
            m[d[i]]=true;
        }
    }
    cout<<ans<<endl;
    return 0;
   
}

Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
AB_list = []
[heapq.heappush(AB_list, list(map(int, input().split()))) for _ in range(N)]
ans = 0
kouho = []

for day in range(1, M + 1):
    if len(AB_list) != 0:
        while AB_list[0][0] <= day:           
            heapq.heappush(kouho, heapq.heappop(AB_list)[1]*(-1))
            if len(AB_list) == 0:
                break
    if len(kouho) != 0:
        ans += heapq.heappop(kouho)

print(ans * (-1))

Measured memory_bytes: 89048
a = [int(input()) for _ in range(5)]
ans,mod = 0,0
for i in a:
    ans += i if i%10 == 0 else i+(10-i%10)
    mod = max(mod,i%10) if i%10 == 0 else max(mod,10-i%10)
print(ans-mod)

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define PRINT(a)   cout << (a) << endl
#define RALL(v) rbegin(v), rend(v)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main(){
  FOR(i,1,6){
    int x;
    cin >> x;
    if(x==0){
      PRINT(i);
      return 0;
    }
  }
}





Measured memory_bytes: 3628
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[6] = {0,1,0,-1,1,-1};
const int vy[6] = {1,0,-1,0,1,1};

void score(int D,vector<int> c,vector<vector<int>> s,vector<int> t){
    vector<int> last(26,0);  
    int ans = 0;
    rep(i,D){
        last[t[i]-1] = i+1;
        ans += s[i][t[i]-1];
        int tmp =  0;
        rep(j,26){
            tmp += c[j] * (i+1-last[j]);
        }
        ans -= tmp;
        cout << ans << endl;   
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int D;
    cin >> D;
    vector<int> c(26);
    rep(i,26) cin >> c[i];
    vector<vector<int>> s(D,vector<int> (26,0));
    vector<int> smax(D,0);
    vector<int> tt(D);
    rep(i,D){
        rep(j,26){
            cin >> s[i][j];
            int old = smax[i];
            smax[i] = max(smax[i],s[i][j]);
            if(old != smax[i]){
                tt[i] = j+1;
            }
        }
    }
    vector<int> t(D);
    vector<int> mis(26,0);
    int mismax = 0;
    int misi = 0;
    mis = c;
    int sum = 0;
    rep(j,26){
        int t = mismax;
        mismax = max(mismax,mis[j]);
        if(t != mismax){
            misi = j;
        }
    }
    rep(i,D) {
        rep(j,26){
            sum += mis[j];
        }
        if(smax[i] > sum){
            t[i] = tt[i];
            mis[tt[i]-1] = 0;
        }else{
            t[i] = misi+1;
            mis[misi] = 0;
            sum = 0;
        }
        rep(j,26){
            int t = mismax;
            mis[j] += c[j];
            mismax = max(mismax,mis[j]);
            if(t != mismax){
                misi = j;
            }
        }
    }    
    rep(i,D){
        cout << t[i] << endl;
    }
    
    
    cout << endl;
    return 0;
}


Measured memory_bytes: 3724
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

//座圧(破壊的)
int cocomp(ll*a,int n){
	//0～cnt-1に圧縮
	ll*b=(ll*)malloc(sizeof(ll)*n);
	memcpy(b,a,sizeof(ll)*n);
	sortup(b,n);
	int cnt=1;
	rep(r,1,n)if(b[r]!=b[cnt-1])b[cnt++]=b[r];
	rep(i,0,n){
		int l=0,r=cnt;
		while(r-l>1){int m=(l+r)/2;if(b[m]>a[i])r=m;else l=m;}
		a[i]=l;
	}
	free(b);
	return cnt;
}



//セグ木ここから
//*
//↓ここを変える
typedef struct atai{ll a;}atai;
atai xx(atai x,atai y){
	atai r;
	r.a=x.a+y.a;//sum
	return r;
}
atai aid={0};
//↑ここを変える

int segNUM;
atai *segN,*seg;
void seguse(int n){
	segN=(atai*)calloc(2*n,sizeof(atai));
	segNUM=n;
	seg=segN+segNUM;
	rep(i,1,2*segNUM)segN[i]=aid;
}
//seg[]に値を与えてから初期化
void seginit(){for(int node=segNUM-1;node;node--)segN[node]=xx(segN[node*2],segN[node*2+1]);}
void segupdate(int node,atai x){
	//seg[node]をxに更新
	node+=segNUM;
	segN[node]=x;
	while(node/=2)segN[node]=xx(segN[node*2],segN[node*2+1]);
}

atai segcalcsub(int l,int r,int k,int cl,int cr){
	if(l>=r)return aid;
	//完全に含むとき
	if(l<=cl&&cr<=r)return segN[k];

	int cm=(cl+cr)/2;
	//左側だけ
	if(r<=cm)return segcalcsub(l,r,2*k  ,cl,cm);
	//右側だけ
	if(cm<=l)return segcalcsub(l,r,2*k+1,cm,cr);
	//両方
	return xx(segcalcsub(l,r,2*k,cl,cm),segcalcsub(l,r,2*k+1,cm,cr));
}
atai segcalc(int l,int r){return segcalcsub(l,r,1,0,segNUM);}
//セグ木ここまで
//*/

ll a[200010];
int main(){
	int n;
	scanf("%d",&n);
	seguse(1<<18);
	rep(i,0,n)scanf("%lld",a+i);
	cocomp(a,n);
	ll ans=0;
	for(int i=0;i<n;i++){
		ans+=segcalc(a[i],n).a;
		atai x={1};
		segupdate(a[i],x);
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 10196
n = int(input())
xy = []
for _ in range(n):
  x, y = map(int, input().split())
  xy.append([x, y])

sm = 0
def distance(a, b):
  return ((a[0]-b[0])**2 + (a[1]-b[1])**2) ** 0.5

for i in range(n):
  for j in range(n):
    if i == j:
      continue
    sm += distance(xy[i], xy[j])
    # print(i, xy[i], j, xy[j], distance(xy[i], xy[j]))
print(sm / n )

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=[]
for i in range(n):
    a,b=MI()
    lis.append([a,b,a+b])
lis.sort(key=lambda x:x[2],reverse=True)
ans=0
for i in range(n):
    if i%2==0:
        ans+=lis[i][0]
    else:
        ans-=lis[i][1]
print(ans)



Measured memory_bytes: 90520
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

T = [0]*N
for i in range(N):
    T[i] = A[i] - B[i]

T.sort()
r = N-1
l = 0

flag = True
cnt = 0

if T[l] >= 0:
    print(0)
else:
    while T[l] < 0:
        if l >= r:
            flag = False
            break
        elif T[r] >= -T[l]:
            T[r] += T[l]
            l += 1
        else:
            T[l] += T[r]
            r -= 1
                


    ans = l + (N - r)
    if flag:
        print(ans)
    else:
        print(-1)


Measured memory_bytes: 80176
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
    int X[100010];
    rep(i, N) cin >> X[i];
    int ans = 0;
    rep(i, N - 1) {
        ans += min(B, (X[i + 1] - X[i]) * A);
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main() {
    unsigned int n, q;
    cin >> n >> q;

    vector<priority_queue<int> > pq(n);
    while (q--) {
        int op, t;
        cin >> op >> t;
        if (op == 0) {
            int x;
            cin >> x;
            pq[t].push(x);
        } else if (op == 1) {
            if (pq[t].empty()) continue;
            cout << pq[t].top() << endl;
        } else if (op == 2) {
            if (pq[t].empty()) continue;
            pq[t].pop();
        }
    }
    return 0;
}



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

const int N = 3e5 + 9;

int32_t main()
{
    long long n; cin >> n;
    long long ans = 0;
    for(long long i = 2; i * i <= n; i++) if(n % i == 0){
        long long p = n;
        while(p % i == 0)  p /= i;
        if(p == 1 || (p - 1) % i == 0) ans++;
        if(i != n / i){
            p = n;
            while(p % (n / i) == 0)  p /= n / i;
            if(p == 1 || (p - 1) % (n / i) == 0) ans++;
        }
    }
    ans++; n--;
    for(long long i = 2; i * i <= n; i++) if(n % i == 0){
        ans += 1 + (i != n / i);
    }
    ans += n > 1;
    cout << ans << '\n';
    return 0;
}


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

int main(){
  ll x,sum=0;
  cin>>x;
  for(int i=1;;i++){
    sum+=i;
    if(sum==x){
      cout<<i<<endl;
      return 0;
    }else if(sum>x){
      cout<<i<<endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N,M; cin >> N >> M;
    vector<int> A(M);
    ll cnt=0;
    for(int i=0;i<M;i++){
        cin >> A[i];
        cnt += A[i];
    }
    if(N-cnt>=0) cout << N-cnt << endl;
    else cout << -1 << endl;
    return 0;
}


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

bool binarySearch(int* a,int key,int length){
    int left = 0;
    int right = length;
    int center;
    
    while(left < right){
        center = (left + right) / 2;
        if(a[center] == key){
            return true;
        }
        else if(a[center] > key){
            right = center;
        }else{
            left = center + 1;
        }
    }
    return false;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,n2,key;
    cin >> n;
    int a[n];
    for (int i = 0;i < n;++i) {
        cin >> a[i];
    }
    cin >> n2;
    for(int i = 0;i < n2;++i){
        cin >> key;
        cout << binarySearch(a,key,n) << endl;
    }
}


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

using namespace std;
typedef long long ll;

int main(){

  string s;
  cin >> s;

  ll counter = 0;

  for (ll i = 0; i<s.size();i++){
    if(s[i]=='o')
      counter++;
  }

  cout << counter * 100 + 700 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);	
		String a = stdin.next();
		String b = stdin.next();
		
		if(a.charAt(0)==b.charAt(2)&&a.charAt(1)==b.charAt(1)&&a.charAt(2)==b.charAt(0)) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

		
		// TODO 自動生成されたメソッド・スタブ

	}

}


Measured memory_bytes: 21972
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	b := sc.nextStr()
	if b == "A" {
		fmt.Println("T")
	} else if b == "C" {
		fmt.Println("G")
	} else if b == "G" {
		fmt.Println("C")
	} else {
		fmt.Println("A")
	}
}


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

int main(){
  int n,x,a=0,count=1;
  cin>>n>>x;
  
  for(int i=0;i<n;i++){
    int b;
    cin>>b;
    a=a+b;
    if(a<=x){
      count=count +1;
  }
    
    
  }
  if(a<x){
    cout<<n+1<<endl;
  }
  else {
  cout<<count<<endl;
  }
  
  
}
 


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

int SumOfDigits(int n){
  int sum = 0;
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(void){
  int n;
  cin >> n;
  if(n % SumOfDigits(n) == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define mod 1000000007

int main()
{

    ll n;
    cin >> n;
    ll ans=n;
    ll sq=sqrt(n);
    for(ll i=1; i <= sq; i++)
    {

        if(n%i==0) ans=i;
    }
    ll jk=n/ans;
    ans=max(ans,jk);
    ll dig=0;
    while(ans)
    {

        dig++;
        ans/=10;
    }
    cout << dig;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


# クラス
class CombMod:

    def __init__(self, N, MOD=10**9 + 7):

        N = N + 1
        inv = [0] * N
        fact = [0] * N
        fact_inv = [0] * N

        inv[0] = 0
        inv[1] = 1
        for n in range(2, N):
            q, r = divmod(MOD, n)
            inv[n] = inv[r] * (-q) % MOD

        fact[0] = 1
        for n in range(1, N):
            fact[n] = n * fact[n - 1] % MOD

        fact_inv[0] = 1
        for n in range(1, N):
            fact_inv[n] = fact_inv[n - 1] * inv[n] % MOD

        self.fact = fact
        self.fact_inv = fact_inv
        self.inv = inv

    def comb(self, n, r, mod=10**9 + 7):
        return self.fact[n] * self.fact_inv[r] % mod * self.fact_inv[n - r] % mod

    def perm(self, n, r, mod=10**9 + 7):
        return self.fact[n] * self.fact_inv[n - r] % mod


def main():

    N = in_n()

    if N == 1:
        print(0)
        exit()

    mod = 10**9 + 7
    comb = CombMod(N + 1)
    ans = 0

    for x in range(2, N + 1):
        t = comb.comb(N, x)
        t *= pow(2, x, mod) - 2
        t %= mod
        t *= pow(8, N - x, mod)
        t %= mod
        ans += t
        ans %= mod

    print(ans)


if __name__ == '__main__':
    main()


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

int main()
{
	int n;
	cin >> n;
	vector<string> s(n);
	for(int i=0;i<n;i++)
		cin >> s[i];
	
	int count=0;
	int ba=0;
	int b=0;
	int a=0;
	
	for(int i=0;i<n;i++)
	{
		bool bflag=false;
		bool hbflag=false;
		if(s[i][0]=='B')hbflag=true;
		bool aflag=false;
		for(int j=0;j<s[i].size();j++)
		{
			if(s[i][j]=='A')
			{
				aflag=true;
				bflag=false;
			}
			else if(s[i][j]=='B')
			{
				if(aflag)count++;
				aflag=false;
			}
			else
			{
				aflag=false;
				bflag=false;
			}
		}
		if(aflag and hbflag)ba++;
		else if(aflag)a++;
		else if(hbflag)b++;
	}

	int ans=count;
	int x=0;
	if(ba>0)
	{
		x=ba-1;
		if(a>0)
		{
			a--;
			x++;
		}
		if(b>0)
		{
			b--;
			x++;
		}
	}
	x+=min(a,b);
	if(x>=n)x=n-1;
	ans+=x;
	cout << ans << endl;



}

Measured memory_bytes: 768
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 10 + 5;
const int MAXM = 1e3 + 5;
const int inf = 0x3f3f3f3f;

inline void chk_min(int &a,int b){ if(a>b) a=b;}

char s[MAXN][MAXM];
int a[MAXN][MAXM];
int cnt[MAXN],fa[MAXN];

#define bit(x,i) (((x)>>(i))&1)

int main(void)
{
	int n,m,d;
	scanf("%d%d%d",&n,&m,&d);
	for(int i=1; i<=n; ++i) scanf("%s",s[i]+1);
	
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=m; ++j)
			a[i][j] = s[i][j]-'0';
	
	int all = (1<<(n-1))-1, ans=inf;
	for(int mask=0; mask<=all; ++mask)
	{
		int res=0,lst=1;
		for(int i=0; i<=n-1; ++i)
		{
			fa[i+1]=lst;
			if(bit(mask,i)) ++res, lst=i+2;
		}
		
		bool ok=1;
		for(int i=1,j=1; i<=m; i=j, ++res)
		{
			for(int k=1; k<=n; ++k) cnt[k]=0;
			
			while(j<=m)
			{
				bool flag=1;
				for(int k=1; k<=n; ++k)
					if(a[k][j] && ++cnt[fa[k]]>d)
					{
						flag=0;
						break;
					}
				if(!flag) break;
				++j;
			}
			
			if(i==j)
			{
				ok=0;
				break;
			}
		}
		--res;
		
		if(ok) chk_min(ans,res);
	}
	printf("%d",ans);
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;

const int INF=1e9;
const int MOD=1e9+7;

int main(){
    int X;
    cin >> X;
    int ans;
    if(X<600){
        ans=8;
    }else if(X>=600&&X<800){
        ans=7;
    }else if(X>=800&&X<1000){
        ans=6;
    }else if(X>=1000&&X<1200){
        ans=5;
    }else if(X>=1200&&X<1400){
        ans=4;
    }else if(X>=1400&&X<1600){
        ans=3;
    }else if(X>=1600&&X<1800){
        ans=2;
    }else{
        ans=1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
    char a[4];
    int i,count=0;
    scanf("%s",a);
    for(i=0;i<4;i++)
    {
        if(a[i]=='+')
            count++;
        else
            count--;
    }
    printf("%d",count);
    return 0;
}


Measured memory_bytes: 128
N=int(input())
A=[int(input()) for _ in range(N)]

ans=A[0]//2
res=A[0]%2
for i in range(1,N):
    ans+=(A[i]+res)//2
    if A[i]>0:
        res=(A[i]+res)%2
    else:
        res=0
print(ans)

Measured memory_bytes: 13012
import java.util.*;
import java.awt.*;

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

        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        int[] h = new int[n];

        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            h[i] = sc.nextInt();
        }

        int ans = 0;
        int tx = -1;
        int ty = -1;

        for (int px = 0; px <= 100; px++) {
            for (int py = 0; py <= 100; py++) {
                boolean f = true;
                int ph = 0;

                for (int i = 0; i < n; i++) {
                    if (h[i] > 0) {
                        ph = h[i] + Math.abs(x[i]-px) + Math.abs(y[i]-py);
                        break;
                    }
                }

                for (int i = 1; i < n; i++) {
                    int tmp = ph - h[i] - Math.abs(x[i]-px) - Math.abs(y[i]-py);
                    if (tmp > 0) {
                        f = false;
                    } else if (tmp < 0) {
                        if (h[i] != 0) {
                            f = false;
                        }
                    }
                }

                if (f == true) {
                   ans = ph;
                   tx = px;
                   ty = py;
                }
            }
        }

        System.out.println(tx + " " + ty + " " + ans);
    }
}

Measured memory_bytes: 23380
//区間更新、区間取得
#include<bits/stdc++.h>
using namespace std;

struct BinaryIndexedTree{
  int N;
  vector<long long> bit[2]; 
  //全て0で初期化
  BinaryIndexedTree(int size){
    bit[0].resize(size+1,0);
    bit[1].resize(size+1,0);
    N=size+1;
  }
  void add_sub(int a,int b,int w){
    for(int i=b;i<N;i+=(i & (-i))){
      bit[a][i]+=w;
    }
    return;
  }
  //区間[a,b)のところv[a],v[a+1], ,v[b-1]に値wを加える
  void add(int a,int b,int w){
    add_sub(0,a,-w*(a-1));
    add_sub(0,b,w*(b-1));
    add_sub(1,a,w);
    add_sub(1,b,-w);
    return;
  } 

  long long sum_sub(int p,int c){
    long long sum=0;
    for(int i=c;i>0;i-=(i & (-i))){
      sum+=bit[p][i];
    }
    return(sum);
  }
  //区間[0,c)のところの和v[0]+v[1]+ +v[c-1]を求める。
  long long sum(int c){
    //(p[0]+p[1]+  +p[c])+(q[0]+q[1]+ +q[c])c を求める。
    long long ret=0;
    ret+=sum_sub(0,c);
    ret+=(sum_sub(1,c)*c);
    return(ret);
  }
  //[a,b)の区間和を取得する。
  long long query(int a,int b){
    long long ret=0;
    ret=sum(b-1);
    ret-=sum(a-1);
    return(ret);
  }
};
//AOJ DSL 2 G RSQ and RAQ にて動作確認を行いました。
int main(){
  int n,q;
  cin>>n>>q;
  BinaryIndexedTree BIT(n+5);
  int que,s,t,x;
  for(int i=0;i<q;i++){
    cin>>que;
    if(que==0){
      cin>>s>>t>>x;
      BIT.add(s,t+1,x);
    }
    else{
      cin>>s>>t;
      cout<<BIT.query(s,t+1)<<'\n';
    }
  }
  return(0);
}


Measured memory_bytes: 4376
using System;

namespace AtCoderBeginnerContest136
{
    class transfer
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().Split(' ');
            var A = int.Parse(r[0]);
            var B = int.Parse(r[1]);
            var C = int.Parse(r[2]);
            if((A - B) - C >= 0){
                Console.WriteLine(0);
            }
            else {
                Console.WriteLine(Math.Abs((A - B) - C));
            }
            
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
 
using namespace std;
 
typedef long long ll;
const int N=5e5+9;
 
ll to[N<<1],nxt[N<<1],beg[N],tot;
ll n,m,c[N],w[N<<1];
ll ans,f[4],flag;
 
inline void add(int u,int v,int c)
{
    to[++tot]=v;
    nxt[tot]=beg[u];
    w[tot]=c;
    beg[u]=tot;
}
 
inline void dfs(int u)
{
    f[c[u]]++;
    for(int i=beg[u];i;i=nxt[i])
    {
        if(w[i]==1)f[3]++;
        if(!(~c[to[i]]))
        {
            c[to[i]]=(c[u]+w[i])%3;
            dfs(to[i]);
        }
        else if (c[to[i]]!=(c[u]+w[i])%3)
            flag=1;
    }
}
 
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1,u,v;i<=m;i++)
    {
        scanf("%d%d",&u,&v);
        add(u,v,1);add(v,u,2);
    }
 
    memset(c,-1,sizeof(c));
    for(int i=1;i<=n;i++)
        if(!(~c[i]))
        {
            f[c[i]=0]=f[1]=f[2]=f[3]=flag=0;
            dfs(i);
            if(flag)
            {
                ll cnt=f[0]+f[1]+f[2];
                ans+=cnt*cnt;
                goto nxt;
            }
            if((!f[0]) || (!f[1]) || (!f[2]))
            {
                ans+=f[3];
                goto nxt;
            }
 
            ans+=f[0]*f[1];
            ans+=f[1]*f[2];
            ans+=f[2]*f[0];
 
            nxt:;
        }
 
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 20096
from collections import deque
from heapq import heappush,heappop
import re

def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))

INF = 1<<29

DIV = 10**9+7

def mod_inv(a,mod = DIV):
    return pow(a,mod-2,mod)

def ncr(n,r, mod =DIV):
	r = min(r,n-r)
	ret = 1
	for i in range(1,r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * pow(i, mod-2, mod) % mod
	return ret


def main():
    N, M,K = ints_raw()
    ans = 0
    for d in range(1,N):
        ans =(ans+d*(N-d)*M*M)%DIV
    for d in range(1,M):
        ans =(ans+d*(M-d)*N*N)%DIV
    return (ans*ncr(N*M-2,K-2))%DIV
print(main())


Measured memory_bytes: 38896
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] c = new int[m];
		for(int i = 0; i < m; i++){
			c[i] = sc.nextInt();
		}
		int[] DP = new int[n+1];
		Arrays.fill(DP,999999);
		DP[0] = 0;
		for(int i = 1; i <= n; i++){
			for(int j = 0; j < m; j++){
				if(i-c[j]>=0){
					DP[i] = Math.min(DP[i],DP[i-c[j]]+1);
				}
			}
		}
		System.out.println(DP[n]);
	}
}



Measured memory_bytes: 27016
package main
import (
    "fmt"
    "math"
)

var zero = make(map[int]float64)
var one  = make(map[int]float64)

func main(){
    var N, K int
    var s string
    fmt.Scan(&N, &K, &s)
    fmt.Println(search(s, N, K))
}

func search(s string, N, K int) float64{
    padding(s, N, K)
    var ans, count float64
    for i, n:=0, 1; i<=len(zero); i++{
        if i == 0{
            if s[0] == 49 {
                count += one[K] + zero[K]
                n = 0
            }
            for j:=0; j<K; j++{
                count += zero[i+j] + one[i+j]
            }
        } else {
            count += zero [i+K-n] + one[i+K-n] - zero[i-n] - one[i-1-n]
        }
        
        ans = math.Max(ans, count)
    } 
    return ans
}

func padding(s string, N, K int){
    for i, now:= 0, 0; now<N; i++ {
        for now < N && s[now] == 48{
            zero[i]++
            now ++
        }
        for now < N && s[now] == 49{
            one[i]++
            now ++
        }
    }
}


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

int main(){
  int i,N,M;
  long long money=0;
  cin>>N>>M;
  vector<pair<long long,long long>> a(N);
  for(i=0;i<N;i++) cin>>a.at(i).first>>a.at(i).second;
  sort(a.begin(),a.end());
  for(i=0;M>0;i++){
    
    if(M>a.at(i).second){
      M-=a.at(i).second;
      money+=a.at(i).first*a.at(i).second;
    }
    else{
      money+=a.at(i).first*M;
      M-=a.at(i).second;
    }
  }
  cout<<money<<endl;
  return 0;
}
    


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebug(multimap<T1, T2> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mdebugr(map<T1, T2, greater<T1>> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebugr(multimap<T1, T2, greater<T1>> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    ll n, m, Q;
    vector<ll> a[510];
    ll l, r;
    cin >> n >> m >> Q;
    rep(i, m){
        cin >> l >> r;
        a[l].push_back(r);
    }

    sort(all(a[l]));
    repr(i, n, 1){
        copy(all(a[i]), back_inserter(a[i-1]));
        sort(all(a[i-1]));
    }

    ll p, q;
    rep(i, Q){
        cin >> p >> q;
        auto itr = upper_bound(all(a[p]), q);
        int ind = distance(a[p].begin(), itr);
        cout << ind << endl;
    }

    return 0;
}


Measured memory_bytes: 270000
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn
  s <- BS.getLine
  let f c = chr $ (ord c - ord 'A' + n) `rem` 26 + ord 'A'
  BS.putStrLn $ BS.map f s


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

int a[10005];

int main()
{
  int s;
  cin >> s;
  a[s] = 1;
  for (int i = 1;; i++)
  {
    if (s % 2)
    {
      s = 3 * s + 1;
    }
    else
    {
      s = s / 2;
    }
    if (a[s])
    {
      cout << i + 1 << endl;
      return 0;
    }
    else
    {
      a[s] = i;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
const int MAXN = 300 + 10;

char s[MAXN];
int k, n;
inline void chmax(int &x, int y) {
  x = std::max(x, y);
}
namespace solver1 {
  int f[MAXN][MAXN][MAXN];
  void main() {
    for (int i = 1; i <= n; i++) {
      for (int j = n; j > i; j--) {
        for (int t = k; t >= 0; t--) {
          if (s[i] == s[j]) f[i][j][t] = f[i - 1][j + 1][t] + 1;
          chmax(f[i][j][t], f[i - 1][j][t]);
          chmax(f[i][j][t], f[i][j + 1][t]);
          if (t == k) continue;
          //chmax(f[i][j][t], f[i][j][t + 1]);
          chmax(f[i][j][t], f[i - 1][j + 1][t + 1] + 1);
          if (t + 1 == k) continue;
          //chmax(f[i][j][t], f[i - 1][j + 1][t + 2] + 1);
          
        }
      }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j <= k; j++) {
        chmax(ans, f[i][i + 1][j] * 2);
        chmax(ans, f[i][i + 2][j] * 2 + 1);
      }
    }
    printf("%d\n", ans);
  }
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  scanf("%d", &k);
  solver1::main();
}


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

using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;
using str = string;
using bl = bool;
using ch = char;

template<class T> using v = vector<T>;
template<class T> using uset = unordered_set<T>;
template<class T1, class T2> using umap = unordered_map<T1, T2>;

template<class T> void pd(T x)
{
    cout << x << " ";
}
template<class T> void pl(T x)
{
    cout << x << endl;
}

#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define sz(x) ((int)(x).size())
#define ph push_back
#define pp pop_back
#define mp make_pair
#define rep(i, a) for(int i = 0; i < (int)a; ++i)
#define repd(i, a) for(int i = (int)a; i >= 0; --i)
#define REP(i, a, b) for(int i = a; i < (int)b; ++i)
#define REPD(i, a, b) for(int i = (int)a; i >= b; --i)
#define fore(i, a) for(auto& i : a)
#define FORE(i, a) for(auto i : a)

// -----



int main()
{
    ll x;
    cin >> x;
    
    x = x % 10;
    if(x == 2 || x == 4 || x == 5 || x == 7 || x == 9)
    {
        pl("hon");
    }
    else if(x == 0 || x == 1 || x == 6 || x == 8)
    {
        pl("pon");
    }
    else
    {
        pl("bon");
    }
    
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int n;
string s; 
int main(){
    cin>>n;
    cin>>s;
    if(n%2!=0){
    cout<<"No";
    return 0;
}
     else{
     for(int i=0;i<=n/2-1;i++){
          if(s[i]!=s[n/2+i]){
          cout<<"No";
            return 0;
        }
     }
     cout<<"Yes";
     return 0;
    }
}


Measured memory_bytes: 256