akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char[]ss = S.toCharArray();
 
    int all = 0;
    for(int i=0; i<S.length(); i++) {
    	all += ss[i]-48; 
    	}
    int N = Integer.valueOf(S);
    
    if(N%all == 0) {
    	System.out.println("Yes");
    }else {
    	System.out.println("No");   	
    }
    }
}


Measured memory_bytes: 35872
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];

  int cnt = 0;
  for(int i=0;i<n;i++){
    if(i%2==0 && a[i]%2==1){
      cnt++;
    }
  }

  cout << cnt << endl;
}

Measured memory_bytes: 3604
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    let N = input[0][0];

    let tmp = 0;

    for (let i = 0; i < N.length; i++){
        tmp += parseInt(N[i], 10);
        tmp %= 9;
    }
    if (tmp === 0) console.log("Yes");
    else console.log("No");

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(){
	int N;
	cin >> N;
	int A[N][N];
	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			cin >> A[i][j];
		}
	}
	long long ans = 0;
	for(int i=0; i<N; i++){
		for(int j=i+1; j<N; j++){
			int f = 0;
			for(int k=0; k<N; k++){
				if(i != k && j != k){
					if(A[i][j] > A[i][k] + A[k][j]){
						cout << -1 << endl;
						return 0;
					}else if(A[i][j] == A[i][k] + A[k][j]){
						f = 1;
					}
				}
			}
			if(!f) ans += A[i][j];
		}
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;

#define NIL -1
#define MAX 100001

struct Node{
    int parent;
    int left;
    int right;
};

Node tree[MAX];
int n;
int depth[MAX];

void setdepth(int r,int i){
    depth[r]=i;
    if(tree[r].right != NIL)setdepth(tree[r].right,i);
    if(tree[r].left != NIL) setdepth(tree[r].left,i+1);
}

void print_ch(int r){
    int ch = tree[r].left;
    for(int i=0;ch!=NIL;i++){
        if(i)cout << ", ";
        cout << ch;
        ch = tree[ch].right;
    }
}

void print(){
    for(int i=0;i<n;i++){
        cout << "node " <<i;
        cout << ": parent = " << tree[i].parent;
        cout << ", depth = " << depth[i];
        if(tree[i].parent==NIL)cout << ", root";
        else if(tree[i].left ==NIL)cout << ", leaf";
        else cout << ", internal node";
        cout << ", [";
        print_ch(i);
        cout << "]\n";
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    int id,k,ch;
    int left;
    for(int i=0;i<n;i++)tree[i].parent=tree[i].left=tree[i].right=NIL;

    for(int i=0;i<n;i++){
        cin >> id >> k;
        for(int j=0;j<k;j++){
            cin >> ch;
            tree[ch].parent=id;
            if(!j)tree[id].left=ch;
            else tree[left].right=ch;
            left=ch;
        }
    }

    int r;
    for(int i=0;i<n;i++){
        if(tree[i].parent==NIL)r=i;
    }

    setdepth(r,0);
    print();

    return 0;

}



Measured memory_bytes: 7812
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long s64;

inline s64 getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	s64 res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

const int MaxN = 100000;

int n, m;

int sta_n;
s64 sta[MaxN + 2];

s64 occur[MaxN + 2];
s64 sum[MaxN + 2];

inline int jump(s64 x, int r)
{
	int l = 1;
	while (l <= r)
	{
		int mid = l + r >> 1;
		if (sta[mid] > x)
			r = mid - 1;
		else
			l = mid + 1;
	}
	return r;
}

int main()
{
	cin >> n >> m;

	sta[sta_n = 1] = n;
	for (int i = 1; i <= m; ++i)
	{
		s64 l = getint();
		while (sta_n && l <= sta[sta_n])
			--sta_n;
		sta[++sta_n] = l;
	}

	occur[sta_n] = 1;
	for (int i = sta_n; i; --i)
	{
		s64 l = sta[i];
		int k = jump(l, i - 1);

		while (k > 0)
		{
			occur[k] += l / sta[k] * occur[i];
			k = jump(l %= sta[k], k - 1);
		}

		sum[1] += occur[i];
		sum[l + 1] -= occur[i];
	}

	s64 cur = 0;
	for (int i = 1; i <= n; ++i)
		printf("%lld\n", cur += sum[i]);

	return 0;
}

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

int main(){

  int a,b,c,d,p;
  int vala=0,valb=0;

  cin>>a>>b>>c>>d>>p;

  vala = a*p;

  valb = b;

  if(p > c){
    valb += d*(p-c);
  }

  if(vala>=valb){
    cout << valb<<endl;
  }else cout << vala<<endl;

  
  return 0;
}



Measured memory_bytes: 3104
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	N, _ := strconv.Atoi(sc.Text())

	H := make([]int, N)
	for i := 0; i < N; i++ {
		sc.Scan()
		H[i], _ = strconv.Atoi(sc.Text())
	}

	canChange := true
	for i := 1; i < N; i++ {
		if canChange && H[i-1] > H[i]+1 {
			fmt.Println("No")
			return
		} else if !canChange && H[i-1] > H[i] {
			fmt.Println("No")
			return
		} else if H[i-1] > H[i] {
			canChange = false
		} else if H[i] > H[i-1] {
			canChange = true
		}
	}
	fmt.Println("Yes")
}


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

#ifdef BTK
#define DEBUG if(1)
#else
#define DEBUG if(0)
#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#endif

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r){bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r){bool a=l<r;if(a)l=r;return a;}
template <typename T>istream& operator>>(istream &is,vector<T> &v){for(auto &it:v)is>>it;return is;}

