akhauriyash/Code-Regression huggingface dataset:
n=int(input())
ans=1
mod=10**9+7
m=1
for i in range(n):
    m*=(i+1)
for j in range(2,n+1):
    b=1
    while m%j==0:
        m=m//j
        b+=1
    ans*=b
ans=ans%mod
print(ans)


Measured memory_bytes: 2940
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	private static final long MOD = 10*10*10*10*10*10*10*10*10+7;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		long sum = 0;
		for (long i = k; i <= n+1; i++) {
			sum = (sum + sumEvery(i, n+1))%MOD;
		}
		System.out.println(sum%MOD);

	}

	private static long sumEvery(long num, long n) {
		if (num == n) {
			return 1;
		}
		if (num == n-1) {
			return n;
		}
		long l = (num*num - num)/2;
		long r = (2*n - num -1)*num/2;
		return (r-l+1)%MOD;
	}

}


Measured memory_bytes: 35836
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication27
{
    class Program
    {
        static void Main()
        {
            int b = 1;
            while (true)
            {
                int a = int.Parse(Console.ReadLine());
                if (a == 0) break;
                Console.WriteLine("Case {0}: {1}",b,a);
                b++;
            }
        }
    }
}

Measured memory_bytes: 9376
#include <iostream>
    #include <string>
    #include <set>  
    #include <stack>
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
    #include <cassert>
    #include <iomanip>
    #include <sstream>
    #include <ctime>
    #include <bitset> 
using namespace std;
#define for1(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,maxn) for1(i,0,maxn)
#define ford(i,b,a) for(int i=(int)(b)-1;i>=a;--i)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,pii > piii;
#define inf 0x3f3f3f3f
#define mod 1000000007
#define st first
#define nd second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define dprintf(...) printf(__VA_ARGS__)
const int maxn=5e5+10;
vector<pii> g[maxn];
int cst[maxn];
bool vis[maxn];
int n,m;
map<pii,int> id;
int ind=1;
int main()
{
	scanf("%d %d",&n,&m);
	rep(i,m)
	{
		int p,q,c;
		scanf("%d %d %d",&p,&q,&c);
		p--,q--;
		if(!id[mp(p,0)])id[mp(p,0)]=ind++;
		if(!id[mp(q,0)])id[mp(q,0)]=ind++;
		if(!id[mp(p,c)])id[mp(p,c)]=ind++;
		if(!id[mp(q,c)])id[mp(q,c)]=ind++;
		g[id[mp(p,0)]].pb(mp(id[mp(p,c)],0));
		g[id[mp(p,c)]].pb(mp(id[mp(q,c)],0));
		g[id[mp(q,c)]].pb(mp(id[mp(q,0)],1));
		g[id[mp(q,0)]].pb(mp(id[mp(q,c)],0));
		g[id[mp(q,c)]].pb(mp(id[mp(p,c)],0));
		g[id[mp(p,c)]].pb(mp(id[mp(p,0)],1));
	}
	if(!id[mp(0,0)])
	{
		printf("-1\n");
		return 0;
	}
	memset(cst,0x3f,sizeof(cst));
	cst[id[mp(0,0)]]=0;
	priority_queue<pii,vector<pii>,greater<pii> > que;
	que.push(mp(0,id[mp(0,0)]));
	while(!que.empty())
	{
		int cur=que.top().st;
		int cid=que.top().nd;
		que.pop();
		if(cst[cid]<cur)continue;
		rep(i,g[cid].size())
		{
			int to=g[cid][i].st;
			int val=g[cid][i].nd;
			if(cst[to]>cst[cid]+val)
			{
				cst[to]=cst[cid]+val;
				que.push(mp(cst[to],to));
			}
		}
	}
	if(cst[id[mp(n-1,0)]]>=inf)printf("-1\n");
	else printf("%d\n",cst[id[mp(n-1,0)]]);
	return 0;
}

Measured memory_bytes: 64376
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int x;
  cin>>x;
  int num=x/100,cur=x%100;
  int temp=0;
  for(int i=5;i>=1;i--){
    temp+=cur/i;
    cur%=i;
  }
  if(num<temp) cout<<"0"<<endl;
  else cout<<"1"<<endl;
  return 0;
}


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

