akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9+7
typedef long long int ll;
const int maxn =1000000; 
ll mod = INF;
int h,w,k;
char g[10][10];
int ans=0;
bool use[12]={0};

void func(int cnt=0){
    if(cnt==h+w){
        // for(int i=0;i<h+w;i++)cout << use[i];
        // cout << endl;
        char m[10][10];
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                m[i][j]=g[i][j];
            }
        }
        for(int i=0;i<h;i++){
            if(use[i]){
                for(int j=0;j<w;j++)m[i][j]='.';
            }
        }
        for(int i=h;i<h+w;i++){
            if(use[i]){
                for(int j=0;j<h;j++)m[j][i-h]='.';
            }
        }
        int count=0;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(m[i][j]=='#')count++;
            }
        }
        if(k==count)ans++;
    }else{
        use[cnt]=true;
        func(cnt+1);
        use[cnt]=false;
        func(cnt+1);
    }
    return;
}

int main(){

    cin >> h>>w>>k;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> g[i][j];
        }
    }

    func();

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

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define r(i,a,b) for(register int i=a;i<=b;i++)
#define ll long long
#define ull unsigned long long

using namespace std;
const ll mod=1e9+7;
ll dp[2020];
int n;
int main()
{
	cin>>n;
	dp[0] =1 ;
	r( i , 3 , n )	
	{
		r( j , 3 , i )
		{
			dp[i] = dp[i]+dp[i-j]%mod; 
		}
	}
	cout<<dp[n]%mod<<endl;
	return 0;	
} 

Measured memory_bytes: 3624
n=int(input())
x=input()
s=list(x)
list=[]
 
for i in range(n):
    a=0
    moji=[]
    for j in range(i):
        for k in range(n-i):
            if s[j]==s[k+i]:
                if s[j] not in moji:
                    a+=1
                    moji.append(s[j])
    list.append(a)
 
f=max(list)
print(f)

Measured memory_bytes: 3060
#include "stdio.h"
#include "stdlib.h"
#include "iostream"
#include "math.h"
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include "algorithm"
#include <time.h>
#include "set"
#include "vector"
#include <iterator>

using namespace std;
#define fori0(G) for(int i=0;i<G;i++)
#define fori1(G) for(int i=1;i<=G;i++)
#define forj0(G) for(int j=0;j<G;j++)
#define forj1(G) for(int j=1;j<=G;j++)
#define fork0(G) for(int k=0;k<G;k++)
#define fork1(G) for(int k=1;k<=G;k++)
int dx[] = { -1,0,1,0 ,0 }, dy[] = { 0,1,0,-1,0 };
#define nxnycon (0<=nx&&nx<h&&0<=ny&&ny<w) 
#define lo long long int
#define  NN cout << "No"<<endl;
#define  YY cout << "Yes"<<endl;

int n, m,qq, l[200000], r[200000], p, q,on[505][505],in[505][505];



int main() {
	cin >> n>> m>>qq;
	fori0(m) {
		cin >> l[i] >> r[i];
	}
	
	fori0(m) {
		on[l[i]][r[i]]++;
	}
	fori0(n) {
		forj1(n - i) {
			in[j][j + i] = on[j][j+i]+in[j][j + i - 1] + in[j + 1][j + i] - in[j + 1][j + i - 1];
		}
	}

	fori0(qq) {
		cin >> p >> q;
		cout << in[p][q] << endl;
	}
	//system("pause");
	return 0;

}



Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 2e3+5;
ll dp[maxn][maxn];
int s[maxn],t[maxn];
int num[5][100005];
int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        for(int i = 1; i <= n; ++i)cin>>s[i];
        for(int i = 1; i <= m; ++i)cin>>t[i];
        memset(num,0,sizeof(num));
        memset(dp,0,sizeof(dp));
        for(int i = 0; i <= n; ++i)dp[i][0] = 1;
        for(int i = 0; i <= m; ++i)dp[0][i] = 1;
        
        for(int i = 1; i <= n; ++i)
        {
            for(int j = 1; j <= m; ++j)
            {
                dp[i][j] = (dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1] + mod)%mod;
                if(s[i] == t[j])
                    dp[i][j] = (dp[i][j] + dp[i-1][j-1])%mod;
            }
        }
        cout<<dp[n][m]<<endl;
    }
}




















Measured memory_bytes: 34172
using Yorukatsu031.Questions;
using Yorukatsu031.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu031.Questions
{
    /// <summary>
    /// ABC051 B
    /// </summary>
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var ks = inputStream.ReadIntArray();
            var k = ks[0];
            var s = ks[1];

            int count = 0;
            for (int x = 0; x <= k; x++)
            {
                for (int y = 0; y <= k; y++)
                {
                    var z = s - (x + y);
                    if (z >= 0 && z <= k)
                    {
                        count++;
                    }
                }
            }

            yield return count;
        }
    }
}