constexpr char ln = '\n';
constexpr int mod = 1e9+7;
const string ok = "Yes";
const string ng = "No";
typedef pair<int,int> P;
typedef priority_queue<P,vector<P>,greater<P>> QUE;
int main(){
    int m;
    cin>>m;
    vector<int> dp(m,50);
    QUE que;
    FOR(i,1,10)if(chmin(dp[i%m],i))que.push({i,i%m});
    while(que.size()){
        int v,cost;
        tie(cost,v) = que.top();que.pop();
        REP(i,10){
            int u = (v*10+i)%m;
            int ncost = cost + i;
            if(chmin(dp[u],ncost))que.push({ncost,u});
        }
    }
    cout<<dp[0]<<endl;
    return 0;
}


Measured memory_bytes: 2932
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for(ll i=0;i<(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    list<int>ls;
    auto it=ls.end();
    int q;cin>>q;
    rep(i,q){
        int a;cin>>a;
        if(a==0){
            int b;cin>>b;
            it=ls.insert(it,b);
        }
        else if(a==1){
            int b;cin>>b;
            if(b>0)rep(i,b)it++;
            else rep(i,-b)it--;
        }
        else{
            it=ls.erase(it);
        }
    }
    for(auto i:ls)cout<<i<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------













































Measured memory_bytes: 18708
#include<stdio.h>
 
 
main()
{
  int A[100],N;
  int i,k,key,j;
 
scanf("%d",&N);
 
for (k=0;k<N;k++)scanf("%d",&A[k]);
 
for (k=0;k<N;k++){
printf("%d",A[k]);
if(k!=N-1){printf(" ");}
}
printf("\n");
 
for (i=1;i<=N-1;i++){   
 
  
    key = A[i];
    /* insert A[i] into the sorted sequence A[0,...,j-1] */
    j = i-1;
 
      while(j>= 0 && A[j]>key){
        A[j+1] = A[j];
        j--;
       }
    A[j+1] = key;
 
for (k=0;k<N;k++){
         printf("%d",A[k]);
if(k!=N-1)printf(" ");}   
 
printf("\n");
  }
 
      return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define mod 1000000007
#define S second
#define F first
#define int long long
using namespace std;
string s;
int mutu(int a){
	int b=1;
	for(int i=a+1;i!=s.size();i++){
		if(s[i]==s[a]) b++;
		else break;
	}
	return b;
}
int solve(int a){
	int i=a;
	for(;i!=s.size();i++){
		if(s[i]=='J') break;
	}
	return i-1;
}
int mypow(int a,int b,int c){
	if(b==1) return a%c;
	if(b%2) return a*mypow(a,b-1,c)%c;
	int d=mypow(a,b/2,c);
	return d*d%c;
}
signed main(){
	int a;
	cin>>a;
	if(a==3||a==5||a==7) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 256
//According to all known laws of aviation, there is no way that a bee should be able to fly.
//Its wings are too small to get its fat little body off the ground. The bee, of course, flies anyway.
//Because bees don't care what humans think is impossible.
#include <bits/stdc++.h>
#define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
using vll = vector<long long int> ;
  
int main(){
    bigint N , M , K  ; cin >> N >> M >> K ;
    vll arr , brr ;
    arr.push_back(0) ;
    for( int i = 1 ; i <= N ; i++ ){
        int x ; cin >> x ;
        arr.push_back(arr[i-1]+x) ;
    }
    bigint x ; cin >> x ;
    brr.push_back(x) ;
    for( int i = 1 ; i < M ; i++ ){
        cin >> x ;
        brr.push_back(x+brr[i-1]) ;
    }
    bigint ans = 0 ;
    for( bigint i = 0 ; i <= N ; i++ ){
        bigint bacha = K - arr[i] ;
        if( bacha < 0 )
            break ;
        auto idx = upper_bound(brr.begin(), brr.end(), bacha ) - brr.begin() ;
        ans = max( ans , i + idx ) ;
    }
    cout << ans << endl ;
    return 0 ;
}


Measured memory_bytes: 7968
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define endl '\n'
using ll=long long;
 
const int INF=1e9+5;
const ll lim=(ll)3e16;
const int N=510000;
const int mod=1e9+7;
const ll oo=1e18+5;

ll fac[N],my_inv[N],inv[N];
ll a[N];

void init(){
	fac[0]=1;
	fac[1]=1;
	my_inv[0]=1;
	my_inv[1]=1;
	inv[1]=1;
	for(int i=2;i<N;++i){
		fac[i]=fac[i-1]*i%mod;
		inv[i]=mod-inv[mod%i]*(mod/i)%mod;
		my_inv[i]=my_inv[i-1]*inv[i]%mod;
	}
}

ll bio(int n,int k){
	if (n<k) return 0;
	if (n<0||k<0) return 0;
	return fac[n]*(my_inv[k]*my_inv[n-k]%mod)%mod;
}

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	int n,k;
	cin>>n>>k;
	init();
	for(int i=1;i<=n;++i) cin>>a[i];
	sort(a+1,a+1+n);
	ll ans=0;
	for(int i=n;i>=k;--i){
		//~ cout<<bio(i-1,k-1)<<endl;
		ans=ans+a[i]*bio(i-1,k-1)%mod;
		//~ cout<<ans<<endl;
	}
	for(int i=1;i<=n-k+1;++i){
		ans=ans-a[i]*bio(n-i,k-1)%mod;
	}
	cout<<(ans+mod)%mod;
	return 0;
}


//~ 1 2 3 4 5 6 7 8 9 10


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

const int MAX = 100;
int main() {
	int N, x, a[MAX];
	cin >> N >> x;
	for (int i = 0;i < N;++ i) cin >> a[i];
	sort(a, a+N);
	for (int i = 0;i < N;++ i) {
		if (a[i] <= x) x -= a[i];
		else {
			cout << i;
			return 0;
		}
	}
	if (x == 0) cout << N;
	else cout << N - 1;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

なるべく小さい量のお菓子を貰って喜ぶ子供を優先すれば良い
*/

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

int main() {
  int n; cin>>n;
  vector<int> d(n);
  rep(i, n) cin>>d[i];

  int sum=0;
  rep(i, n) {
    rep(j, n) {
      if (i==j) continue;
      sum+=d[i]*d[j];
    }
  }
  sum/=2;
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <vector>

#include <bits/stdc++.h>
using namespace std;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define TRUE (0)
#define FALSE (1)

// This value shold be close to used maximum value.  
#define NUM_MAX 20000000005

// void sort(uint32_t *num, uint32_t size);

int main()
{
    vector<vector<uint64_t>> arr(0);
    vector<uint64_t> temp_vec(2);
    vector<uint64_t> num_vec(0);
    string result;
    // vector<long long> res_vec(0);
    // uint64_t res_arr[NUM_MAX];
    // uint32_t sum = 0;
    uint64_t num1, num2;
    uint64_t num;
    // uint64_t result;
    double length, mass;

    // uint32_t res_i = 0;
    // string str_temp, str_temp2;
    uint64_t temp, temp2;
    uint64_t i, j, k, l, count, n, o, size;
    // uint32_t count = 0;
    // string str;
    // uint8_t k_flag;
    
    cin >> result;

    if (result.at(2) != result.at(3)) {
        cout << "No" << endl;
        return 0;
    }
    if (result.at(4) != result.at(5)) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    // cout << fixed << setprecision(10) << mass << endl;

    // for (i=0; i<num; i++) {
    //     cin >> temp_vec.at(0) >> temp_vec.at(1);
    //     arr.push_back(temp_vec);
    // }

    // for (i=0; i<num; i++) {
    //     temp = arr.at(i).at(0);
    //     result[temp] = arr.at(i).at(1);
    // }

    return 0;
}

uint64_t silver_fox(vector<vector<int64_t>>& monster_arr, uint64_t range, uint64_t attack, uint64_t count)
{
    int64_t life, pos, num;
    int64_t i, short_i;

    while (monster_arr.size() != 0) {
        pos = monster_arr[0][0];
        life = monster_arr[0][1];
        count++;
        short_i = 0;

        for (i = 0; i < monster_arr.size(); i++) {
            short_i++;
            if (monster_arr[i][0] < pos + range) {
                monster_arr[i][1] -= attack;
            } else {
                break;
            }
        }

        for (i = short_i - 1; i >= 0; i--) {
            if (monster_arr[i][1] <= 0) {
                monster_arr.erase(monster_arr.begin() + i);
            }
        }
    }

    return count;
}

// void sort(uint32_t *num, uint32_t size) {
//     uint32_t i, j, k;
//     uint32_t sorted_num;
//     uint32_t array[NUM_MAX] = {0};

//     for (i = 1; i < size + 1; i++) {
//         array[num[i - 1]]++;
//     }

//     sorted_num = 0;

//     for (i = 0; i < NUM_MAX; i++) {
//         for (j = 0; j < array[i]; j++) {
//             num[j + sorted_num] = i;
//         }
//         sorted_num += j;
//         j = 0;
//     }

//     return;
// }


Measured memory_bytes: 256
def main():
  h,w = list(map(int,input().split()))
  s = [input() for i in range(h)]
  for i in range(0,h):
    for j in range(0,w):
      if s[i][j]=='#':
        print('#',end="")
      else:
        count=0
        for k in range(i-1,i+2):
          if k>=0 and k<h:
            for l in range(j-1,j+2):
              if l>=0 and l<w and s[k][l]=='#':
                count+=1
        print(count,end="")
    print()
    
main()

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
const int N=1e5;
typedef long long ll;
ll nOO  = -1e15 ;
int A[N],n,x,y,z,cnt;
ll mem[N][2];
ll solve(int idx,bool nega){
    if(idx==n-1) return (nega)? -A[idx] : A[idx];
    if(idx==n) return 0;
    if(mem[idx][nega]!=-1) return mem[idx][nega];
    ll v=A[idx];
    if(nega) v*=-1;
    ll op1 = v+ solve(idx+1,0);
    ll op2 = -v  + solve(idx+1,1);
    return mem[idx][nega] = max(op1,op2);

}
int main(){
    memset(mem,-1,sizeof mem);
    scanf("%d",&n);
    for( int i = 0 ; i < n; ++i )
        scanf("%d",A+i);
    printf("%lld\n",solve(0,0));
    return 0;
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::vector<lint>a(n);
    for(lint&x:a)std::cin>>x;
    lint ans=0;
    for(lint i=0,j=1;j<=n;j++){
        if(j!=n&&a.at(j-1)==a.at(j))continue;
        ans+=(j-i)/2;
        i=j;
    }
    std::cout<<ans<<'\n';
}


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

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int r = readint;
    if (r < 1200) writeln("ABC");
    else if (r < 2800) writeln("ARC");
    else writeln("AGC");
}

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

int max_happy(vector < vector<int> > &input, int n, int i, int j, vector < vector<int> > &output);
int max_happy(vector < vector<int> > &input, int n, int i, int j, vector < vector<int> > &output) {

    if (i == n)
      return input[i][j];
    if (output[i][j] != -1)
      return output[i][j];
    output[i][j] = input[i][j] + max(max_happy(input, n, i+1, (j+1)%3, output),max_happy(input, n, i+1, (j+2)%3, output));
    return output[i][j];
}

int main()
{
    int n;
    scanf("%d", &n);
    vector < vector<int> > input(n);
    vector < vector<int> > output(n);
    for(auto &x: input)            
      x = vector<int> (3);
    for(auto &x: output)            
      x = vector<int> (3);
    for(auto &i: input)
      for (auto &j: i)
        scanf("%d", &j);
    for(auto &i: output)
      for (auto &j: i)
        j = -1;
    int x = max_happy(input, n-1, 0, 0, output);
    int y = max_happy(input, n-1, 0, 1, output);
    int z = max_happy(input, n-1, 0, 2, output);
    
    cout << max(x,max(y,z))<<endl;
    return 0;
    
}

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

int main(){
  int n;
  cin >> n;
  vector<long long> cnt(5, 0);
  string temp;
  for(int i = 0; i < n; ++i){
    cin >> temp;
    if(temp[0] == 'M') cnt[0]++; 
    else if(temp[0] == 'A') cnt[1]++; 
    else if(temp[0] == 'R') cnt[2]++; 
    else if(temp[0] == 'C') cnt[3]++; 
    else if(temp[0] == 'H') cnt[4]++; 
  }
  long long ans = 0;
  for(int i = 0; i < 5; ++i){
    for(int j = i + 1; j < 5; ++j){
      for(int k = j + 1; k < 5; ++k){
        ans += cnt[i] * cnt[j] * cnt[k];
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define min(a, b) ((a)<(b) ? (a) : (b))

int main(){
  int A, B, M;  scanf("%d%d%d", &A, &B, &M);
  int a[100002], b[100002];
  int amin = 100000, bmin = 100000;
  for(int i=1; i<=A; i++){
    scanf("%d", &a[i]);
    amin = min(amin, a[i]);
  }
  for(int i=1; i<=B; i++){
    scanf("%d", &b[i]);
    bmin = min(bmin, b[i]);
  }
  long long int ans = (long long int)amin + (long long int)bmin;
  for(int i=0; i<M; i++){
    int x, y, c;
    scanf("%d%d%d", &x, &y, &c);
    ans = min(ans, a[x]+b[y]-c);
  }

  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define inf 100000000000
#define int long long int
#define hell (int)(1e9+7)

using namespace std;

void solve(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            int g=__gcd(i,j);
            for(int k=1;k<=n;k++)
                ans+=__gcd(g,k);
        }
    }
    cout<<ans;
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << "\n\n"
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      cout << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

/* mint、表示は変数名.x */
struct mint {
  ll x;
  mint(ll x = 0) : x((x % MOD + MOD) % MOD) {
  }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  /* 変数名.pow(n) */
  mint pow(ll t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // 以降はMODが素数のみ
  mint inv() const {
    return pow(MOD - 2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

signed main() {
  int N;
  cin >> N;
  string S;
  cin >> S;

  map<char, ll> m;
  rep(i, N) {
    m[S[i]]++;
  }

  mint ans=1;
  for (auto item : m) {
    auto Fi = item.fi;
    auto Se = item.se;
    ans*=(Se+1);
  }
  ans-=1;

  cout << ans.x << "\n";
}

Measured memory_bytes: 512
#ifndef bhartiya
    // #pragma GCC optimize("Ofast")
    // #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#ifdef bhartiya
#define endl '\n'
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


#define pb push_back
#define bitc  __builtin_popcountl
#define mp make_pair
#define ff first
#define ss second

#define swap(a,b) {a=a^b;b=a^b;a=a^b;}
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define inf 200000000000000ll
// #define inf 10000000000ll
#define mod 1000000007ll
// #define mod 998244353ll
#define eps 1e-7

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

const ll maxn = 212345;
// ll n;
ll a[maxn];
ll b[maxn];


int main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.precision(10);
    // cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
        ll n;
        cin>>n;
        rep(i,n){
            cin>>a[i];
            b[i]= inf;
        }
        b[0] = 0;
        rep(i,n-2){
            b[i+1] = min(b[i+1], b[i]+abs(a[i+1]-a[i]));
            b[i+2] = min(b[i+2], b[i]+abs(a[i+2]-a[i]));
        }
        b[n-1] = min(b[n-1], b[n-2]+abs(a[n-2]-a[n-1]));
        cout<<b[n-1];
    }
}

Measured memory_bytes: 1792
def func(n):
    if n%2 == 0:
        return n//2
    else:
        return 3*n+1

a = [0,int(input())]

for i in range(2,10**6):
    x = func(a[i-1])
    if x in a:
        print(i)
        break
    else:
        a.append(x)


Measured memory_bytes: 2940
use std::cmp::{max, min};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{stdin, Read};
use std::os::raw::{c_double, c_float};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let mut v = (0..n).map(|_| read::<u64>()).collect::<Vec<_>>();
    v.sort();
    let mut x = v[0] as f64;
    for i in 1..n {
        x = (x + v[i] as f64) / 2.0;
    }
    println!("{}", x);
}


Measured memory_bytes: 4352
//https://atcoder.jp/contests/arc069/tasks/arc069_d

#include<bits/stdc++.h>
const int M = 205;
const int N = 5005;
using namespace std;

stack <int> ms[M];
int n, m, b[N][M];
long long it[N << 2], lz[N << 2], a[N], ans;

void dolazy(int i, int l, int r){
    if (l != r){
        lz[i << 1] += lz[i];
        lz[i << 1 | 1] += lz[i];
    }
    it[i] += lz[i]; lz[i] = 0;
}

void update(int i, int l, int r, int L, int R, long long val){
    dolazy(i, l, r);
    if (L > r || l > R) return;
    if (L <= l && r <= R){
        lz[i] = val;
        dolazy(i, l, r);
        return;
    }
    int mid = (l + r) >> 1;
    update(i << 1, l, mid, L, R, val); update(i << 1 | 1, mid+1, r, L, R, val);
    it[i] = max(it[i << 1], it[i << 1 | 1]);
}

long long get(int i, int l, int r, int L, int R){
    dolazy(i, l, r);
    if (L > r || l > R) return (long long)(-1e18);
    if (L <= l && r <= R) return it[i];
    int mid = (l + r) >> 1;
    return max(get(i << 1, l, mid, L, R), get(i << 1 | 1, mid+1, r, L, R));
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 2; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> b[i][j];
    for (int i = 1; i <= n; i++){
        a[i] += a[i-1];
        update(1, 1, n, i, i, a[i]);
    }
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            update(1, 1, n, i, i, b[i][j]);
            while (ms[j].size() && b[ms[j].top()][j] < b[i][j]){
                int r = ms[j].top(), val = b[ms[j].top()][j];
                ms[j].pop();
                int l = (ms[j].size() ? ms[j].top() : 0);
                update(1, 1, n, l+1, r, b[i][j] - val);
            }
            ms[j].push(i);
        }
        ans = max(ans, get(1, 1, n, 1, i) - a[i]);
    }
    cout << ans;
}


Measured memory_bytes: 4736
from collections import deque
N = int(input())
ad_ls = [[] for _ in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    ad_ls[a].append(b)
    ad_ls[b].append(a)
c_ls = list(map(int, input().split()))
c_ls.sort(reverse=True)
c_q = deque(c_ls)

# d_ls[i] := 0idxでi番目の頂点に書く数字
d_ls = [0] * N

q = deque()
q.append(0)
d_ls[0] = c_q.popleft()
while q:
    now = q.popleft()
    for nex in ad_ls[now]:
        if d_ls[nex] == 0:
            d_ls[nex] = c_q.popleft()
            q.append(nex)

print(sum(c_ls) - max(c_ls))
print(*d_ls)

Measured memory_bytes: 77068
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T &a, T b){if(a > b){ a = b; return 1;}return 0;}
const long long INF = 1LL << 60;

int main(){
  int N, K; cin >> N >> K;
  vector<long long> h(1e7), dp(1e7);
  for(int i = 1; i <= N; i++){
    cin >> h[i];
    dp[i] = INF;
  }
  dp[1] = 0;
  for(int i = 1; i <= N; i++){
    for(int k = 1; k <= K; k++){
      chmin(dp[i + k], dp[i] + abs(h[i] - h[i + k]));
    }
  }
  cout << dp[N] << endl;
}
  

Measured memory_bytes: 156544
#include <iostream>
#include <deque>

using namespace std;
deque<char> que;
int main(){
	string s;
	int i,q,n,muki = 1;
	cin >> s >> q;
	n = s.size();
	for(i=0;i<n;i++){
		que.push_back(s[i]);
	}
	for(i=0;i<q;i++){
		int t; cin >> t;
		if(t==1){
			muki *= -1;
		}
		if(t==2){
			int f; char c;
			cin >> f >> c;
			if(f==1){
				if(muki==1){
					que.push_front(c);
				}else{
					que.push_back(c);
				}
			}
			if(f==2){
				if(muki==1){
					que.push_back(c);
				}else{
					que.push_front(c);
				}
			}
		}
	}
	if(muki==1){
		for(i=0;i<que.size();i++){
			cout << que[i];
		}
	}else{
		for(i=que.size() - 1;i>=0;i--){
			cout << que[i];
		}
	}
	cout << endl;
}

Measured memory_bytes: 1024
#ifdef OJ_MISC_OFFLINE

#include "prolog.h"

#else
#define LOG
#define PRINT
#define LCERR
#include <iostream>
auto optimize_cpp_stdio = []() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::setvbuf(stdout, nullptr, _IOFBF, BUFSIZ);
    return 0;
}();
#endif

#include <algorithm>
#include <array>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

namespace {

using namespace std;

int solve() {
    // handle IO here
    int A, B;
    cin >> A >> B;
    if (A != 0 && B % A == 0) {
        cout << A + B << '\n';
    } else {
        cout << B - A << '\n';
    }
    return 0;
}

} // anonymous namespace

#ifdef OJ_MISC_OFFLINE

#include "epilog.h"

#else

int main() {
    return solve();
}

#endif


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    cout << "ABC" << N << endl;
    return 0;
}


Measured memory_bytes: 3576
/*
    Author: Anthony Ngene
    Created: 19/09/2020 - 13:04
*/

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        boolean isValid = false;
        int count = 0;
        for (int i = 0; i < n; i++) {
            int a = in.nextInt(), b = in.nextInt();
            if (a == b) {
                count++;
                if (count >= 3)
                    isValid = true;
            } else {
                count = 0;
            }
        }
        System.out.println(isValid ? "Yes" : "No");
    }
}


Measured memory_bytes: 35532
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    int N;
    cin >> N;
    int num;
    for(int i = 0; i < N; i ++){
        int a;
        cin >> a;
        if(a%2 != 0){
            break;
        }
        num++;
    }
    
    if(num == N){
        cout << "second" << endl;
        
    }else{
        cout << "first" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define VIN(n,v) for(int64_t i=0;i<(n);i++){cin >> (v).at(i);}

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  I n, k;
  cin >> n >> k;
  double t=0;
  REP(i,n+1){
    if (i >= k){
      t += 1.0 / n;
    }else{
      I cnt = i;
      while (i > 0){
        if (cnt >= k){
          t += 1.0 / (cnt*n/i);
          break;
        }else{
          cnt *= 2;
        }
      }
    }
  }

  cout << setprecision(11) << t << endl;
  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int N,A[100],i,j,minj,x,count=0;
  scanf("%d",&N);
  for(i=0; i<N; i++){
    scanf("%d",&A[i]);
  }

  for(i=0; i<=N-1; i++){
    minj=i;
    for(j=i; j<=N-1; j++){
      if(A[j]<A[minj]){
	 minj=j;
      }
    }
    if(i!=minj){
        x=A[i];
        A[i]=A[minj];
        A[minj]=x;
        count++;
    }
  }

  for(i=0; i<N-1; i++){
    printf("%d ",A[i]);
  }
  printf("%d",A[N-1]);
  printf("\n");
  printf("%d\n",count);
  return 0; 
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define int 	long long

int n;
int aa[300005];
pair<int, int> dp[300005];

#define x first
#define y second

void update(pair<int, int> &a, int val) {
	if (a.y == val || a.x == val) return;
	if (a.y == -1 || aa[a.y] <= aa[val]) {
		if ((a.x == -1 || aa[a.x] <= aa[val]) && a.x != val) {
			a.y = a.x;
			a.x = val;
		}
		else {
			a.y = val;
		}
	}
}

void update2(pair<int, int> &a, pair<int, int> b) {
	update(a, b.x);
	update(a, b.y);
}

signed main() {
	scanf("%lld", &n);
	for (int i = 0; i < (1<<n); i++) {
		scanf("%lld", &aa[i]);
	}
	memset(dp, -1, sizeof(dp));
	for (int i = 0; i < (1 << n); i++) {
		update(dp[i], i);
	}
	int mi = aa[0];
	for (int i = 0; i < (1 << n); i++) {
		for (int j = 0; j < n; j++) {
			if (i & (1 << j)) {
				update2(dp[i], dp[i - (1 << j)]);
			}
		}
	}
	for (int i = 1; i < (1 << n); i++) {
		mi = max(aa[dp[i].x] + aa[dp[i].y], mi);
		cout << mi << "\n";
	}
}

Measured memory_bytes: 9856
let id x = x

let rec num_of_area n = 
  if n = 1 then 2
  else n + num_of_area (n - 1)
                       
let _ =
  try
    while true do
      let x = Scanf.scanf "%d\n" id in
      Printf.printf "%d\n" (num_of_area x)
    done
  with
    End_of_file -> ()

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  int n, a, b; cin >> n >> a >> b;
  cout << min(n * a, b) << endl;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef pair<int,int> P;
string l[50];
string r[50];
int w,h;
deque<pair<P,P>> q;
bool used[50][50][50][50];//L,Rの順
int main()
{
	int dx[4]={1,0,-1,0};
	int dy[2][4]={{0,-1,0,1},{0,1,0,-1}};
	while(1)
	{
		cin>>w>>h;
		if(h==0)
			break;
		for(int i=0;i<h;i++)
			cin>>l[i]>>r[i];
		q.clear();
		//初期位置を突っ込む
		P p1,p2;
		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)
			{
				if(l[i][j]=='L')
					p1=P(i,j);
				if(r[i][j]=='R')
					p2=P(i,j);
			}
		}
		fill(used[0][0][0],used[50][0][0],false);
		q.push_back(make_pair(p1,p2));
		used[p1.first][p1.second][p2.first][p2.second]=true;
		//BFS
		bool ans=false;
		while(!q.empty())
		{
			auto t=q.back();q.pop_back();
			p1=t.first; p2=t.second;
			if(l[p1.first][p1.second]=='%' && r[p2.first][p2.second]=='%')
			{
				ans=true;
				break;
			}else if(l[p1.first][p1.second]=='%' || r[p2.first][p2.second]=='%'){
				continue;
			}
			//上下左右探す
			for(int i=0;i<4;i++)
			{
				int nx[2]={p1.first+dx[i],p2.first+dx[i]};
				int ny[2]={p1.second+dy[0][i],p2.second+dy[1][i]};
				//壁あるいは進行不可能なものは補正する
				//進行不能を調べる
				for(int j=0;j<2;j++)
				{
					if(nx[j]<0)
						nx[j]=0;
					else if(nx[j]>=h)
						nx[j]=h-1;
					if(ny[j]<0)
						ny[j]=0;
					else if(ny[j]>=w)
						ny[j]=w-1;
				}
				//壁を調べる
				if(l[nx[0]][ny[0]]=='#')
				{
					nx[0]-=dx[i];
					ny[0]-=dy[0][i];
				}
				if(r[nx[1]][ny[1]]=='#')
				{
					nx[1]-=dx[i];
					ny[1]-=dy[1][i];
				}
				if(!used[nx[0]][ny[0]][nx[1]][ny[1]])
				{
					used[nx[0]][ny[0]][nx[1]][ny[1]]=true;
					q.push_front(make_pair(P(nx[0],ny[0]),P(nx[1],ny[1])));
				}
			}
		}
		if(ans)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 10052
#include<bits/stdc++.h>
#define ll long long
#define MAX 1e9+7
#define MIN -MAX
#define i(a) cin>>a
#define in(a,b) cin>>a>>b
#define o(a) cout<<a
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loop1(i,a,b) for(ll i=a;i<=b;i++)
#define v(a) vector<ll>a
#define mp(a,b) make_pair(a,b)
using namespace std;
int main()
{
    ll a,b,max1;
    cin>>a>>b;
    max1 = max(a+b,a-b);
    cout<<max(max1,a*b);


         /*for(ll i=1;i<=n;i++){
        cout<<dp[i]<<" ";
    }*/
    //cout << dp[n] <<"\n";

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {
    int n; cin >> n;
    ll ans = 1;
    int a[1001] = {0};
    for (int i = 2; i <= n; ++i) { //n!
        int t = 2, k = i;
        while (k != 1) {
            while (k % t == 0) {
                a[t]++;
                k /= t;
            }
            t++;
        }
    }
    for (int i = 2; i <= 997; ++i) ans = ans * (a[i] + 1) % (long long)(1e9 + 7);
    cout << ans << endl;
}


Measured memory_bytes: 256
<?php
$input_line = trim(fgets(STDIN));
$s = explode(" ", $input_line);
$num = $s[0];
$sum = $s[1];

for ($i = 0; $i <= $num; $i++) {
	$num_10000 = 10000 * $i;
  	for ($j = 0; $j <= ($num - $i); $j++) {
    	$num_5000 = 5000 * $j;
      	$k = ($num - $i - $j);
      	$num_1000 = 1000 * $k;
      	$result = $num_10000 + $num_5000 + $num_1000;
      	if ($sum == $result) {
          	echo $i." ".$j." ".$k;
        	break 2;
        }
    }
  	if ($num == $i) {
    	echo "-1"." "."-1"." "."-1";
    }
}
?>

Measured memory_bytes: 3704
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 2248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)

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

const int MAXN = 1e5+2; //AREGLAAAAAAAAR!!!!
int a[2034];
int main(){
	int n;
	ri(n);
	FOR(i,0,n) ri(a[i]);
	sort(a,a+n);
	int ans=1,ant=a[0];
	FOR(i,1,n){
		if(a[i]>ant){
			ans++;
			ant=a[i];
		}
	}
	printf("%d\n",ans);
}
	

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

int main() {
    int a;
  
 
   cin >> a;
  
  if (a < 1200){
    
    
     cout << "ABC" << endl;
    
  }else{
    
    cout << "ARC" << endl;
    
  }
  
  
  
  
  return 0;
}


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

int main(){
  int c[3][3];
  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      cin >> c[i][j];
    }
  }

  int flg=1;
  for (int i = 0; i < 3; i++)
  {
    if(!(c[i][0]-c[(i+1)%3][0]==c[i][1]-c[(i+1)%3][1] && c[i][0]-c[(i+1)%3][0]==c[i][2]-c[(i+1)%3][2])) flg=0;
  }
  for (int i = 0; i < 3; i++)
  {
    if(!(c[0][i]-c[0][(i+1)%3]==c[1][i]-c[1][(i+1)%3] && c[0][i]-c[0][(i+1)%3]==c[2][i]-c[2][(i+1)%3])) flg=0;
  }
  if (flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    sm = sum(a)%mod
    ans = (sm**2)%mod
    for i in a:
        ans -= i**2
        ans %= mod

    print((ans*500000004)%mod)

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 95360
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define For(i,l,r) for(res i=(l),_=(r);i<=_;++i)
#define Dor(i,l,r) for(res i=(r),_=(l);i>=_;--i)
#define Sor(i,l,r) for(res i=(l),_=(r);i<_;++i)
#define fz(a,b) memset(a,b,sizeof a)
#define qd(a) while(!a.empty())a.pop()
#define JB(a,b)(T[++t]=b,E[t]=H[a],H[a]=t)
#define ll long long
#define N 100001
#define M 1000000007
int main() {
	int a;
	cin>>a;
	cout<<1ll*a*(a-1)/2;
}

Measured memory_bytes: 256
import collections

def prime_fact_counts(n):
    c = collections.Counter(prime_factorize(n))
    return c.values()


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


n = int(input())
count = 0
for x in prime_fact_counts(n):
    for i in range(1, x + 1):
        if x >= i:
            x -= i
            count += 1
        else:
            break
print(count)

Measured memory_bytes: 9356
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	int P, Q, R;
	cin >> P >> Q >> R;
	cout << P + Q + R - max(P, max(Q, R)) << endl;

//"Hiroakimm0415"

	return 0;
}

Measured memory_bytes: 256
r,c = map(int,input().split())
num_list = []

for i in range(r):
    num_list.append(list(map(int,input().split())))
    num_list[i].append(sum(num_list[i]))

col_sum_list = [0]*(c+1)
for i in range(c+1):
    for j in range(r):
        col_sum_list[i] += num_list[j][i]

num_list.append(col_sum_list)
for num in num_list:
    ans = [str(chrs) for chrs in num]
    print(' '.join(ans))


Measured memory_bytes: 5716
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int dp1[3005][3005];
int dp2[3005][3005];

int main() {
    int n, t; cin >> n >> t;
    vint a(n), b(n);
    rep(i,n) cin >> a[i] >> b[i];
    rep(i,n)rep(j,3005) {
        chmax(dp1[i+1][j],dp1[i][j]);
        if (j-a[i] >= 0) chmax(dp1[i+1][j],dp1[i][j-a[i]]+b[i]);
    }
    rep(i,n)rep(j,3005) {
        chmax(dp2[i+1][j],dp2[i][j]);
        if (j-a[n-i-1] >= 0) chmax(dp2[i+1][j],dp2[i][j-a[n-i-1]]+b[n-i-1]);
    }
    int ans = 0;
    rep(i,n) {
        rep(j,t) ans = max(ans,dp1[i][j]+dp2[n-i-1][t-1-j]+b[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 70784
#include <stdio.h>
 
#define AMAX 20
#define MIMAX 2000

int main(){

  int i, j;
  int n, q, num;
  int one[MIMAX+1] = {0};

  scanf("%d", &n);
  for (i = 0; i < n; i++){
    scanf("%d", &num);
    for(j = MIMAX-num; 0 < j; j--){
      if(one[j]){
        one[j+num] = 1;
      }
    }
    one[num] = 1;
  }

  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf("%d", &num);
    if(one[num]){
      printf("yes\n");
    }
    else printf("no\n");
  }

  return 0;
}

Measured memory_bytes: 588
from collections import Counter

N, T, *A = map(int, open(0).read().split())

mi = A[0]
ma = 0

B = Counter()
for a in A[1:]:
    b = a - mi
    B[b] += 1
    ma = max(ma, b)
    mi = min(mi, a)

print(B[ma])


Measured memory_bytes: 21600