int main() {

    int n,x,l,ans = 0;
  	int L[n + 1];
    L[0] = 0;
    scanf("%d %d", &n, &x);
  
    for (int i = 1; i <= n; i++) {
        scanf("%d", &l);
        L[i] = L[i - 1] + l;
    }
    for (int i = 0; i <= n; i++) {
        if (L[i] <= x) {
            ans++;
        }
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 1740
#include<iostream>
using namespace std;
int main()
{
  string s; cin >> s;
  int count = 700;
  if(s[0] == 'o') count += 100;
  if(s[1] == 'o') count += 100;
  if(s[2] == 'o') count += 100;
  cout << count << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
using namespace std;
int main(int argc, char *argv[])
{
  const int N = 1000001;
  vector<int> full(N);
  vector<int> odd(N);
  for(int i = 0; i < N; i++) full[i] = i;
  for(int i = 0; i < N; i++) odd[i] = i;
  for(int n = 2; ; n++) {
    const int t = (n * (n+1) * (n+2))/6;
    if(t >= N) break;
    for(int i = 0; i + t < N; i++) {
      const int k = i + t;
      if(full[i] + 1 < full[k]) full[k] = full[i] + 1;
      if(t & 1) {
        if(odd[i] + 1 < odd[k]) odd[k] = odd[i] + 1;
      }
    }
  }
  
  for(int t = 1;; t++) {
    int n;
    cin >> n;
    if(n == 0) break;
    cout << full[n] << " " << odd[n] << endl;
  }
  return 0;
}

Measured memory_bytes: 10552
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#include<numeric>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

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

    int a;cin>>a;
    if(a%2){
        cout<<a/2<<endl;
    }else{
        cout<<a/2-1<<endl;
    }
}


Measured memory_bytes: 256
require 'matrix'

rot = Matrix[[0, -1], [1, 0]]

loop {
	n = gets.to_i
	break if n == 0

	polylines = []
	(n+1).times {
		m = gets.to_i
		polylines << (1..m).map { Vector[*gets.split.map(&:to_i)] }
	}
	
	polylines.map!{|points|
		origin = points[0]
		points.map!{|point|
			point - origin
		}
	}
	
	target = polylines[0]
	(1..n).each{|i|
		points = polylines[i]
		ok = false
		4.times {
			ok = true if target == points
			points.map!{|v| rot * v}
		}
		origin = points[-1]
		points.map!{|point|
			point - origin
		}
		points.reverse!
		4.times {
			ok = true if target == points
			points.map!{|v| rot * v}
		}
		puts i if ok
	}

	puts "+++++"
}

Measured memory_bytes: 6916
# C
import numpy as np

N = int(input())

res = 100000

res_9 = np.zeros(100001, dtype="int32")
res_6 = np.zeros(100001, dtype="int32")
for i in range(10):
    res_9 += (np.arange(100001) // (9**i)) % 9
for j in range(10):
    res_6 += (np.arange(100001) // (6**j)) % 6

for k in range(N + 1):
    res = min(res, res_9[k] + res_6[N - k])
print(res)

Measured memory_bytes: 17976
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
  string s;
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(s[i] != 'x'){
      s[i] = 'x';
    }
  }
  
  cout << s << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int a,b,c;
	while(cin>>a>>b>>c,a+1){
		int sum=a*3600+b*60+c;
		int out=7200-sum;
		printf("%02d:%02d:%02d\n",out/3600,(out%3600)/60,out%60);
		/*double tmp=sum/3.0;
		if(tmp-(int)tmp)tmp++;
		out=7200-(int)tmp;*/
		out*=3;
		printf("%02d:%02d:%02d\n",out/3600,(out%3600)/60,out%60);
	}
}

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

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

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  string s; cin >> s;

  int cntl = 0;
  int ansl = 0, ansr = 0;
  for(int i=0;i<n;++i) {
    if(s[i] == '(') {
      cntl++;
    } else {
      if(cntl == 0) {
        ansl++;
      } else {
        cntl--;
      }
    }
  }
  ansr = cntl;
  for(int i=0;i<ansl;++i) {
    cout << "(";
  }
  cout << s;
  for(int i=0;i<ansr;++i) {
    cout << ")";
  }
  cout << endl;
}


Measured memory_bytes: 256
//Circle Pond

#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
using ll = long long;
#define range(a) (a).begin(),(a).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int inf = 1000000000;

int main (){
    int R;cin>>R;
    const double PI=3.14159265358979323846;
    cout << 2 * R * PI << endl;
    return 0;
}

Measured memory_bytes: 3780
#include <iostream>
using namespace std;
#define rep(i,x,to) for(int i=x;i<to;i++)

int main() {
	int n,rank,card[4][13]={{}};
	char mark;
	cin>>n;
	if(n!=52){
		rep(k,0,n){
			cin>>mark>>rank;
			switch(mark){
				case 'S':
				  card[0][rank-1]=1;
				  break;
				case 'H':
				  card[1][rank-1]=1;
				  break;
				case 'C':
				  card[2][rank-1]=1;
				  break;
				case 'D':
				  card[3][rank-1]=1;
				  break;
			}
		}
		rep(i,0,4){
			rep(j,0,13){
				if(card[i][j]==0){
					if(i==0)cout << 'S' << " " << j+1 << endl;
					else if(i==1)cout << 'H' << " " << j+1 << endl;
					else if(i==2)cout << 'C' << " " << j+1 << endl;
					else cout << 'D' << " " << j+1 << endl;
				}
			}
		}
	}
	return 0;
}



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

int main() {
	int N, L;
	cin >> N >> L;
	int idx = 0;
	int tmp = 10000;
	int ans = 0;
	rep (i, N){
		ans += L + i;
		if (tmp*tmp > (L + i)*(L + i)){
			idx = i;
			tmp = L + i;
		}
	}
	cout << ans - (L + idx) << endl;
	return 0;
}


Measured memory_bytes: 3544
//1_  minmax表記
//pair型のmin_max関数：firstが最小値, secondが最大値
#include <iostream>
#include <algorithm>
using ll = long long;

int main()
{
    //std::pair<最小値の変数型 , 最大値の変数型> 変数名 = std::minmax(代入する値);
    //autoで宣言したほうが楽
    ll a, b, c;
    std::cin >> a >> b >> c;
    
    std::pair<int,int> abc = std::minmax({a,b,c});
    std::cout << abc.first << " " << abc.second << std::endl;

    return 0;
}


Measured memory_bytes: 3088
package main

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

func main() {
	N := ReadInt()
	m := make(map[int]int)
	for i := 0; i < N-1; i++ {
		m[ReadInt()]++
	}
	for i := 1; i <= N; i++ {
		fmt.Println(m[i])
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 13992
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  vector<int> D(8);
  D[A]++;
  D[B]++;
  D[C]++;
  if (D[5] == 2 && D[7] == 1) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC128_1
{
    class C
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = a[0]; var M = a[1];
            var b = Enumerable.Repeat(0, M).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
            var p = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var res = 0;
            for (int bit = 0; bit < (1 << N); bit++)
            {
                bool all = true;
                // 各電球の数繰り返す
                for (int i = 0; i < M; i++)
                {
                    var total = 0;
                    for (int j = 1; j <= b[i][0]; j++)
                    {
                        if ((bit & (1 << (b[i][j] - 1))) > 0) total++;
                    }
                    if (total % 2 != p[i]) { all = false; }
                }
                if (all) res++;
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<30;
const ll LLINF = 1LL<<62;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
  int dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1};
  int h,w;
  static const int size = 50;
  char bomb[size+2][size+2];
  int cnt[size+2][size+2] = {};
  string S;
  cin >> h >> w;
  REP(i,h){
      cin >> S;
      REP(j,S.size()){
      bomb[i+1][j+1] = S[j];
      if (S[j]=='#'){
        REP(k,8){
            cnt[i+1+dx[k]][j+1+dy[k]]++;
        }
      }
      }
  }
  REP(i,h){
      REP(j,w){
        if (bomb[i+1][j+1] == '#'){
            cout << '#';
        }else{
            cout << cnt[i+1][j+1];
        }
      }
      cout << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main() {
    string s;
    cin>>s;
    replace(s.begin(),s.end(),',',' ');
    cout<<s<<endl;
}

Measured memory_bytes: 256
// AOJ 2538 Stack Maze
// 2018.2.2 bal4u

#include <stdio.h>
#include <string.h>
#include <ctype.h>

char map[53][53];
char mk[53][53][53][53];
int memo[53][53][53][53];
char a[53][53][11][2], hi[53][53];

#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int calc(int lr, int lc, int rr, int rc)
{
	int i, r, c, t, x, ans;

	if ((ans = memo[lr][lc][rr][rc]) >= 0) return ans;
	if (lc > rc || lr > rr) { ans = 0; goto done; }
	if (map[lr][lc] == '#' || map[rr][rc] == '#' ||
		!mk[lr][lc][rr][rc]) { ans = -1; goto done; }

	ans = 0;
	for (i = 0; i < hi[lr][lc]; i++) {
		r = a[lr][lc][i][0], c = a[lr][lc][i][1];
		if (r < lr || r > rr || c < lc || c > rc) continue;
		x = calc(r, c, rr, rc) + 1;
		t = calc(lr+1, lc, r-1, c) + x; if (t > ans) ans = t;
		t = calc(lr, lc+1, r-1, c) + x; if (t > ans) ans = t;
		t = calc(lr+1, lc, r, c-1) + x; if (t > ans) ans = t;
		t = calc(lr, lc+1, r, c-1) + x; if (t > ans) ans = t;
	}
	t = calc(lr+1, lc, rr, rc); if (t > ans) ans = t;
	t = calc(lr, lc+1, rr, rc); if (t > ans) ans = t;
done:
	return memo[lr][lc][rr][rc] = ans;;
}

int main()
{
	int H, W, r, c, u, v, k;

	while (H = in()) {
		W = in();
		memset(mk, 0, sizeof(mk));
		memset(hi, 0, sizeof(hi));
		memset(memo, -1, sizeof(memo));

		for (r = 1; r <= H; r++) {
			fgets(map[r]+1, 53, stdin);
			for (c = 1; c <= W; c++) if (map[r][c] != '#') {
				mk[r][c][r][c] = 1;
				for (u =1 ; u <= r; u++) for (v = 1; v <= c; v++) {
					if (mk[u][v][r-1][c] || mk[u][v][r][c-1]) {
						mk[u][v][r][c] = 1;
						if (isupper(map[r][c]) && islower(map[u][v]) &&
							(map[r][c] & 0x1f) == (map[u][v] & 0x1f)) {
							k = hi[u][v]++;
							a[u][v][k][0] = r, a[u][v][k][1] = c;
						}
					}
				}
			}
		}

		printf("%d\n", calc(1, 1, H, W));
	}
	return 0;
}


Measured memory_bytes: 40392
#include<cstdio>
long long n,a[100001],k,sum,s,s2,ans;
long long abs(long long x){return x<0?0:x;}
long long max(long long x,long long y){return x<y?y:x;}
int main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;++i)scanf("%lld",a+i),sum+=abs(a[i]);
	for(int i=1;i<=k;++i)s=s+a[i],s2+=abs(a[i]);ans=sum+abs(s)-s2;
	for(int i=k+1;i<=n;++i)s=s-a[i-k]+a[i],s2=s2-abs(a[i-k])+abs(a[i]),ans=max(ans,sum+abs(s)-s2);
	printf("%lld\n",ans);
	return 0;
}

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

int p[500][500];
int sum[500][500];

int main(){
	int n;cin>>n;
	rep(i,n)rep(j,n)scanf("%d",&p[i][j]);
	rep(i,n){
		rep(j,n){
			sum[i+1][j]=sum[i][j]+p[i][j];
		}
	}
	int ans=INT_MIN;
	rep(i,n){
		int Max=0;
		rep(k,n){
			ans=max(ans,Max+p[i][k]);
			Max=max(Max+p[i][k],0);
		}
		for(int j=i+1;j<n;j++){
			int Max=0;
			rep(k,n){
				ans=max(ans,max(0,Max)+(sum[j+1][k]-sum[i][k]));
				Max=max(Max+p[i][k]+p[j][k],sum[j+1][k]-sum[i][k]);
			}
		}
	}
	cout<<ans<<endl;
}


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

int main(){
	int A, B, C;
  	cin >> A >> B >> C;

  	string ans = "No";

  	if(A != B && B == C){
    	ans = "Yes";
    }
	 if(A != C && B == C){
    	ans = "Yes";
    }  
   	if(B != C && A == C){
    	ans = "Yes";
    }
     if(B != C && A == B){
    	ans = "Yes";
    }
  
  	cout << ans << endl;
}

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

int main()
{
    string X[5];
    int i;

    for (i = 0; i < 5; i++)
    {
        cin >> X[i];
        if (X[i] == "0")
            break;
    }
    cout << i+1 << "\n";
    return 0;
}

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

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

  bool exist = false;

  for (int ly = 0; ly < N; ly++)
  {
    for (int lx = 0; lx < N; lx++)
    {
      if (ly >= N - M + 1 or lx >= N - M + 1)
        continue;

      bool match = true;
      for (int y = 0; y < M; y++)
      {
        for (int x = 0; x < M; x++)
        {
          if (A[ly + y][lx + x] != B[y][x])
            match = false;
        }
      }
      if (match)
        exist = true;
    }
  }
  if (exist)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int X;
  cin >> X;
  int a = 0;
  for (int i = 0; i < 10000; i++) {
    a += X;
    if (a % 360 == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;

ll n,m;

ll sum[100010];
vector<ll>a;

ll check(ll x){
    ll c = 0;
    for(ll i=0;i<n;i++){
        ll index = lower_bound(a.begin(),a.end(),x-a[i])-a.begin();
        c+=(n-index);
    }
    return c;
}

ll solve(ll x){
    ll ans = 0;
    for(ll i=0;i<n;i++){
        ll index = lower_bound(a.begin(),a.end(),x-a[i])-a.begin();
        ans += sum[n]-sum[index];
        ans += a[i]*(n-index);
    }
    return ans;
}

int main(void){
    cin>>n>>m;
    a.resize(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    sum[0]=0;
    sort(a.begin(),a.end());
    for(ll i=0;i<n;i++)sum[i+1]=sum[i]+a[i];
    ll ok = 0,ng = 200005;
    while(ng-ok>1){
        ll mid=(ng+ok)/2;
        if(check(mid)>=m)ok = mid;
        else ng = mid;
    }
    cout<<solve(ok)-(check(ok)-m)*ok<<endl;
    return 0;
}

Measured memory_bytes: 1920
object Main extends App {
  val input =  scala.io.StdIn.readLine()
  val AB = input.split(" ").map(_.toInt).toVector
  val a = AB(0)
  val b = AB(1)
  var tapCount = 0
  var plugCount = 1

  while(plugCount < b) {
    plugCount = plugCount - 1 + a
    tapCount += 1
  }
  println(tapCount)
}

Measured memory_bytes: 25660
n, m = gets.split.map(&:to_i)
ans = "0" * n
m.times do
    s, c = gets.split.map(&:to_i)
    if s == 1 && c == 0 && n != 1
        ans = "-1"
        break
    elsif ans[s - 1] == "0"
        ans[s - 1] = c.to_s
    elsif ans[s - 1] != c.to_s
        ans = "-1"
        break
    end
end
if ans[0] == "0" && n != 1
    ans[0] = "1"
end
puts ans.gsub(" ", "0")

Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MOD = (int)1e9 + 7;

const int MAX = 1000000;
bool IsPrime[MAX];
vector<int> Eratosthenes(int n = MAX) {
    vector<int> res;    // prime numbers
    IsPrime[0] = false; IsPrime[1] = false;
    for (int i = 2; i < n; ++i) IsPrime[i] = true;
    for (int i = 2; i < n; ++i) if (IsPrime[i]) {
        res.push_back(i);
        for (int j = i * 2; j < n; j += i) IsPrime[j] = false;
    }
    return res;
}

int main() {
    Eratosthenes();
    int n; cin >> n;
    long long ans = 1;
    for (int i = 1; i <= n; i++) if (IsPrime[i]) {
        int x = n, cnt = 0;
        while (x) cnt += (x /= i);
        (ans *= (cnt + 1)) %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1916
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        for (int i = x - k + 1; i <= x + k - 1; i++) {
            System.out.print(i + " ");
        }
    }
}

Measured memory_bytes: 22736
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> Pair;
typedef long long ll;
const ll MOD = 1E9 + 7;
int main()
{
	int n;
	scanf("%d", &n);
	vector<bool> b;
	vector<Pair> primes;
	b.resize(n + 1);
	for (int i = 2; i <= n; i++) {
		if (!b[i]) {
			primes.push_back(make_pair(i, 0));
			for (int j = i; j <= n; j += i) {
				b[j] = true;
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		for (auto it = primes.begin(); it != primes.end(); it++) {
			auto &e = *it;
			if (e.first > i) break;
			int t = i;
			while (t % e.first == 0) {
				e.second++;
				t /= e.first;
			}
		}
	}
	ll s = 1;
	for (auto e : primes)
		s = s * (e.second + 1) % MOD;
	cout << s << endl;
}


Measured memory_bytes: 384
n = int(input())
no_group = []
if n % 2 ==0:
  for  i in range(1,n//2+1):
    no_group.append([i,n-i+1])
else:
  for i in range(1,n//2+1):
    no_group.append([i,n-i])
  no_group.append([n])
  
sub_list = [[0 for i in range(n)] for i in range(n)]
for g in no_group:
  if len(g) == 2:
    sub_list[g[0]-1][g[1]-1] = 1
    sub_list[g[1]-1][g[0]-1] = 1
ans_list = []
for i in range(n):
  for j in range(i,n):
    if i != j and sub_list[i][j] == 0:
      ans_list.append([i+1,j+1])
      
print(len(ans_list))
for ans in ans_list:
  print(*ans)
    

Measured memory_bytes: 43632
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define deque vector
void Oli(){
//int n;
//int k;
//cin>>n>>k;
//int s=0;
//vector<string> b(n);
//for(int i=0;i<n;i++){
//    cin>>b[i];
//}
//for(int i=0;i<n;i++){
//    int c[10] ={0};
//    for(int j=0;j<b[i].size();j++){
//        c[(int)b[i][j] + 48]++;
//    }
//    int mn=0;
//    for(auto l:c)
//    cout<<l<<" ";
//    cout<<endl;
//    for(int l=0;l<10;l++){
//    cout<<c[l]<<" ";
//        if( c[l] == 0){
//            mn = l;
//            break;
//        }
//    }
//    if (mn!=0)
//    s+= mn  -k;
//    cout<<s<<endl;
//}
//cout<<s;
ll n,x,t;
cin>>n>>x>>t;
cout.precision(20);
cout<< ceil( (double)n/(double)x) * t;
}
int main(){
int times = 1;
//cin>>times;
while(times--)
Oli();
}


Measured memory_bytes: 3772
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;
import java.io.*;
//import java.util.stream.IntStream;



public class Main {

    public static class Node{
        Queue<Integer> child = new ArrayDeque<>();
    }
    static Node[] nodes;
    static int[] colors;
    static int[] d;
    static int distance;


    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        //BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //try{}
        
        int n = sc.nextInt();
        nodes = new Node[n+1];
        colors = new int[n+1];
        d = new int[n+1];


        for(int i=1;i<=n;i++){
            int id = sc.nextInt();
            int numChild = sc.nextInt();
            nodes[id] = new Node();
            for(int j=0;j<numChild;j++){
                int child = sc.nextInt();
                nodes[id].child.add(child);
            }
        }

        // 島を分けないのでfor文は使わない
         bfs(1);
         for(int i=2;i<=n;i++){
             if(d[i] == 0){d[i] = -1;}
         }


        StringBuffer buf = new StringBuffer();
        for(int i=1;i<=n;i++){
            buf.append(i + " " + d[i] + '\n');
        }
        System.out.print(buf);

    }

    public static void bfs(int id){
        Queue<Integer> queue = new ArrayDeque<>();
        queue.add(id);
        colors[id] = 1;
        d[id] = distance;

        while(!queue.isEmpty()){
            int u = queue.poll();
            
            int numChild = nodes[u].child.size();

            for(int i=0;i<numChild;i++){
                Integer v = nodes[u].child.poll();
                if(v != null && colors[v] == 0){
                    queue.add(v);
                    d[v] = d[u] + 1;
                    colors[v] = 1;
                }
            }
        }

    }
}





Measured memory_bytes: 27740
#include<cstdio>
int n,k;
struct permutation{
	int a[100100];
}p,q,_p,_q,g,_g,g_,_g_,ans,a[10],_a[10],E;
void times(permutation &ans,permutation x,permutation y){
	for(int i=1;i<=n;i++)
		ans.a[i]=x.a[y.a[i]];	
}
void inv(permutation &x,permutation y){
	for(int i=1;i<=n;i++)
		x.a[y.a[i]]=i;
}
void quickpow(permutation &ans,permutation x,int y){
	permutation res=x;
	ans=E;
	while(y){
		if(y&1) times(ans,ans,res);
		times(res,res,res);
		y>>=1;
	}
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		E.a[i]=i;
	for(int i=1;i<=n;i++)
		scanf("%d",&p.a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&q.a[i]);
	inv(_p,p);
	inv(_q,q);
	times(g,q,_p);
	times(g,g,_q);
	times(g,g,p);
	inv(_g,g);
	int R=(k-1)%6+1,Q=(k-R)/6;
	a[1]=p,a[2]=q,_a[1]=_p,_a[2]=_q;
	for(int i=3;i<=6;i++)
		times(a[i],a[i-1],_a[i-2]),inv(_a[i],a[i]);
	quickpow(g_,g,Q);
	quickpow(_g_,_g,Q);
	times(ans,g_,a[R]);
	times(ans,ans,_g_);
	for(int i=1;i<=n;i++)
		printf("%d ",ans.a[i]);
}

Measured memory_bytes: 20736
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int a;
	long long b, n;
	cin >> a >> b >> n;
	cout << a * min(b - 1, n) / b;
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ud(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep2(i, a, b) for (int i = a, i < b; ++i)
#define rep3(i, n) for (int i = n - 1; i >= 0; ++i)
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }

void solve(void) {
  int x;
  cin >> x;

  if (x >= 30)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
int main(void) { solve(); }


Measured memory_bytes: 3632
#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

int T;
string S;

int mod[10] = { 1, 5, 3, 3, 3, 3, 3, 4, 3, 4 };
char key[10][5] = {
  { '0', '0', '0', '0', '0' },
  { '.', ',', '!', '?', ' ' },
  { 'a', 'b', 'c', '0', '0' },
  { 'd', 'e', 'f', '0', '0' },
  { 'g', 'h', 'i', '0', '0' },
  { 'j', 'k', 'l', '0', '0' },
  { 'm', 'n', 'o', '0', '0' },
  { 'p', 'q', 'r', 's', '0' },
  { 't', 'u', 'v', '0', '0' },
  { 'w', 'x', 'y', 'z', '0' },
};

int main(void) {
  cin >> T;
  while(T--) {
    cin >> S;
    string ans = "";
    REP(i, 0, S.length()) {
      if(S[i] == '0') continue;
      int j;
      for(j = i; S[j] != '0'; j++);
      int n = S[i] - '0';
      int p = (j - i - 1) % mod[n];
      int k = key[n][p];
      ans += k;
      i = j;
    }
    cout << ans << endl;
  }
  return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

template<class T> inline bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    
    int cnt = 0;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cnt += a[i];
    }
    int sel = 0;
    for(int i = 0; i < n; i++){
        if(4*m*a[i] >= cnt){
            sel++;
        }
    }
    if(sel >= m){
        cout << "Yes" << endl;
    }
    else{
        cout<< "No" << endl;
    }
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)

	list := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&list[i])
	}

	total := int(math.Pow(3, float64(n)))
	odd := 1
	for i := 0; i < n; i++ {
		if list[i]%2 == 0 {
			odd *= 2
		} else {
			odd *= 1
		}
	}
	fmt.Println(total - odd)

}


Measured memory_bytes: 512
// Created by ...
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
//#define rep(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)

#define vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; i++)
#define pii pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)

using namespace std;
using ll = long long;

/*template<typename T>inline void in(T &x){x=0;register T c=inchar();while(((c<48)||(c>57))&&(c!='-'))c=inchar();bool neg=false;if(c=='-')neg=true;for(;c<48||c>57;c=inchar());for(;c>47&&c<58;c=inchar())x=(x<<3)+(x<<1)+(c&15);if(neg)x=-x;}
 template<typename T>inline void out(T n){if(n<0){outchar('-');n*=-1;}char snum[65];ll i=0;do {snum[i++]=n%10+'0';n/=10;}while(n);i=i-1;while(i>=0)outchar(snum[i--]);}
ll pr[M+1],freq[M+1];
ll fact[M+1],inv[M+1];*/

ll md=MD;
ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
//ll chose(ll n,ll k){ll r=fact[n]%md;r=(r+md)%md;r=r*inv[k]%md;r=(r+md)%md;r=r*inv[n-k]%md;r=(r+md)%md;return r;}

ll Min(ll a,ll b){if(a<b)return a; return b;}
int main() {
    ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    
        ll n,i;
        cin>>n;
        vll v(n+1);
        rep(i,1,n) cin>>v[i];
        vll dp(n+1);
        if(n==1){cout<<"0"<<endl; return 0;}
        dp[1]=0;dp[2]=abs(v[2]-v[1]);
        for(i=3;i<=n;++i)
        {
        	dp[i]=Min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
        }
        cout<<dp[n];
        
        cout<<'\n';
    return 0;
}

Measured memory_bytes: 1792
def main():
    s = input()
    s_list = list(s)
    s_list.sort()

    t = input()
    t_list = list(t)
    t_list.sort(reverse = True)

    for i in range(0,min(len(s_list),len(t_list))):
        if s_list[i] < t_list[i]:
            print("Yes")
            return
        elif s_list[i] > t_list[i]:
            print("No")
            return

    if len(s_list) < len(t_list):
        print("Yes")
    else:
        print("No")

    return

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long int ll;
int main(){
  int n;
  cin >> n;
  ll aa=1,b=1;
  ll t,a,s;
  for(int i=0;i<n;i++) {
    cin >> t>>a;
    aa=aa/t+(aa%t==0?0:1);
    b=b/a+(b%a==0?0:1);
    s=max(aa,b);
    aa=s*t; b=s*a;
  }
  cout << aa+b<<endl;
}


Measured memory_bytes: 256
n, t = list(map(int, input().split()))
box = []
cost = 9999
for i in range(n):
    box.append(list(map(int, input().split())))
    if box[i][1] <= t:
        if cost > box[i][0]:
            cost = box[i][0]

if cost == 9999:
    print("TLE")
else:
    print(cost)


Measured memory_bytes: 3060
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<complex>

#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 llong long long
#define pb(a) push_back(a)

using namespace std;

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




const ll INF = 1e9;


/******************************************************************************************/


int main() {

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

	
	int n, q;
	cin >> n >> q;
	vector<int> a(n);

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	sort(a.begin(), a.end());

	for (int i = 0; i < q; i++)
	{
		int l, r;
		cin >> l >> r;
		cout << upper_bound(a.begin(), a.end(), r) - lower_bound(a.begin(), a.end(), l) << endl;
	}


	return 0;
}



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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

template<typename T> struct MaxFlow {
	const T INF =  1LL<<59; 
	const int V;
	struct Edge { int to, rev; T cap; };
	vector<vector<Edge>> g;
	vector<int>  iter, level;
	MaxFlow(int su) : V(su), g(V) { };
	/// 辺の追加 有向辺 true, 無向辺 false
	void add(int from, int to, T cap, bool drc = true) {
		g[from].push_back(Edge{to, (int)g[to].size(), cap});
		g[to].push_back(Edge{from, (int)g[from].size()-1, drc? 0: cap});
	}
	void bfs(int s) {
		fill(level.begin(), level.end(), -1);
		queue<int> que;
		level[s] = 0;
		que.push(s);
		for(;!que.empty();) {
			int v = que.front(); que.pop();
			for(const Edge& e: g[v]) if(e.cap > 0){
				if (level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					que.push(e.to);
				}
			}
		}
	}
	T dfs(int v, int t, T f) {
		if (v == t) return f;
		for(int &i = iter[v]; i < (int)g[v].size(); i++) {
			Edge &e = g[v][i];
			if (e.cap <= 0) continue;
			if (level[v] < level[e.to]) {
				T d = dfs(e.to, t, min(f, e.cap));
				if (d <= 0) continue;
				e.cap -= d;
				g[e.to][e.rev].cap += d;
				return d;
			}
		}
		return 0;
	}
	// sからtへの最大流を返す
	T exec(int s, int t) {
		level.assign(V, -1);
		iter.assign(V, 0);
		T flow = 0;
		for(;;) {
			bfs(s);
			if (level[t] < 0) return flow;
			fill(iter.begin(), iter.end(), 0);
			T f;
			for(;(f = dfs(s, t, INF)) > 0;) flow += f;
		}
	}
};

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

	int n;
	cin >>n;
	VI a(n), b(n), c(n), d(n);
	rep(i, n) cin >>a[i] >>b[i];
	rep(i, n) cin >>c[i] >>d[i];
	
	MaxFlow<ll> mfw(2*n+2);
	rep(i, n) rep(j, n) if(a[i] < c[j] && b[i] < d[j]){
		mfw.add(i, n+j, 1);
	}
	rep(i, n){
		mfw.add(2*n,   i,   1);
		mfw.add(n+i, 2*n+1, 1);
	}
	
	cout << mfw.exec(2*n, 2*n+1) <<"\n";
	return 0;
}


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

struct P {
    int x, y;

    P() : x(0), y(0) { }
    P(int x, int y) : x(x), y(y) { }

    int norm() { return x * x + y * y; }
    int dot(P p) { return x * p.x + y * p.y; }
    int cross(P p) { return x * p.y - y * p.x; }

    P operator -() { return P(-x, -y); }
    P operator +(P p) { return P(x + p.x, y + p.y); }
    P operator -(P p) { return P(x - p.x, y - p.y); }
    P operator *(int k) { return P(x * k, y * k); }
};

const int MAX_N = 100;

int ccw(P p0, P p1, P p2) {
    P a = p1 - p0;
    P b = p2 - p0;

    if (a.cross(b) > 0) return 1;
    if (a.cross(b) < 0) return -1;
    if (a.dot(b) < 0) return 2;
    if (a.norm() < b.norm()) return -2;

    return 0;
}

int n;
P ps[MAX_N + 2];

int solve(int x, int y) {
    int c = 0;
    P p(x, y);

    for (int i = 0; i < n; i++) {
        P a = ps[i] - p;
        P b = ps[i + 1] - p;
        if (a.cross(b) == 0 && a.dot(b) <= 0) return 1;
        if (a.y > b.y) swap(a, b);
        if (a.y <= 0 && b.y > 0 && a.cross(b) > 0) c++;
    }

    return c % 2 ? 2 : 0;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;

        ps[i] = P(x, y);
    }
    ps[n] = ps[0];
    ps[n + 1] = ps[1];

    int q;
    cin >> q;

    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        cout << solve(x, y) << endl;
    }
}

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

using namespace std;
using ll = long long;
constexpr ll mod = 1e9+7;
constexpr ll md = mod;
constexpr ll inf = 1e15;
int main(){
    ll n;
    cin>>n;
    vector<vector<ll>> dp(62,vector<ll>(3));
    bitset<60> bs(n);
    dp[0][0] = 1;
    for(int i=0;i<=60;i++){
        if(bs[60-i]){
            dp[i+1][0] += dp[i][0];
            (dp[i+1][1] += dp[i][1] + dp[i][0])%= mod;
            (dp[i+1][2] += dp[i][2]*3%mod + dp[i][1]*2%mod)%= mod;
        }else{
            (dp[i+1][0] += dp[i][0] + dp[i][1] )%= mod;
            dp[i+1][1] += dp[i][1];
            (dp[i+1][2] += dp[i][1] + dp[i][2] * 3 %mod)%= mod;
        }
    }
    cout << ((dp[61][0] + dp[61][1])%mod + dp[61][2])%mod << endl;
    return 0;
}



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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

int a;
string s;

int main()
{
	cin >> a >> s;
	if ( a >= 3200 )
		cout << s;
	else
		cout << "red\n";
	return 0;
}


Measured memory_bytes: 256
package main

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

// const abcd = "abcdefghijklnmopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

// var dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1}
// var dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1}

// var dx = [...]int{0, 1, 0, -1}
// var dy = [...]int{1, 0, -1, 0}

var inf int = 1e9

// ---------------------------------------------------------
func main() {
	log.SetFlags(log.Lshortfile)
	next := newScanner()
	n := next.Int()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = next.Int()
	}
	num := map[int]int{}
	for i := 0; i < n; i++ {
		num[a[i]]++
	}
	ans := 0
	for _, m := range num {
		if m%2 != 0 {
			ans++
		}
	}

	fmt.Println(ans)
}

// ---------------------------------------------------------

// Pair is liked C++ pair
type Pair struct {
	a, b int
}

// Pairs is sorted by []Pair struct
type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a < p[j].a {
		return true
	} else if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return false
}

// -------------------------------
func in(c, a, z int) bool {
	return c >= a && c < z
}

func btoi(b bool) int {
	if b {
		return 1
	}
	return 0
}

func itob(a int) bool {
	if a == 0 {
		return false
	}
	return true
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ---------- buffered scanner -----------------------------------------
type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) Line() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) Int() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) Int64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 7808
#include<iostream>
using namespace std;
using ll=long long;