namespace Yorukatsu031
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu031.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu031.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int m;
int x[16], y[16];
// int used[16];
vector<pii> v;
int ans;

int paralell(pii p, pii q) {
  return p.first*q.second-p.second*q.first == 0;
}

void dfs(int s) {
  int no = 1;
  for (int i = 0; i < m; i++) {
    if (s >> i & 1) continue;
    // if (used[i]) continue;
    for (int j = i+1; j < m; j++) {
      if (s >> j & 1) continue;
      // if (used[j]) continue;
      no = 0;
      s += 1 << i;
      s += 1 << j;
      // used[i] = used[j] = 1;
      v.emplace_back(x[i]-x[j], y[i]-y[j]);
      dfs(s);
      v.pop_back();
      s -= 1 << i;
      s -= 1 << j;
      // used[i] = used[j] = 0;
    }
    break;
  }
  if (no) {
    int sum = 0;
    for (int i = 0; i < v.size(); i++) {
      for (int j = i+1; j < v.size(); j++) {
        if (paralell(v[i], v[j])) sum++;
      }
    }
    ans = max(ans, sum);
  }
}


int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> x[i] >> y[i];
  }
  dfs(0);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3224
use strict;
my ($n, $t) = split(' ', <>);

my @a = split(' ', <>);

my $min = 1000000000;
my $mx = 0;
for (@a) {
    my $dif = $_ - $min;
    if ($dif > $mx) {
        $mx = $dif;
    } elsif ($_ < $min) {
        $min = $_;
    }
}
my $fin_mx = $mx;

$min = 1000000000;
$mx = 0;
my $cnt;
for (@a) {
    my $dif = $_ - $min;
    if ($dif >= $mx) {
        $mx = $dif;
        if ($mx == $fin_mx) {
            $cnt++;
        }
    } elsif ($_ < $min) {
        $min = $_;
    }
}

print "$cnt\n";


Measured memory_bytes: 17132
#include <algorithm>
#include <iostream>
#include <set>
#include <iterator>
#include <cmath>
#include <tuple>
#include <stack>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <limits>
#include <cassert>

using namespace std;

//#define endl '\n' //fastio
typedef long long ll;

template<class Flow=long long>
class FlowNetwork{
 private:
    constexpr static Flow PINF = std::numeric_limits<Flow>::max(); 
    class Edge{
     public:
        int to;
        Flow cap; //capacity
        int rev_edge_id; //id of reverse edge (rev_edge = graph[e.to][e.rev_edge_id];
    };

    int n;
    vector<vector<Edge>> graph;

    long long dfs(int from, int to, Flow max_flow){
        vector<bool> is_used(n, false);
        return dfs(from,to,max_flow,is_used);
    }

    long long dfs(int from, int to, Flow max_flow, vector<bool>& is_used) {
        if (from == to) return max_flow;
        is_used[from] = true;
        for(auto& e : graph[from]){
            if(is_used[e.to] || e.cap == 0) continue;

            Edge& rev = graph[e.to][e.rev_edge_id];
            Flow flow = min(e.cap, dfs(e.to, to, min(max_flow, e.cap), is_used));
            if(flow != 0){
                e.cap -= flow;
                rev.cap += flow;
                return flow;
            }
        }
        return 0;
    }
 public:
    FlowNetwork(int _n) : n(_n), graph(_n) {}
    void add_Edge(int from, int to, Flow capacity) {
        int edge_id = graph[from].size(), rev_edge_id = graph[to].size();
        graph[from].push_back({to, capacity, rev_edge_id});
        graph[to].push_back({from, 0, edge_id});
    }

    long long max_flow(int s, int t) {
        ll res = 0;
        for (;;) {
            ll f = dfs(s, t, PINF);
            if (f == 0) return res;
            res += f;
        }
    }
};

int main(int , char** ){
	cin.tie(nullptr); ios::sync_with_stdio(false);
	//cout << fixed << setprecision(10);

    int n,m;
    cin >> n >> m;
    FlowNetwork<long long> fn(n);
    for(int i = 0; i < m; ++i){
        int u,v,c;
        cin >> u >> v >> c;
        fn.add_Edge(u,v,c);
    }
    cout << fn.max_flow(0,n-1) << endl;

return 0;/*
    int n,m,x;
    cin >> n >> m >> x;

    vector<set<int>> Edges(n);
    for(int i = 0; i < m; ++i){

    }
 
 		cout << 1 << endl;
 */
  return 0;
}

