akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define smax(a, b) ((a) < (b) ? ((a)=(b), true) : false)
#define smin(a, b) ((a) > (b) ? ((a)=(b), true) : false)
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;
typedef long long ll;

int n, w;
ll dp[100001][100];
ll item[101][2];
int main() {
    cin >> n >> w;
    for(int i = 1; i <= n; i++)
    {
        cin >> item[i][1] >> item[i][0];
    }
    for(int i = 0; i <= w; i++)
    {
        for(int j = 0; j <= n; j++)
        {
            dp[i][j] = -1;
        }
    }

    dp[0][0] = 0;

    for(int i = 1; i <= n; i++)
    {
        for(int j = 0; j <= w; j++) {
            dp[j][i] = dp[j][i-1];
        }
        for(int j = 0; j <= w; j++)
        {
            if(dp[j][i-1] != -1 && (j + item[i][1]) <= w)
            {
                dp[j + item[i][1]][i] = max(dp[j + item[i][1]][i], dp[j][i-1] + item[i][0]);
            }
        }
    }

    ll ans = 0;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 0; j <= w; j++)
        {
            //cout << dp[j][i] << ' ';
            ans = max(ans, dp[j][i]);
        }
        //cout << endl;
    }
    cout << ans << endl;
}

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

const int N = 1e5 + 5;
int n, l[N], r[N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		cin >> l[i] >> r[i];
	}
	sort(l + 1, l + n + 1);
	sort(r + 1, r + n + 1);
	reverse(l + 1, l + n + 1);
	long long tp = 0, fp = 0;
	for(int i = 1; i <= n; ++i) {
		tp += 2 * l[i];
		tp -= 2 * r[i];
		//
		if(r[i] > 0) {
			fp = max(fp, tp + 2 * r[i]);
		} else {
			fp = max(fp, tp);
		}
		//
		if(l[i] < 0) {
			fp = max(fp, tp - 2 * l[i]);
		} else {
			fp = max(fp, tp);
		}
	}
	cout << fp << endl;
	return 0;
}


Measured memory_bytes: 1024
def main():
    l = []
    l.append(list753from(3))
    l.append(list753from(5))
    l.append(list753from(7))
    flatten = lambda x: [z for y in x for z in (flatten(y) if hasattr(y, '__iter__') and not isinstance(y, str) else (y,))]
    l = flatten(l)
    #print(l)
    #print(len(l))
    print(len(list(filter(lambda x: ('3' in str(x)) & ('5' in str(x)) & ('7' in str(x)), l))))

def list753from(n):
    ret = []
    if n>N:
        return ret
    ret.append(n)
    a = list753from(int(str(n)+"3"))
    if a==[]:
        pass
    else:
        ret.append(a)

    a = list753from(int(str(n)+"5"))
    if a==[]:
        pass
    else:
        ret.append(a)

    a = list753from(int(str(n)+"7"))
    if a==[]:
        pass
    else:
        ret.append(a)

    return ret
    #print("-----")
    #print(n)

if __name__ == '__main__':
    N = int(input())
    main()

Measured memory_bytes: 7704
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
const int maxn=1e5+5;
int fa[maxn],cnt[maxn];
vector<int>vec[maxn],vec1[maxn];//存放直接朋友的
int find(int x){
	if(x==fa[x])return x;
	else return fa[x]=find(fa[x]);
}
void Merge(int x,int y){
	 int xx=find(x);
	 int yy=find(y);
	 if(xx!=yy){
	 	fa[xx]=yy;
	 }
	 return ;
}
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++){
		fa[i]=i;
	}
	int xx,yy;
	while(m--){
         scanf("%d%d",&xx,&yy);
         Merge(xx,yy);
         vec[xx].push_back(yy);
         vec[yy].push_back(xx);
	}
	while(k--){
		scanf("%d%d",&xx,&yy);
		if(find(xx)==find(yy)){
			vec1[xx].push_back(yy);
			vec1[yy].push_back(xx);
		}
	}
	for(int i=1;i<=n;i++){
		cnt[find(i)]++;
	}
	for(int i=1;i<=n;i++){
		cout<<cnt[find(i)]-vec[i].size()-vec1[i].size()-1<<" ";
	}
	return 0;
}

Measured memory_bytes: 12920
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define F first
#define S second
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;
ll vis[N],res[N];