int main(){
    ll N;
    cin>>N;
    char c[N+1];
    ll w=0;
    ll r=0;
    for(int i=1;i<=N;i++){
        cin>>c[i];
        if(c[i]=='W'){
            w++;
        }else if(c[i]=='R'){
            r++;
        }
    }
    ll cnt=0;
    for(int i=1;i<=r;i++){
        if(c[i]=='W'){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}

const ll MOD = 1e9 + 7;
const ll MAX = 1e5 + 5; // 適宜
ll 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;
}
void mainsolve(){

	ll n,k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];

	if(k==1){
		cout << 0 << endl;
		return;
	}

	sort(a.begin(), a.end());
	COMinit();
	ll resmax = 0;
	ll resmin = 0;
	rep(i,n){
		(resmax += (COM(i,k-1) * a[i]) % MOD) %= MOD;
		(resmin += (COM(n-1-i,k-1) * a[i]) % MOD) %= MOD;
	}

	cout << (resmax - resmin + MOD) % MOD << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 3328
N, M = map(int, input().split())

from math import factorial
ans = 0
div = int(1e9 + 7)

diff = abs(N - M)
if diff < 2:
  x = factorial(N) % div
  y = factorial(M) % div
  ans = (x * y) % div

if diff == 0:
  ans = (ans * 2) % div
print(ans)

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int main()
{
    int n; cin >> n; int arr[n]; 
    int A = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
        A ^= arr[i];
    }
    int ans[n];
    for (int i = 0; i < n; i++)
        ans[i] = A ^ arr[i];
    cout << ans[0];
    for (int i = 1; i < n; i++)
        cout << " " << ans[i];
    cout << '\n';
    
    return 0;
}


Measured memory_bytes: 5000
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    string s, t, u;
    int a, b;

    cin >> s >> t >> a >> b >> u;
    if (s == u) {
        a = a - 1;
    }
    else if (t == u) {
        b = b - 1;
    }

    cout << a << " " << b << endl;

    return 0;
}


Measured memory_bytes: 256