Measured memory_bytes: 3260
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int[] a = new int[n];
        
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
        }
        
        Arrays.sort(a);
        
        for(int i=1; i<n; i++){
            if(a[i]==a[i-1]){
                System.out.println("NO");
                return;
            }
        }
        
        
        System.out.println("YES");
    }
}


Measured memory_bytes: 61116
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define endl 		"\n"
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1) {std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " : " << arg1;
	ZZ(comma, args...);
}

void solve() {
	int n;
	cin >> n;
	vl a(n + 1);
	rep(i, 1, n + 1)cin >> a[i];
	vl l(n + 1), r(n + 1);
	unordered_map<ll , ll> ls;
	rep(i, 1, n + 1) {
		ls[i + a[i]]++;
	}
	ll ans = 0;
	rep(i, 1, n + 1) {
		ll cnt = ls[i - a[i]];
		ans += cnt;
	}
	cout << ans;
}
int main() {
	fast_io;
	int t = 1;
	// cin>>t;
	while (t--) {
		solve();
	}
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 23232
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    ll X, Y;
    cin >> X >> Y;
    if(X%Y==0){
        cout << -1 << endl;;
    }else{
        cout << X << endl;
    }
}

Measured memory_bytes: 3608
use proconio::*;
use proconio::marker::Usize1;

fn run() {
    input! {
        n: usize,
        mut k: u64,
        a: [Usize1; n],
    }
    let mul = |a: &[usize], b: &[usize]| -> Vec<usize> {
        let mut c = vec![0; n];
        for (i, a) in a.iter().enumerate() {
            c[i] = b[*a];
        }
        c
    };
    let mut pos = 0;
    let mut s = a;
    while k > 0 {
        if k & 1 == 1 {
            pos = s[pos];
        }
        s = mul(&s, &s);
        k >>= 1;
    }
    println!("{}", pos + 1);
}

fn main() {
    run();
}


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


int gcd(int x, int y) {
  return (x % y)? gcd(y, x % y): y;
}

int main() {
  int n;
  long long tmp = 0, sum = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      tmp = gcd(i,j);
      for (int k = 1; k <= n; k++) {
        sum += gcd(tmp, k);
      } 
    }  
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
using namespace std;
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 long long LLINF=1LL<<60;
//set<int>::iterator it;



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int a,b;
	cin>>a>>b;
	int ans=0;
	ans+=max(a,b);
	if(a>b)a--;
	else b--;
	ans+=max(a,b);
	cout<<ans<<endl;
	
	
	
	
	
	
	
	
//////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define sort(v)     sort((v).begin(),(v).end())
#define rall(v)     (v).rbegin(),(v).rend()
#define rsort(v)     sort((v).rbegin(),(v).rend())
#define gcd(a,b)    __gcd((a),(b))
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;
//x.substr(start, length);
/*
// Create a vector containing n 
//vectors of size m.  
    vector<vector<int> > vec( n , vector<int> (m, 0));  
*/
struct type{
    int k, i, j;
};
//to check if a no is prime or not?
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

// minimum subaaray sum of size k-sliding window approach
int findSubarray(int arr[], int n, int k)
{
	int window_sum = 0;
	int min_window = INT_MAX;
	int last = 0;
	for (int i = 0; i < n; i++)
	{
		window_sum += arr[i];
		if (i + 1 >= k)
		{
			if (min_window > window_sum)
			{
				min_window = window_sum;
				last = i;
			}
			window_sum -= arr[i + 1 - k];
		}
	}
	int sum=0;
	for(int i=last-k+1;i<=last;i++)
	{
	    sum+=arr[i];
	}
	return sum;
}
signed main() 
{
    fastio;
    string s;
    cin>>s;
    for(int i=0;i<3;i++)
    {
        cout<<s[i]<<"";
    }
    cout<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}


Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int mp[1001][1001];

int main(){
	int W;char c;
	for(int num = 0;cin >> W&&W;num++){
		int v[1000], w[1000], n;
		cin >> n;
		fill((int*)mp, (int*)(mp+n+1), 0);
		for(int i = 0;i < n;i++)cin >> v[i] >> c >> w[i];
		for(int i = 0;i < n;i++){
			
			for(int j = 0;j < W+1;j++){
				if(j < w[i])mp[i+1][j] = mp[i][j];
				else mp[i+1][j] = max(mp[i][j], mp[i][j-w[i]]+v[i]);
			}
		}
		
		int ans = 0;
		for(int i = 1;i < W+1;i++){
			if(mp[n][i] > mp[n][ans])ans = i;
		}
		cout << "Case " << num+1 << ":" << endl;
		cout << mp[n][ans] << endl << ans << endl;
	}
	return 0;
}
/*
1
y eazqyp pnop pngtg ye obmpngt xmybp mr lygw
*/