int solve() 
{
	//happy coding

	string s[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

	string a;
	cin>>a;
	for(int i=0;i<7;i++){
		if(a == s[i]){
			cout<<7-i<<endl;
			return
			 0;
		}
	}

	
	return 0;
}
int main(){
	int test = 1;
  	//scanf("%d", &test);
  	while (test--)solve();return 0;
}

Measured memory_bytes: 3480
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
	long mon;
	int m,n,i,j,k,y,te,th;
	double rate;

	cin >> m;
	for(i=0;i<m;i++){
		vector<int> kekka;
		cin >> mon >> y >> n;
		for(j=0;j<n;j++){
			cin >> th >> rate >> te;
			if(th==1){
				long A=mon;
				int B =0;
				for(k=0;k<y;k++){
					B = (int)(A*rate);
					A = A + B - te;
				}
				kekka.push_back(A);
			}else{
				long A=mon;
				int B =0;
				for(k=0;k<y;k++){
					B += (int)(A*rate);
					A -= te;;
				}
				kekka.push_back(A+B);
			}
		}
		sort(kekka.begin(),kekka.end());

		cout << kekka[kekka.size()-1] <<endl;

	}

	return 0;
}

Measured memory_bytes: 1260
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>
#include<utility>

using ULLI = unsigned long long int;
using LLI = long long int;

using namespace std;

template<class T>
class ModCal{
private:
    const ULLI MAX = 1000000;
    ULLI mod;

    std::vector<T> fac;
    std::vector<T> finv;
    std::vector<T> inv;

    void COMinit() {
        fac.resize(MAX);
        finv.resize(MAX);
        inv.resize(MAX);

        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;
        }
    }
public:
    ModCal(ULLI _mod){
        this->mod = _mod;
        ModCal<T>::COMinit();
    }
    ModCal(){
        this->mod = 0;
    }

    T add(T a, T b){
        T tmp;
        tmp = a + b;
        if(mod != 0) tmp %= mod;
        return tmp;
    }

    T sub(T a, T b){
        T tmp;
        tmp = a - b;
        if(mod != 0){
            if(tmp < 0) tmp += mod;
            tmp %= mod;
        }
        return tmp;
    }

    T mul(T a, T b){
        T tmp;
        tmp = a * b;
        if(mod != 0) tmp %= mod;
        return tmp;
    }

    T modinv(T a, T m){
        T b = m, u = 1, v = 0;
        while (b) {
            T t = a / b;
            a -= t * b; std::swap(a, b);
            u -= t * v; std::swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }

    T div(T a, T b){
        if(mod == 0){
            return a / b;
        }
        a %= mod;
        T tmp = a * ModCal<T>::modinv(b, mod) % mod;
        return tmp;
    }

    T pow(T a, T b){
        T tmp = 1;
        while(b > 0){
            if(mod != 0){
                if(b & 1) tmp = tmp * a % mod;
                a = a * a % mod;
            }else{
                if(b & 1) tmp *= a;
                a *= a;
            }
            b >>= 1;
        }
        return tmp;
    }

    // 以下の関数はMODを設定しない限り使えない
    // 無理やり使う場合は "ModCal<T> cal(Tの最大値)" でオブジェクトを作る
    T com(T n, T k){
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    }

    T fact(T n){
        return fac[n];
    }
};

int main(){
    ULLI X,Y;
    cin >> X >> Y;

    ModCal<ULLI> mod(1000000007);

    if((X+Y)%3!=0){
        cout << 0 << endl;
        return 0;
    }

    ULLI tmp = (X+Y)/3;
    if(X>=tmp && Y>=tmp){
        cout << mod.com(tmp, X-tmp) << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}



Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long A,B,N,p,q;
	cin>>A>>B>>N;
	if(A%N == 0)
		p=A/N;
	else
		p=A/N+1;
	   q=B/N;
	cout<<q-p+1<<endl;
	return 0;
}


Measured memory_bytes: 256
package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	as := make([]int, n)

	for i := 0; i < n; i++ {
		as[i] = nextInt()
	}
	sort.Sort(sort.Reverse(sort.IntSlice(as)))

	s := 0
	for i, a := range as {
		if i%2 == 0 {
			s += a
		} else {
			s -= a
		}
	}
	fmt.Println(s)
}

func nextInt() int {
	i, err := strconv.Atoi(nextWord())
	pnc(err)
	return i
}

func nextWord() string {
	sc.Scan()
	return sc.Text()
}

func pnc(err error) {
	if err != nil {
		panic(err)
	}
}


Measured memory_bytes: 1776
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll n=in(),m=in();
    string ans(n,'\0');
    for(int i=0;i<m;++i){
        ll s=in()-1;
        char c='0'+in();
        if(ans[s]=='\0'){
            ans[s]=c;
        }else if(ans[s]!=c){
            cout<<-1<<endl;
            return 0;
        }
    }

    if(ans[0]=='0'){
        cout<<(n==1?0:-1)<<endl;
        return 0;
    }

    if(ans[0]=='\0')ans[0]=n==1?'0':'1';
    for(int i=0;i<n;++i)cout<<(ans[i]=='\0'?'0':ans[i]);
    cout<<endl;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc048/tasks/abc048_a
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main()
{
	string a, b, c;
	// string op;
	cin >> a >> b >> c;
	char resrult = b.at(0);
	// cout << resrult;
	cout << "A" << resrult << "C";
}

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