Measured memory_bytes: 6940
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N;

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

  int m = 0, cnt = 0;
  int prev = 100;
  int n = N;
  while (n > 0) {
    int cur = n % 10;
    if (prev == cur) {
      cnt++;
    }
    else {
      cnt = 1;
    }
    m = max(m, cnt);
    prev = cur;
    n /= 10;
  }
  if (m >= 3) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int A[3],sum=0,i,s=0;
	for(i=0;i<3;i++)
	{
		cin>>A[i];
	}
	for(i=0;i<3;i++)
	{
		if(A[i]==5)
			sum++;
		if(A[i]==7)
			s++;
	}
	if(sum==2&&s==1)
		cout<<"YES";
	else
		cout<<"NO";
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;

int main()
{
	IO;
	ll a,b,n;
	cin>>a>>b>>n;
	ll tmp=min(b-1,n);
	cout<<floor(a*tmp/b)-floor(tmp/b)*a<<endl;
 	return 0;
}







Measured memory_bytes: 3804
import java.util.*;
import java.util.stream.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int[] p = new int[N];
		for (int i = 0; i < N; i++) {
			p[i] = in.nextInt();
		}
		Arrays.sort(p);
		p[N - 1] /= 2;
		int ans = 0;
		for (int num : p) {
			ans += num;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#!/usr/bin/env python3
# DSL_2_G: RSQ and RAQ
# Range Add Query and Range Sum Query


class BinaryIndexedTree:
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (self.size+1)

    def add(self, i, v):
        while i <= self.size:
            self.bit[i] += v
            i += (i & -i)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= (i & -i)
        return s


class RangeQuery:
    def __init__(self, n):
        self.size = n
        self.bit1 = BinaryIndexedTree(n+1)
        self.bit2 = BinaryIndexedTree(n+1)

    def add(self, i, j, v):
        self.bit1.add(i, v * -i)
        self.bit1.add(j+1, v * (j+1))
        self.bit2.add(i, v)
        self.bit2.add(j+1, -v)

    def sum(self, i, j):
        s = self.bit1.sum(j+1) + (j+1)*self.bit2.sum(j+1)
        s -= self.bit1.sum(i) + i*self.bit2.sum(i)
        return s


def run():
    n, q = [int(i) for i in input().split()]

    r = RangeQuery(n)

    for _ in range(q):
        com, *args = input().split()
        if com == '0':
            s, t, x = [int(i) for i in args]
            r.add(s, t, x)
        elif com == '1':
            s, t = [int(i) for i in args]
            print(r.sum(s, t))


if __name__ == '__main__':
    run()



Measured memory_bytes: 11800
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()
#define pb push_back

typedef long long ll;
const int inf = 1e9+7;
const ll infll = 1 << 60LL;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

// 型による変数のオーバーフローに気をつけろ！！
// 悩んだら図やグラフを書け！！悩む前から書け！！

// 素因数分解 pair.firstで素数、pair.secondで対応する指数
vector<pair<long long, long long> > prime_factorize(long long n) {
	vector<pair<long long, long long> > res;
	for (long long p = 2; p * p <= n; ++p) {
		if (n % p != 0) continue;
		int num = 0;
		while (n % p == 0) { ++num; n /= p; }
		res.push_back(make_pair(p, num));
	}
	if (n != 1) res.push_back(make_pair(n, 1));
	return res;
}

const int MAX = 210000;

//二項係数を求める前処理 テーブルを作る　O(n)
// facは階乗
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

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

	ll n, m;
	cin >> n >> m;
	COMinit();

	auto vec = prime_factorize(m);
	long long res = 1;
	for (auto pa : vec) { // 便利
		int num = pa.second;
		long long temp = COM(num + n - 1, n - 1);
		res = (res * temp) % mod;
	}

	cout << res << endl;
}

Measured memory_bytes: 5120
#include<cstdio>
#include<cstring>
#include<algorithm>
const int N=1e5+10;
int n,k,sum=0,count[N],q[N],h=1,t=0,fa[N],ll[N];
int read(){
	int f=1,ans=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-48;c=getchar();}
	return ans*f;
}
int main(){
	n=read();k=read();
	int a=read();if(a!=1)sum++;
	for(int i=2;i<=n;i++){
		a=read();fa[i]=a;count[a]++;
	}
	for(int i=2;i<=n;i++)if(!count[i])q[++t]=i;
	while(h<=t){
		int x=q[h];h++;
		if(x==1)break;
		if(fa[x]!=1&&ll[x]==k-1)sum++;
		else ll[fa[x]]=std::max(ll[fa[x]],ll[x]+1);
		count[fa[x]]--;
		if(!count[fa[x]])q[++t]=fa[x];
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;

    if (x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

int main()
{
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

//　if文
// if (num == 0)
// {
//     cout << "0";
// }
// else if (num == 1)
// {
//     cout << "1"; // 1が表示される
// }
// else
// {
//     cout << "01以外";
// }


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

int main()
{
    string S, T;
    cin >> S >> T;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] != T[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//long long MOD = 1e9 + 7;

long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;


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

    ll n;
    cin >> n;
    
    cout << n * n << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl "\n"
#define p_b push_back
#define m_p make_pair
#define fastIO ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
template <class T> 
using _ost = tree<
		T, 
		null_type, 
		less<T>, 
		rb_tree_tag, 
        tree_order_statistics_node_update>;

// char alphabet[26] = {'a','b','c','d','e','f','g','h','i',
//        'j','k','l','m','n','o','p','q','r','s','t','u','v',
//        'w','x','y','z'};


int32_t main(){
 	fastIO;
	int k;cin>>k;
	int a,b;cin>>a>>b;
	if(a/k<b/k || a%k==0 || b%k==0)cout<<"OK"<<endl;
	else cout<<"NG"<<endl;
}		



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){


  ll n;cin>>n;
  string s;cin>>s;
  int shiro[n];
  if(s[0]=='.'){
    shiro[0] = 1;
  }else{
    shiro[0] = 0;
  }
  bool is0 = true;
  for(int i=1;i<n;i++){
    if(s[i]=='.'&&s[i-1]=='#')is0 = false;

    shiro[i] = shiro[i-1];
    if(s[i]=='.'){
      shiro[i]++;
    }
  }
  if(is0){
    cout<<0<<endl;
    return 0;
  }

  int  ans = n/2;
  for(int i=1;i<n;i++){
    ans = min(ans,i-shiro[i-1] + shiro[n-1] - shiro[i-1]);
  }

  cout<<ans<<endl;

 

  return 0;
}

Measured memory_bytes: 1412
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999



bool per[101][101]={};
int w,h;
int s,t;


int solve(int y,int x){
    int sum = 0;
    for(int i=y;i<y+t;i++){
        for(int j=x;j<x+s;j++){
            if(per[i][j])sum++;
        }
    }
    return sum;
}

int main(){
    int n;
    while(cin>>n){
        if(n==0)break;
        rep(i,101)rep(j,101)per[i][j]=false;
        cin>>w>>h;
        rep(i,n){
            int x,y;
            cin>>x>>y;
            x--,y--;
            per[y][x] = true;
        }
        cin>>s>>t;
    
        int maxi = -1;
        rep(i,h-t+1){
            rep(j,w-s+1){
                maxi = max(maxi,solve(i,j));
            }
        }
        cout<<maxi<<endl;
    }
}

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

bool isPrime(int x){
  if(x<=1)return false;
  for(int i=2;i*i<=x;i++){
    if(x%i==0)return false;
  }
  return true;
}

int main(){
  int n;
  while(cin >> n){
    if(n==0)break;

    int res = 0;
    for(int i=n+1;i<=2*n;i++){
      if(isPrime(i))res++;
    }
    cout << res << endl;
  }
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while(0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll x,y;
  cin>>x>>y;
  map<ll,ll> mp ={{1, 300000}, {2, 200000}, {3, 100000}};
  ll ans = mp[x] + mp[y];
  if (x==1 && y==1)
    ans += 400000;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		solve();
	}

	private static void solve() {
		Scanner scn = new Scanner(System.in);
		PrintWriter pr = new PrintWriter(System.out);
		int N = scn.nextInt();
		while(N-->0){
			int sum=0;
			for(int s=0;s<2;s++){
				String a = scn.next();
				int c=1;
				for(int i=0;i<a.length();i++){
					if(a.charAt(i)=='m'){
						sum+=c*1000;
						c=1;
					}else if(a.charAt(i)=='c'){
						sum+=c*100;
						c=1;
					}else if(a.charAt(i)=='x'){
						sum+=c*10;
						c=1;
					}else if(a.charAt(i)=='i'){
						sum+=c;
						c=1;
					}else{
						c=a.charAt(i)-'0';
					}
				}
			}
			if(sum/1000>0){
				if(sum/1000==1){
					pr.print("m");
				}else{
					pr.print(sum/1000+"m");
				}
				sum%=1000;
			}
			if(sum/100>0){
				if(sum/100==1){
					pr.print("c");
				}else{
					pr.print(sum/100+"c");
				}
				sum%=100;
			}
			if(sum/10>0){
				if(sum/10==1){
					pr.print("x");
				}else{
					pr.print(sum/10+"x");
				}
				sum%=10;
			}
			if(sum>0){
				if(sum==1){
					pr.print("i");
				}else{
					pr.print(sum+"i");
				}
			}
			pr.println();
		}
		pr.flush();
		scn.close();
	}

}

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

using namespace std;

int main() {
	int H, W;
	while (cin >> H >> W && (H || W)) {
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (i == 0 || i == H-1 || j == 0 || j == W-1) {
					cout << '#';
				} else {
					cout << '.';
				}
			}
			cout << '\n';
		}
		cout << '\n';
	}
}


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

int main(){
    string s;
    cin >> s;

    vector<int> flag(3, 0);
    for(int i = 0; i < 3; i++){
        flag[s[i] - 'a']++;
    }

    if(flag[0] == 1 && flag[1] == 1 && flag[2] == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
import math

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    a, b, h, m = inl()
    t2 = 2 * math.pi * m / 60.0
    t1 = 2 * math.pi * (h * 60.0 + m) / (12 * 60.0)
    return math.sqrt(a * a + b * b - 2 * a * b * math.cos(t1 - t2))


print(solve())


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

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




int main() {
	int n;
	cin >> n;
	ll a[n];
	bool ok[n];
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a, a + n, greater<ll>());
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		sum -= a[i];
		if (2 * sum < a[i]) {
			ans = i + 1;
			cout << ans << endl;
			return 0;
		}
	}
	
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 1024
"""
愚直に考えると、
・今XXX日目です
・試合できる人は試合をします。
・その日一回でも試合があれば次の日に進んで、なかったらおわり
をやる。愚直にやろうとすると、
・各選手について、次に試合する相手
・各選手がその日に試合したかどうか（１日に同じ人が複数回試合できないので）
・現在XXX日目
などの情報を持つ必要があり、また、その日の終わりに、各選手が試合したかどうかなどから、その日１回でも試合があったか判定をしたり、処理がめんどくさい。

ちょっとひねった方法で考えると、
・各選手が順番に、自分が次に試合するべき相手を一人指名して場にカードを出す。
・マッチングが成立する（a->b, b->a のカードが両方場に出される）と、その試合が実施され、試合した二人の選手について、次に試合したい選手がいれば、またカードを場に出す
・aとbが試合した時の最短の日にちは、max(aが最後に試合した日, bが最後に試合した日)+1 で表される
・各選手がカードを出したにも関わらず、マッチングが成立しない場合は、与えられた順番で試合ができない。

の形で管理すると、今日は何日で～とか、その日一回でも試合があったか～とかを管理しなくてよい。
"""

from collections import deque

N = int(input())
A = [deque(list(map(int, input().split()))) for _ in range(N)]


q = deque()
for i in range(N):
    q.append(i)

next_game_with = [-1] * N
end_by = [0] * N
while q:
    a = q.popleft()
    opponent = A[a].popleft() - 1
    if next_game_with[opponent] == a:
        end_by[a] = end_by[opponent] = max(end_by[a], end_by[opponent]) + 1
        if A[a]:
            q.append(a)
        if A[opponent]:
            q.append(opponent)
    else:
        next_game_with[a] = opponent

finished = True
for i in range(N):
    if A[i]:
        finished = False
        break
if finished:
    print(max(end_by))
else:
    print(-1)

Measured memory_bytes: 80988
#include <stdio.h>

void merge_sort(long long x[], int n)
{
	static long long y[100001] = {};
	if (n == 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N, V, P;
	long long M, A[100001];
	scanf("%d %lld %d %d", &N, &M, &V, &P);
	for (i = 0; i < N; i++) scanf("%lld", &(A[i]));
	merge_sort(A, N);
	
	int l = 0, r = N - P, m;
	long long border, rest;
	while (l < r) {
		m = (l + r) / 2;
		border = A[m] + M;
		if (border < A[N-P]) {
			l = m + 1;
			continue;
		}
		for (i = m + 1, rest = M * (V - P - m); i <= N - P && rest > 0; i++) rest -= border - A[i];
		if (rest > 0) l = m + 1;
		else r = m;
	}
	
	printf("%d\n", N - l);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3292
#include<stdio.h>
int main() {
	int N;
	scanf("%d", &N);
	int *A = (int *)malloc(sizeof(int)*N);
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &A[i]);
	}

	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		ans++;
		while (A[i] == A[i + 1] && i + 1 < N)
		{
			i++;
		}
		if (A[i] - A[i + 1] > 0)
		{
			while (A[i] - A[i + 1] >= 0 && i + 1 < N)
			{
				i++;
			}
		}
		else
		{
			while (A[i] - A[i + 1] <= 0 && i + 1 < N)
			{
				i++;
			}
		}
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if((a-1)/d+1 >= (c-1)/b+1) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef vector<int> vi;
typedef vector<vi> vvi;

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

int bfs(int sy, int sx, int st, vvi& board, vvi& used){

  queue<piii> que;
  que.push(piii(pii(sy,sx),st));
  
  int ans = 0;
  while(que.size()){
    int y = que.front().first.first;
    int x = que.front().first.second;
    int t = que.front().second;
    que.pop();
    //    if(y > 60 || y < 0 || x > 60 || x < 0) continue; // ?£????
    if(used[y][x]  == 1) continue;  // ??¢?´¢?????? 
    if(board[y][x] == 1) continue;;  // ?????????
    if(t < 0) continue; // ???????????°??????
    
    ans++;
    used[y][x] = 1; 
    for(int i=0; i<6; i++){
      int nx = x + dx[i]; int ny = y + dy[i];
      que.push(piii(pii(ny,nx),t-1));
    }
  }
  return ans;
}


int main(){

  while(1){
    int t,n;
    cin >> t >> n;
    if(!t and !n)break;
    
    vvi board(200,vi(200,0));
    vvi used(200,vi(200,0));
    for(int i=0; i<n; i++){
      int x,y; cin >> x >> y;
      board[y+100][x+100] = 1; // ?????????
    }
    int sx,sy; cin >> sx >> sy;
    cout << bfs(sy+100,sx+100,t,board,used) << endl;
  }
  
}

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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < n ; i++)


int main(){
    int N;
    cin >> N;
    vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        cin >> a[i];
        a[i] -= i;
    }
    sort(a.begin(), a.end());

    auto solve = [](long long m,vector<long long> x){
        long long ans = 0;
        for(long long i : x ){
            ans += abs(m-i);
        }
        return ans;
    };
    cout << min(solve(a[(a.size()+1)/2], a), solve(a[a.size()/2],a)) << endl;
}

Measured memory_bytes: 4992
#include<iostream>
using namespace std;
int main(){
	
	int a,b,c,d,e,f;
	cin>>a;
	cin>>b;
	cin>>c;
	cin>>d;
	cin>>e;
	cin>>f;

	if(a<b){swap(a,b);}
	if(b<c){swap(b,c);}
	if(c<d){swap(c,d);}
	if(a<d){swap(a,d);}

	if(e<f){swap(e,f);}

	cout<<a+b+c+e<<endl;



return 0;
}


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

int main(void){
	string S;
	cin >> S;
	bool flag{false};
	for(int i{0}; i<3; ++i){
		if(S[i] == S[i+1]){
			flag = true;
			break;
		}
	}
	if(flag){
		cout << "Bad" << endl;
	}
	else{
		cout << "Good" << endl;
	}
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int H,W;
char board[520][520];
int dp[520][520];//右から見て"."がいくつ連続しているか
int main(){
	while(cin>>H>>W,H||W){
		for(int i =1;i <=H;i++){
			for(int j =1;j <=W;j++){
				dp[i][j]=0;
			}
		}
		for(int i =1;i <=H;i++){
			int x = 1;
			for(int j =W;j >=1;j--){
				cin>>board[i][j];
				if(board[i][j]=='.'){
					dp[i][j]=x;
					x++;
				}else{
					dp[i][j]=0;
					x = 1;
				}
			}
		}
		int ans = 0;
		for(int i = 1;i <=H;i++){
			for(int j =1;j <= W;j++){
				if(dp[i][j]==0)continue;
				int m =INF;
				if(ans >(H-i+1)*W)continue;
				for(int k =i;k <=H;k++){
					m =min(m,dp[k][j]);
					if(m==0)break;
					ans =max(ans,(k-i+1)*m);
				}
			}
		}
		cout <<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 2436
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AGC003_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            long ans = 0;
            long cnt = 0;
            for (int i = 0; i < n; i++)
            {
                int a = int.Parse(Console.ReadLine());
                cnt += a;
                if (a == 0)
                {
                    ans += cnt / 2;
                    cnt = 0;
                }
            }
            ans += cnt / 2;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 6744
/*
	The Number of Inversions
*/

#include <stdio.h>
#include <stdlib.h>


int *WORK;
long long int COMPARE_COUNT;


void Merge_sort(int *S, int low, int high)
{
	int mid;
	int i, j, k;


	if(high <= low)
		return;

	mid = (low + high) / 2;

	// 左側の処理
	Merge_sort(S, low, mid);

	// 右側の処理
	Merge_sort(S, mid + 1, high);

	for(i = low; i <= mid; i++)
		WORK[i] = S[i];

	for(i = high, j = mid + 1; i > mid; i--, j++)
		WORK[i] = S[j];


	// マージ
	i = low;
	j = high;
	for(k = low; k <= high; k++){
		if(WORK[i] <= WORK[j]){
			S[k] = WORK[i++];
		}else{
			S[k] = WORK[j--];
			//COMPARE_COUNT += ((mid - low + 1) - (i - low));
			COMPARE_COUNT += mid - i + 1;	// 上の式を変形
		}
	}
}


int main()
{
	int n;
	int n2;
	int *box;
	int i;


	scanf("%d", &n);
	n2 = n;

	box = (int *)malloc(sizeof(int) * n);
	WORK = (int *)malloc(sizeof(int) * n);

	srand((unsigned)time(NULL));
	for(i = 0; i < n; i++)
		scanf("%d", &box[i]);

	COMPARE_COUNT = 0;
	Merge_sort(box, 0, n - 1);

	printf("%lld\n", COMPARE_COUNT);

	return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  ll N;
  string S;
  cin >> N;
  cin >> S;
  ll r = 0;
  for (int i = 0; i < N; ++i) {
    if (S[i]=='R')
      r++;
  }
  if (r <= N-r)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <queue> 
#include <map>
#include <set>
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
using namespace std;

int main(){

  int n,c;
  cin >> n >> c;

  map <int,int>channel[c+1];
  REP(i,n){
    int s,t,C;
    cin >> s >> t >> C;
    channel[C].insert({s,t});
  }


for(auto i = 1; i <= c; i++) {
  int key = 0, t = 0;
  map<int, int> &ch = channel[i];
  for (auto itr = ch.begin(); itr != ch.end(); ) {
    if (itr->first == t) {
      t = ch[key] = itr->second;
      itr = ch.erase(itr);
    } else {
      key = itr->first;
      t = itr->second;
      ++itr;
    }
  }
}

  const int NMAX = 100010;
  int s[NMAX] = {};

  REP(i,c){
    ITR(itr,channel[i+1]){
      s[itr->first-1]++; //待機時間があるため，録画器は番組開始の1手前の時刻から使用
      s[itr->second]--;
    }
  }

/*    REP(i,c){
      cout << i+1 << endl;
    ITR(itr,channel[i+1]){
 cout << itr->first << " " << itr->second << endl;
    }
    }
  */

  int ans = 0;

  REP(i,NMAX-1){
    s[i+1] += s[i];
    ans = max(ans,s[i+1]);
  }

  cout << ans << endl;

 return 0;
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> v(n);
  rep(i,n) cin >> v[i];
  sort(v.begin(),v.end());
  if(n%3!=0) {
    if(v[n-1]==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
  }
  int x=n/3;
  if(v[0]==v[x-1]&&v[x]==v[2*x-1]&&v[2*x]==v[n-1]){
    int a=v[0];
    int b=v[x];
    int c=v[2*x];
    int d=a^b;
    if(d==c) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else cout << "No" << endl;
}


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

int x, n;
set<int> st;

int main() {
  cin >> x >> n;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    st.insert(a);
  }
  
  for (int i = 0; ; ++i) {
    for (int k : { -1, 1 }) {
      int p = x + k * i;
      if (!st.count(p)) {
        cout << p << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3640
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int func(int N)
{
        if (N < 10)
                return N;
        return func(N / 10) + N % 10;
}

int main()
{
        int N, L;
        cin >> N >> L;

        vector<ll> S(N + 1), T(N + 1, 0);

        rep(i, N) cin >> S[i];
        sort(S.begin(), S.begin() + N);
        rep(i, N) T[i + 1] += S[i] + T[i];

        ll ans = 0, cnt = 0;

        rep(i, N)
        {
                cnt += S[i];
        }
        if (cnt == L)
                ans = N;
        else if (cnt < L)
                ans = N - 1;
        else
        {
                rep(i, N + 1)
                {
                        if (T[i] > L)
                        {
                                ans = i - 1;
                                break;
                        }
                }
        }
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
from math import factorial

n, m = map(int, input().split())
if n == m:
    print((factorial(n) ** 2 * 2) % (10 ** 9 + 7))
elif abs(n - m) == 1:
    print((factorial(n) * factorial(m)) % (10 ** 9 + 7))
else:
    print(0)

Measured memory_bytes: 11096
#!/usr/bin/env python3
def main():
    X, K, D = map(int, input().split())

    res = abs(X) // D
    if res <= K:
        K -= res
        if K % 2:
            print(abs(abs(X) % D - D))
        else:
            print(abs(X) % D)
    else:
        print(abs(X) - D * K)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9124
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

bool f(int a, int b, int c) {

    return (a < b and b < c) or (c < b and b < a);

}

int main() {

    int n;
    cin >> n;
    vector<int> ps;
    for (int i = 0; i < n; ++i) {
        int p;
        cin >> p;
        ps.push_back(p);
    }

    int cnt = 0;
    for (int i = 1; i < n - 1; ++i) {
        if(f(ps[i-1],ps[i],ps[i+1])) {
            cnt += 1;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256