using namespace std;


using ll = long long;


int main() {
    ll K, N;
    cin >> K >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    ll acc = K - A[N - 1] + A[0];
    ll max_len = K - A[N - 1] + A[0];
    for (ll i = 0; i < N - 1; i++) {
        if (A[i + 1] - A[i] > max_len) {
            max_len = A[i + 1] - A[i];
        }
        acc += A[i + 1] - A[i];
    }
    cout << acc - max_len << endl;
}


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

int frogII(vector<int> &arr, int n, int k)
{
    vector<int> dp(n+1, INT_MAX);
    dp[1] = 0;

    for(int i=2; i<=n; i++)
    {
        for(int j=1; j<=k ; j++)
        {
            if(i-j>=1)
            {
                dp[i] = min(dp[i], dp[i-j]+ abs(arr[i-j-1] - arr[i-1]));
            }
            else           
                break;         
        }
    }
    return dp[n];
}

int main()
{
    int n,k;
    vector<int> arr;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        int temp;
        cin>>temp;
        arr.push_back(temp);
    }
    
    cout<<frogII(arr, n, k);
    return 0;
}

Measured memory_bytes: 1144
#include <iostream>
using namespace std;
int main()
{
	double a = 0;
	double b = 0;
	int c = 0;
	int d = 0;
	int e = 0;
	cin >> a; cin >> b; cin >> c; cin >> d; cin >> e;
	if (a < 0 && b <= 0)
	{
		cout << (b - a)* c << endl;
	}
	if (a < 0 && b > 0)
	{
		cout << -a*c + d + e*b << endl;
	}
	if (a > 0 && b > 0)
	{
		cout << (b - a)*e << endl;
	}
	return 0;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

int main(){
    int N,M;
    cin>>N>>M;
    
    int ans = 0;
    int even = 1;
    if(N<2){
        even = 0;
    }else{
        REPD2(i,N,N-1){
            even *= i;
        }
        even /= 2;
    }
    int odd = 1;
    if(M<2){
        odd = 0;
    }else{
        REPD2(i,M,M-1){
            odd *= i;
        }
        odd /= 2;
    }

    cout<<even+odd<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define MAXN 100000

int A[MAXN+1];
int DP[MAXN+1];


int flog (int n, int k)
{
	int i,tmp,j;
	int min;

	DP[1] = 0;

	for ( i = 2; i <= k; i++ ) {
		min = DP[1] + abs(A[1]-A[i]);
		for ( j = 1; j < i; j++ ) {
			tmp = DP[j] + abs(A[i]-A[j]);
			if ( min > tmp ) min = tmp;
		}
		DP[i] = min;
	}

	for ( i = k+1; i <= n; i++ ) {
		min = DP[i-k] + abs(A[i-k]-A[i]);
		for ( j = i-k; j < i; j++ ) {
			tmp = DP[j] + abs(A[j]-A[i]);
			if ( tmp < min ) min = tmp;
		}
		DP[i] = min;
	}

	return DP[n];

}

int main(void)
{
	int i,n,k;

	scanf("%d", &n); scanf("%d", &k);
	for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);

	printf("%d", flog(n,k));

	return 0;
}


Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;

    int park_time;
    int pay_per_use;
    int fix_price;
    int min_price;


    try
    {

      in_stream    = new BufferedReader(new InputStreamReader(System.in));
      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");

      park_time   = Integer.parseInt(in_str_split[0]);
      pay_per_use = Integer.parseInt(in_str_split[1]);
      fix_price   = Integer.parseInt(in_str_split[2]);

      min_price = pay_per_use * park_time;

      if(fix_price < min_price)
      {
        min_price = fix_price;
      }

      UtilLog.ans_ln("" + min_price);
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}

class UtilLog
{
  private static boolean is_debug_mode = false;



  public static void ans_ln
  (
    String i_message
  )
  {
    System.out.println(i_message);
  }



  public static void ans_f
  (
    String i_message
  )
  {
    System.out.printf(i_message);
  }



  public static void inf_ln
  (
    String i_message
  )
  {
    StackTraceElement[] stack;


    if(is_debug_mode)
    {
    stack = new Throwable().getStackTrace();

    System.out.println
      (
        String.format
          (
            "[inf][%s:%s():%5d]",
            stack[1].getClassName(),
            stack[1].getMethodName(),
            stack[1].getLineNumber(),
            i_message
          )
      );
    }
  }
}


Measured memory_bytes: 25044
# coding: utf-8
# Here your code !
ipt = input().split(" ")
j,k =0,0
for i in [ int(i) for i in ipt]:
    if i == 5:
        k += 1
    elif i==7:
        j += 1
#    print(ipt,i,k,j)

if j == 1 and k == 2:
    print("YES")
else:
    print("NO")

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

class UnionFind{
private:
  vector<ll> Parent; 
 public:
  UnionFind(ll N){
    Parent = vector<ll>(N, -1);
  }
  
  ll root(ll A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  ll size(ll A){
    return -Parent[root(A)]; 
  }
  
  bool connect(ll A, ll B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(ll A, ll B){
    return root(A) == root(B);
  }
};


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  vll p(n);
  rep(i,n){
    cin>>p[i]; p[i]--;
  }
  UnionFind uf(n);
  rep(i,m){
    ll x,y; cin>>x>>y; x--,y--;
    uf.connect(x,y);
  }
  ll ans=0;
  vb check(n);
  rep(i,n){
    if(check[p[p[i]]]) continue;
    if(uf.isSame(p[i],p[p[i]])){
      check[p[p[i]]]=true;
      ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define pb push_back
#define sf scanf
#define pf printf
using namespace std;
#define ll long long
const int N=1e5+9;
const ll mod=1e9+7;
void slv()
{
    vector<ll>v,v1;
    ll n,x,y;
    cin >> n ;
    while (n--)
    {
        cin >> x >> y;
        v.push_back(x+y);
        v1.push_back(x-y);
    }
    sort(v.begin(),v.end());
    sort(v1.begin(),v1.end());
    cout<<max(v.back()-v[0],v1.back()-v1[0])<<endl;
}
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int t;
    t=1;
    while (t--)
    {
        slv();
    }
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
#define PINT pair<int,int>
#define f1 first
#define s2 second
const int INF = 1e9 + 7;

using namespace std;

int main(){
    cin.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<PINT> red(n),blue(n);
    REP(i,n) cin >> red[i].f1 >> red[i].s2;
    REP(i,n) cin >> blue[i].f1 >> blue[i].s2;
    sort(red.begin(),red.end());
    sort(blue.begin(),blue.end());
    vector<bool> jud(n,false);
    int ans=0;
    REP(i,n){
        int max;
        bool flg=false;
        for(int j=0;j<n;++j){
            if(jud[j]) continue;
            else{
                //cout << blue[i].f1 << ":" << red[j].f1 << endl;
                if(red[j].f1<blue[i].f1 && red[j].s2 < blue[i].s2){
                    if(!flg){
                        max=j;
                        flg=true;
                    }
                    if(red[max].s2 < red[j].s2) max = j;
                }
            }
        }
        if(flg){
            jud[max] = true;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N; cin >> N;
  vector<int> a(N);
  REP(i, N) {
    cin >> a[i];
    a[i]--;
  }

  int ans = 0;
  REP(i, N) {
    if (a[i] != -1 && i == a[a[i]]) {
      ans++;
      a[i] = -1;
    }
  }
  cout << ans << endl;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> P(M),n(N,1);
  vector<int64_t> Y(M);
  vector< pair<int,int64_t> >py(M);
  vector< map<int64_t,int> > vm(N);
  for(int i=0;i<M;i++){
    cin >> P.at(i) >> Y.at(i);
    py.at(i)=make_pair(P.at(i),Y.at(i));
  }
  sort(py.begin(),py.end());
  for(int i=0;i<M;i++){
    vm.at(py.at(i).first-1)[py.at(i).second]=n.at(py.at(i).first-1);
    n.at(py.at(i).first-1)++;
  }
  for(int i=0;i<M;i++){
    printf("%06d%06d\n",P.at(i),vm.at(P.at(i)-1).at(Y.at(i)));
  }
  return 0;
}


Measured memory_bytes: 15616
#include<stdio.h>
using namespace std;

int main(){
    int A,B;
    scanf("%d %d", &A, &B);
    if(A>=13){
        printf("%d\n", B);
    }else if(6<=A && A<=12){
        printf("%d\n", B/2);
    }else if(0<=A && A<=5){
        printf("%d\n", 0);
    }
    return 0;
}

Measured memory_bytes: 128
function Main(input) {
  var N = parseInt(input[0], 10);
  var A = input.slice(1, N + 2).map(a => parseInt(a, 10));
  var B = input.slice(N + 2).map(a => parseInt(a, 10));

  var result = 0;
  var townNum = 0;

  for(var i = 0; i < B.length; i++) {
    if (i > townNum) {
      townNum = i;
    }
    while(B[i] > 0 && townNum < i + 2) {
      if (B[i] > A[townNum]) {
        // 全部倒す
        B[i] -= A[townNum];
        result += A[townNum];
        townNum++;
      } else {
        // 残りが出る
        A[townNum] -= B[i];
        result += B[i];
        B[i] = 0;
      }
    }
  }
  console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));


Measured memory_bytes: 55252
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	const int maxn = 1 << 15;
	vvi dp(4, vi(maxn + 1, 0));
	


	for (int j = 1; j*j <= maxn; ++j) {
		REP(i, 3) {
			if (i == 0) {

				dp[0][j*j] = 1;
			}
			
			REP(k, maxn  - j*j) {
				dp[i + 1][k+1 + j*j] += dp[i][k+1];
			}
		}
	}

	while (1) {
		int n;
		cin >> n;
		if (!n)break;
		int ans = 0;
		REP(i, 4)ans += dp[i][n];
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>


using namespace std;

vector<pair<long, long>> prime_factorization(long n) {
    vector<pair<long, long>> res;

    for (long i = 2; i * i <= n; ++i) {
        if (n % i != 0) {
            continue;
        }

        long ex = 0;

        while (n % i == 0) {
            ex += 1;
            n = n / i;
        }

        res.emplace_back(i, ex);
    }

    if (n != 1) {
        res.emplace_back(n, 1);
    }

    return res;

}


int main() {

    long N, P;
    cin >> N >> P;

    vector<pair<long, long>> vs = prime_factorization(P);

    long result = 1;
    for (auto kv:vs) {
        for (int i = 0; i < kv.second / N; ++i) {
            result = result * (kv.first);
        }
    }
    cout << result << endl;

    return 0;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=3e3+5,MAXlg=__lg(MAXn)+2;
const ll MOD=998244353;
const ll INF=0x3f3f3f3f;

ll dp[MAXn][MAXn];
ll d[MAXn];
int main(){
    IOS();
    ll n,s;
    cin >> n >> s;
    REP1 (i,n) cin >> d[i];
    REP (i,n+1) dp[i][0] = i+1;
    REP1 (i,n) {
        REP1 (j,s) {
            if (j >= d[i]) dp[i][j] = (dp[i-1][j] + dp[i-1][j-d[i]]) % MOD;
            else dp[i][j] = dp[i-1][j];
        }
    }
    ll ans = 0;
    REP1 (i,n) ans = (ans + dp[i][s]) % MOD;
    cout << ans << endl;
}


Measured memory_bytes: 70784
#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>
#include<functional>
#include<cstdio>
#include<cstdlib>
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

const double EPS = 1e-10;

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

int main(){
  int x,n; cin >> x >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int now = INF;
  int ans = -1;
  rep(i,102){
    bool ok = false;
    rep(j,n){
      if(p[j] == i) ok = true;
    }
    if(!ok){
      if(now > abs(i-x)){
        now = abs(i-x);
        ans = i;
      }
    }
  }
  cout << ans << endl;
}


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

int main() {

  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int ans = 0;
  
  for(int i = 0; i <= A; i++){
    for(int j = 0; j <= B; j++){
      for(int k = 0; k <= C; k++){
        if( 500 * i + 100 * j + 50 * k == X ) {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int x=-2*a+b+c, y=a-2*b+c, z=a+b-2*c;
	for(int i=0; ; i++){
		if(x+2*i>=0 && y+2*i>=0 && z+2*i>=0
			&& (x+2*i)%3==0 && (y+2*i)%3==0 && (z+2*i)%3==0){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
//右回りか、左回りか
ll dp_r[100005],dp_l[100005];
ll dp_rb[100005],dp_lb[100005];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N,C;cin>>N>>C;
  ll x1[N],x2[N],v1[N],v2[N];
  FOR(i,0,N)cin>>x1[i]>>v1[i];
  FOR(i,0,N)x2[i]=C-x1[N-i-1];
  FOR(i,0,N)v2[i]=v1[N-i-1];
  ll ans=0;
  ll now=0;
  FOR(i,0,N){
    now+=v1[i];
    dp_l[i+1]=max(dp_l[i],now-x1[i]);
    dp_lb[i+1]=max(dp_lb[i],now-2*x1[i]);
  }
  now=0;
  FOR(i,0,N){
    now+=v2[i];
    dp_r[i+1]=max(dp_r[i],now-x2[i]);
    dp_rb[i+1]=max(dp_rb[i],now-2*x2[i]);
  }
  FOR(i,0,N+1){
    ans=max(ans,max(dp_l[i],dp_r[N-i]));
    ans=max(ans,dp_lb[i]+dp_r[N-i]);
    ans=max(ans,dp_l[i]+dp_rb[N-i]);
  }
  cout<<ans<<endl;
}

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

int main (){
    int a, b, c;
    cin>>a>>b>>c;
    vector<int> Vec(3);
    Vec={a, b, c};
    sort(Vec.begin(), Vec.end());
    cout<<Vec.at(0)+Vec.at(1)<<endl;
    
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    long long int a,b,k;
    
    scanf("%ld %ld %ld",&a,&b,&k);
    if(a>0){
        if(a<=k){k-=a;a=0;}
        else a-=k;
    }
    if(a==0){
        if(b>=k){b-=k;}
        else b=0;
        
    }    
    printf("%ld %ld",a,b);
    
    return 0;
}


Measured memory_bytes: 128
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <queue>
#include <iomanip>
#include <tuple>
#include <unordered_set>
#include <unordered_map>

using namespace std;


int main() {
	int a, b;
	cin >> a >> b;

	int res = a + b;

	res = max(res, a - b);
	res = max(res, a * b);

	cout << res;
}


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

int main(){
    int n; cin >> n;
    double ans = 0;
    for(int i = 0; i < n; i++){
        double mid;cin >> mid;
        ans += 1/mid;
    }
    ans = 1/ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

#約数列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

def is_prime(n):
    if n == 1: return True

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

a,b = inpl()
res = 0
gc = fractions.gcd(a,b)
div = make_divisors(gc)
# print(div)
for i in div:
    if is_prime(i):
        res += 1
print(res)

Measured memory_bytes: 65640
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

int main(){
    int k,a,b;
    cin>>k>>a>>b;
    rep(i,b+2){
        if(k*i>=a&&k*i<=b){
            cout<<"OK";
            return 0;
        }
    }
    cout<<"NG";
    return 0;
}

Measured memory_bytes: 3628
import Control.Monad
import Data.Array.IO
import Data.Array.Unboxed

type Idx = (Int,Int,Int)
type IODp = IOUArray Idx Int

main = do
    [n,a] <- map read.words<$>getLine::IO[Int]
    xs <- map read.words<$>getLine::IO[Int]
    let nx = n * maximum (a:xs)
    dp <- newArray ((0,0,0),(n,n,nx)) 0 :: IO IODp
    mapM_ (f dp) [(j,k,s)|s<-[0..nx],k<-[0..n],j<-zip [0..] (0:xs)]
    print.sum =<< mapM (\k -> readArray dp (n,k,k*a)) [1..n]

f dp ((j,_),0,0) = writeArray dp (j,0,0) 1
f dp ((j,xj),k,s) | j>0, s<xj       = readArray dp (j-1,k,s) >>= writeArray dp (j,k,s)
f dp ((j,xj),k,s) | j>0, k>0, s>=xj = liftM2 (+) (readArray dp (j-1,k,s)) (readArray dp (j-1,k-1,s-xj)) >>= writeArray dp (j,k,s)
f _ _ = return ()

{-
dp(j,k,s) -> [x1..xj]からk集めた合計がsになる総数

dp(*,0,0) = 1
dp(j,k,s) = dp(j-1,k,s)                    , j>=1, s<xj
dp(j,k,s) = dp(j-1,k,s) + dp(j-1,k-1,s-xj) , k>=1, j>=1, s>=xj
other = 0
-}

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

string s;

int oper(int lhs,int rhs,char op){
    if(op=='+'){
        return lhs+rhs;
    }
    if(op=='-'){
        return lhs-rhs;
    }
    if(op=='*'){
        return lhs*rhs;
    }
    if(op=='/'){
        if(rhs==0) throw "0_devision";
        return lhs/rhs;
    }
    assert(false);
    return 0;
}

set<int> calc(vector<int> num,vector<char> op){
    set<int> res;
    if(num.size()==1){
        res.insert(num[0]);
        return res;
    }
    for(int i=0;i<num.size()-1;i++){
        auto nexnum=num;
        auto nexop=op;
        int lhs=num[i];
        int rhs=num[i+1];
        char opc=op[i];
        int val;
        try{
            val=oper(lhs,rhs,opc);
        }catch(const char* ex){
            continue;
        }
        nexnum.erase(nexnum.begin()+i,nexnum.begin()+i+2);
        nexnum.insert(nexnum.begin()+i,val);
        nexop.erase(nexop.begin()+i);
        auto ret=calc(nexnum,nexop);
        res.insert(ret.begin(),ret.end());
    }
    return res;
}

set<int> dfs(int inde,vector<set<int>> &nums,vector<char> &op,vector<int> &num){
    if(inde==nums.size()){
        return calc(num,op);
    }
    set<int> res;
    for(auto &v:nums[inde]){
        num.push_back(v);
        auto ret=dfs(inde+1,nums,op,num);
        res.insert(ret.begin(),ret.end());
        num.pop_back();
    }
    return res;
}

int val(int &p){
    int res=0;
    while(isdigit(s[p])){
        res*=10;
        res+=s[p]-'0';
        p++;
    }
    return res;
}

set<int> expr(int &p){
    vector<set<int>> nums;
    vector<char> op;
    while(true){
        if(isdigit(s[p])){
            set<int> st;
            int v=val(p);
            st.insert(v);
            nums.push_back(st);
        }
        else{
            assert(s[p]=='(');
            p++;
            nums.push_back(expr(p));
            assert(s[p]==')');
            p++;
        }
        if(p==s.size() || s[p]==')') break;
        op.push_back(s[p]);
        p++;
    }
    vector<int> num;
    return dfs(0,nums,op,num);
}

int main(){
    while(cin>>s,s!="#"){
        int p=0;
        cout<<expr(p).size()<<endl;
    }      
    return 0;
}

Measured memory_bytes: 3212
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int dp[MAX+1];

void update_dp(int b, int n){
	int tmp=1;
	while(tmp*b<=n) tmp*=b;
	while(tmp>1){
		for(int i=tmp;i<=n;i++){
			dp[i]=min(dp[i],dp[i-tmp]+1);
		}
		tmp/=b;
	}
}

int main() {
	int n;cin>>n;
	rep(i,n+1) dp[i]=INF;
	dp[0]=0;
	update_dp(9,n);
	update_dp(6,n);
	rep1(i,n) dp[i]=min(dp[i],dp[i-1]+1);
	cout<<dp[n]<<endl;
}


Measured memory_bytes: 640
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> adj[100000];
bool cp[100000];
int a, b, lb = 0, ml;
void dfs1(int c, int p, int l){
	cp[c] = false;
	if (c == b){
		cp[c] = true;
		lb = l;
	}
	for (int i = 0; i < adj[c].size(); i++){
		if (adj[c][i] != p){
			dfs1(adj[c][i], c, l + 1);
			cp[c] = cp[c] || cp[adj[c][i]];
		}
	}
}
void dfs2(int c, int p, int l){
	ml = max(ml, l);
	for (int i = 0; i < adj[c].size(); i++){
		if (adj[c][i] != p){
			dfs2(adj[c][i], c, l + 1);
		}
	}
}
int main(){
	int n, x, y;
	scanf("%d %d %d", &n, &a, &b);
	a--;
	b--;
	for (int i = 1; i < n; i++){
		scanf("%d %d", &x, &y);
		adj[x - 1].push_back(y - 1);
		adj[y - 1].push_back(x - 1);
	}
	dfs1(a, -1, 0);
	int ans = lb - 1, c = a, p = -1;
	for (int i = 0; i < ceil(lb / 2.0); i++){
		int next;
		ml = -1;
		for (int j = 0; j < adj[c].size(); j++){
			if (!cp[adj[c][j]]){
				dfs2(adj[c][j], c, 0);
			}else if (adj[c][j] != p){
				next = adj[c][j];
			}
		}
		if (ml != -1){
			ans = max(ans, lb - i + ml);
		}
		p = c;
		c = next;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 11392
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        
        if(a < b && b < c){
            System.out.println("Yes");
        }
        if(!(a < b && b < c)){
            System.out.println("No");
        }
    
         
    }
}



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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int count;
  int tmp1;
  int tmp2;
  
  for (int i = 0; i <= A; i++){
    
    tmp1 = X - i * 500;
    
    for (int j = 0; j <= B; j++){
      
        tmp2 = tmp1 - j * 100;
      
      for (int k = 0; k <= C; k++){
        if (tmp2 - k * 50 == 0){
          count ++;
        }
      }
    }
  }
  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

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

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

const int Maxn = 2010;

char f[Maxn][Maxn];

int cnt[4][Maxn][Maxn];

int h, w;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> f[i][j];
            if (f[i][j] == '.') {
                for (int k = 0; k < 4; ++k) {
                    cnt[k][i][j]++;
                }
            }
        }
    }

    for (int j = 0; j < w; ++j) {
        for (int i = 1; i < h; ++i) {
            if (f[i][j] == '#') continue;
            cnt[0][i][j] += cnt[0][i - 1][j];
        }
        for (int i = h - 1; i >= 1; --i) {
            if (f[i][j] == '#') continue;
            cnt[1][i][j] += cnt[1][i + 1][j];
        }
    }

    for (int i = 0; i < h; ++i) {
        for (int j = 1; j < w; ++j) {
            if (f[i][j] == '#') continue;
            cnt[2][i][j] += cnt[2][i][j - 1];
        }
        for (int j = w - 1; j >= 1; --j) {
            if (f[i][j] == '#') continue;
            cnt[3][i][j] += cnt[3][i][j + 1];
        }
    }

    int ans = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            int sum = 0;
            for (int k = 0; k < 4; ++k) {
                sum += cnt[k][i][j];
            }
            ans = max(ans, sum - 3);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 67328
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int A, B;
	cin >> A >> B;

	cout << max(A + B, max(A - B, A * B)) << endl;

	return 0;
}

Measured memory_bytes: 256
x,y,z,k = [ int(it) for it in input().split() ]
al = [ int(it) for it in input().split() ]
bl = [ int(it) for it in input().split() ]
cl = [ int(it) for it in input().split() ]

abl = [ a + b for a in al for b in bl]
abl.sort()
abl.reverse()
abl=abl[:k]

abcl = [ ab + c for ab in abl for c in cl]
abcl.sort()
abcl.reverse()
abcl=abcl[:k]
print ( "\n".join( [ str(it) for it in abcl ]) )






Measured memory_bytes: 134300
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;

typedef long long ll;

int MOD=1000000007;

int main()
{
  ll N,K,ans=0;
  cin >> N >> K;
  while(N!=0){
    N/=K;
    ans+=1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
k = int(input())
sum = 0
def gcd(p,q):
  if p%q == 0:
    return q
  return gcd(q,p%q)
  
for i in range(1,k+1):
   for j in range(1,k+1):
      for k in range(1,k+1):
        sum += gcd(gcd(i,j),k)

print(sum)

Measured memory_bytes: 80440
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        var min = 1;
        var max = n[0];
        for(int i = 0; i < n[1]; i++)
        {
            var s = ReadLine().Split().Select(int.Parse).ToArray();
            min = Max(min, s[0]);
            max = Min(max, s[1]);
        }
        WriteLine(Max(max - min + 1, 0));
    }
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong H, R;
	cin >> H >> R;

	if(H == -R)
		cout << 0 << endl;
	else if(H < -R)
		cout << -1 << endl;
	else
		cout << 1 << endl;

	return 0;
}


Measured memory_bytes: 3092
import math
import numpy as np

n=int(input())
a=np.array([int(i)  for i in input().split()])

b=np.zeros(n, dtype=int)
pos=math.ceil((n-1)/2)

forward=True
for i in range(n):
    #print("i:{0}, pos:{1}, a[i]:{2}".format(i, pos, a[i]))
    b[pos]=a[i]
    if forward:
        forward=False
        pos-=(i+1)
    else:
        forward=True
        pos+=(i+1)
        
if forward:
    for i in range(n):
        print(b[i],end=' ')
else:
    for i in range(n):
        print(b[n-1-i],end=' ')

Measured memory_bytes: 43112
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(void) {
	bool flag = true;
	int a, b;
	string s;

	cin >> a >> b;
	cin >> s;
	for (int i = 0; i < a; i++) {
		if (s[i] == '-') {
			flag = false;
			break;
		}
	}
	if (s[a] != '-') {
		flag = false;
	}
	for (int i = a + 1; i < a + b + 1; i++) {
		if (s[i] == '-') {
			flag = false;
			break;
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <limits>
#define INF 100000000
typedef long long int ll;
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, l;
    cin >> n >> l;
    int sum = 0;
    int ret = INF;
    int ret2 = 0;
    rep(i, n){
        sum+=l+i;
        if (abs(l+i) < ret){
            ret = abs(l+i);
            ret2=l+i;
        }
        }
    printf("%d\n", sum-ret2);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int dijkstra(int s, int g, vector<vector<P>> &G){
    vector<int> dist(110, 1e9);
    priority_queue<P, vector<P>, greater<P>> que;
    dist[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        ll ccost = que.top().first;
        ll cv = que.top().second;
        que.pop();
        if(dist[cv] < ccost) continue;

        for(auto x : G[cv]){
            ll nv = x.first;
            ll ncost = x.second;
            if(dist[nv] > dist[cv] + ncost){
                dist[nv] = dist[cv] + ncost;
                que.push(P(dist[nv], nv));
            }
        }
    }

    return (dist[g] == 1e9 ? -1 : dist[g]);
}

int main(){
    while(1){
        int n, k; cin>>n>>k;
        if(n == 0) return 0;

        vector<vector<P>> G(n);
        for(int i=0; i<k; i++){
            int x; cin>>x;
            if(x == 0){
                int a, b; cin>>a>>b;
                a--, b--;
                cout << dijkstra(a, b, G) << endl;
            }
            else{
                int c, d, e; cin>>c>>d>>e;
                c--, d--;
                G[c].eb(P(d, e));
                G[d].eb(P(c, e));
            }
        }
    }
}


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

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		while( scan.hasNextInt() ) {
			Integer[] ary = new Integer[2];
			ary[0] = scan.nextInt();
			ary[1] = scan.nextInt();
			
			Arrays.sort(ary);
			
			int divisor = 0, temp = 0;
			long multiple = 0;
			
			if(ary[0] != 0) {
				int m = ary[1];
				int n = ary[0];
				
				while(true) {
					if(m % n != 0) {
						temp = n;
						n = m % n;
						m = temp;
					}
					
					else if(m % n == 0){
						divisor = n;
						break;
					}
				}
			}
			
			else {
				divisor = ary[1];
			}
			
			multiple = (ary[0] * (long)ary[1]) / divisor;
			
			
			System.out.println(divisor + " " + multiple);
		}
	}
}

Measured memory_bytes: 17232