akhauriyash/Code-Regression huggingface dataset:
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

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

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

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

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

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

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

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

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

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

func main() {
	sc := NewScanner()
	A, B, C, D := sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()
	if A+B > C+D {
		fmt.Println("Left")
		return
	} else if A+B < C+D {
		fmt.Println("Right")
		return
	} else {
		fmt.Println("Balanced")
		return
	}
}


Measured memory_bytes: 640
#include <stdio.h>

int main()
{
	int H, W, N;
	scanf("%d %d %d", &H, &W, &N);
	int a[10000];
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	int c[100][100];
	int i = 0;
	int y = 0;
	while (y < H) {
		for (int x = 0; x < W; x++) {
			a[i] -= 1;
			c[x][y] = i + 1;
			if (a[i] == 0) {
				i += 1;
			}
		}
		y += 1;
		if (y == H ) {
			break;
		}
		for (int x = W - 1; x >= 0; x--) {
			a[i] -= 1;
			c[x][y] = i + 1;
			if (a[i] == 0) {
				i += 1;
			}
		}
		y += 1;
	}
	for (int y = 0; y < H; y++) {
		for (int x = 0; x < W; x++) {
			printf("%d",c[x][y]);
			if (x < W - 1) {
				printf(" ");
			}
			else {
				printf("\n");
			}
		}
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n, i, fail, l, r, balls[10];
    
    scanf("%d", &n);
    
    while(n--){
        fail = l = r = 0;
    
        for(i = 0; i < 10; i++) scanf("%d", &balls[i]);
        
        for(i = 0; i < 10 && !fail; i++)
            if     (balls[i] > l) l = balls[i];
            else if(balls[i] > r) r = balls[i];
            else fail = 1;
                
        printf("%s\n", (fail ? "NO" : "YES"));
    }
 
    return 0;
}

Measured memory_bytes: 580
#editorial参照
#a,bとa+1,b+1での成立は同値でa=0のみ数える
n=int(input())
s=[input() for _ in range(n)]
ans=0
for i in range(n):
    s2=[s[b][i:]+s[b][:i] for b in range(n)]
    flag=True
    for b in range(n):
        for c in range(n):
            if s2[b][c]!=s2[c][b]:
                flag=False
                break
    ans+=flag

print(ans*n)


Measured memory_bytes: 63324
def solve(points) -> float:
  def all_shuffled(xs):
    if len(xs) == 0:
      return [[]]

    ret = []
    for i in range(len(xs)):
      ret += [[xs[i]] + shuffled for shuffled in all_shuffled(xs[0: i] + xs[i + 1: ])]
    return ret

  n = len(points)

  factorial_n = 1
  for i in range(1, n + 1):
    factorial_n *= i

  dist_sum = 0.0
  for ps in all_shuffled(points):
    for i in range(n - 1):
      xi, yi = ps[i]
      xj, yj = ps[i + 1]
      dist_sum += ((xi - xj) ** 2 + (yi - yj) ** 2) ** (1/2)

  return dist_sum / factorial_n


n = int(input().strip())
points = []
for i in range(n):
  l = input().strip()
  x, y = l.split()
  points.append((int(x), int(y)))

print(solve(points))


Measured memory_bytes: 9844
#include<stdio.h>
int mid_exam[150] = {0};
int f_exam[150] = {0};
int makeup_exam[150] = {0};
int main(){
int i;
for(i=0;;i++){
    scanf("%d %d %d",&mid_exam[i],&f_exam[i],&makeup_exam[i]);
    if(mid_exam[i]==-1 && f_exam[i]==-1 && makeup_exam[i]==-1)
        break;
}
for(int j=0;j<i;j++){
    int total = mid_exam[j] + f_exam[j];
    if(mid_exam[j] == -1 || f_exam[j] == -1){
        printf("F\n");
    }
    else if(total>= 80){
            printf("A\n");}
    else if(total>= 65 && total<80){
                printf("B\n");
            }
    else if(total>=50 && total<65){
        printf("C\n");
    }
    else if(total>=30 && total<50){
        if(makeup_exam[j]>=50){
            printf("C\n");}
    else { printf("D\n");
        }
    }
    else if(total<30){
        printf("F\n");
    }
}

return 0;
}



Measured memory_bytes: 2132
#include <stdio.h>

#define N 100000
#define Q 50000



int main(){
    int i,j,n,q;
    int cen;
    int S[N],T[Q];
    int cnt=0;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&S[i]);
    }
    cen = S[(n+1)/2];

    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&T[i]);
    }

    for(i=0;i<q;i++){
        if(cen > T[i]){
            for(j=0;j<n/2+1;j++){
                if(S[j] == T[i]){
                    cnt++;
                    break;
                }    
            }
        }
        else{
            for(j=n/2;j<n+1;j++){
                if(S[j] == T[i]){
                    cnt++;
                    break;
                }
            }
        }
    }
    printf("%d\n",cnt);
    return 0;
}



Measured memory_bytes: 2332
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e10;
const double EPS=1e-8;
const ll mod = 1000000007;


int main(){
	ll n;
	string s;
	cin>>n>>s;
	ll letter_count[3];
	for(ll i1=0;i1<3;i1++){
		letter_count[i1]=0;
	}
	for(ll i1=0;i1<n;i1++){
		if(s[i1]=='R'){
			letter_count[0]++;
		}else if(s[i1]=='G'){
			letter_count[1]++;
		}else{
			letter_count[2]++;
		}
	}
	ll ans = letter_count[0]*letter_count[1]*letter_count[2];
	for(ll i1=0;i1<n;i1++){
		for(ll i2=1;i2<=n/2+1;i2++){
			if(i1+2*i2>=n){
				break;
			}
			char t1,t2,t3;
			t1=s[i1];
			t2=s[i1+i2];
			t3=s[i1+2*i2];
			if(t1!=t2&&t2!=t3&&t3!=t1){
				ans--;
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3636
#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 a[210];  //最大 200 個なので余裕を持って 210 に --- 200 以上ならなんでもよい

int main() {
  int n;
  cin >> n;
  rep(i, n) cin >> a[i];

  // 偶数の場合は2でわる
  int ans = 0;

  // 無限ループ
  while(1) {
    bool odd = false;
    rep(i, n) {
      if(a[i]%2==1){
        odd = true;
      }
    }
    // 奇数が出てきたら無限ループ終了
    if(odd) break;
    ans++;
    // 全ての要素を2でわる
    rep(i, n) a[i]/=2;
  }
  cout << ans << endl;
  return 0;
};

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string S = in<string>();
    S[5] = ' ';
    S[13] = ' ';
    cout << S << "\n";
}

Measured memory_bytes: 256
a, b = input().split()
ab = int(a + b)


def bisearch(f, n):
    l = 0
    r = n
    fl = f(l)
    fr = f(r)
    while l <= r:
        m = (l + r) // 2
        fm = f(m)
        # print l,m,r,fl,fm,fr,n
        if fm == n:
            return m
        elif fm > n:
            r = m - 1
            fr = f(r)
        else:
            l = m + 1
            fl = f(l)


def try_square_root(n2):
    return bisearch(lambda n: n * n, n2)


if try_square_root(ab):
    print("Yes")
else:
    print("No")


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

using namespace std;

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

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

	string A; cin >> A;
	ll cnt[26] = {0LL};
	ll n = (ll)A.length();
	rep (i, n){
		++cnt[(int)(A[i] - 'a')];
	} // end rep 

	ll res = n * (n - 1LL) / 2LL;
	++res;
	rep (i, 26){
		res -= cnt[i] * (cnt[i] - 1LL) / 2LL;
	} // end rep

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 720
#include <stdio.h>
int main()
{
  int i,j,n,x,y;
  char c,t;
  int map[30][30];
  int r_x,r_y;
  for(;scanf("%d",&n),n;)
    {
      for(i=0;i<30;i++)
	for(j=0;j<30;j++)
	  map[i][j]=0;
      for(j=n;j--;)
	{
	  scanf("%d%d",&x,&y);
	  map[x][y]=1; 
	}
      scanf("%d",&j);
  	  getchar();
      for(r_y=10,r_x=10;j--;)
	{
	  i=0;
	  c=0;
	  while((t=getchar())!='\n')
	    {
	      if(t>='0' &&t<='9')
		{
		  i=i*10+t-'0';
		}
	      else if(t>'A' && t<'Z')
		{
		  c=t;
		}
	    }
	  for(;i--;)
	    {
	      if(c=='N')
		r_y++;
	      if(c=='E')
		r_x++;
	      if(c=='S')
		r_y--;
      if(c=='W')
		r_x--;
	      if(map[r_x][r_y]==1)
		{
		  map[r_x][r_y]=0;
		  n--;
		}
	    }
	}
      puts(n?"No":"Yes");
    }
  return 0;
}

Measured memory_bytes: 0
#include <atcoder/segtree>
#include <cstdio>
#include <vector>

using namespace std;
using namespace atcoder;

int op(int a, int b) { return max(a, b); }

int e() { return -1; }

int target;

bool f(int v) { return v < target; }

int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &(a[i]));
    }

    segtree<int, op, e> seg(a);

    for (int i = 0; i < q; i++) {
        int t;
        scanf("%d", &t);
        if (t == 1) {
            int x, v;
            scanf("%d %d", &x, &v);
            x--;
            seg.set(x, v);
        } else if (t == 2) {
            int l, r;
            scanf("%d %d", &l, &r);
            l--;
            printf("%d\n", seg.prod(l, r));
        } else if (t == 3) {
            int p;
            scanf("%d %d", &p, &target);
            p--;
            printf("%d\n", seg.max_right<f>(p) + 1);
        }
    }
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;
ll N;

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

vector<vector<int>> grid;
vector<ll> H, S;
vector<bool> seen;
vector<ll>sum;
vector<int> pl;

int main(int argc, char **argv){
	int n; cin>>n;
	vector<P> robo(n);

	rep(i,0,n){
		ll xi,li;cin>>xi>>li;
		robo[i]=make_pair(xi+li,xi-li);
	}

	sort(all(robo));

	ll ans=1;
	ll bord=robo[0].first;

	rep(i,1,n){
		if(robo[i].second>=bord){
			bord=robo[i].first;
			ans++;
		}
	}

	cout<<ans<<endl;
}


Measured memory_bytes: 1024
input = gets(nil).chomp

input.split("\n").each_slice(2) do |l1, l2|
  x = l1.to_f
  h = l2.to_f
  exit if x.zero? && h.zero?

  puts (x * Math.sqrt(((x/2)**2) + h**2) * 2) + (x**2)
end

Measured memory_bytes: 6152
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);

  int a = 0, b = 0, c = 0, d = 0;
  for(int i = 0; i < n; i++) {
    char str[5];
    scanf("%s", str);
    if(str[0] == 'A') a++;
    else if(str[0] == 'W') b++;
    else if(str[0] == 'T') c++;
    else d++;
  }
  printf("AC x %d\n", a);
  printf("WA x %d\n", b);
  printf("TLE x %d\n", c);
  printf("RE x %d\n", d);
  return 0;
}

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

using namespace std;

using ll = long long;
using p  = pair<ll, ll>;

// agc008b
ll N, K;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N >> K;
    vector<ll> A(N + 1, 0);
    for (ll i = 0; i <= N; i++) {
        cin >> A[i];
    }
    auto B = A;
    for (auto&& b : B) {
        b = max(0LL, b);
    }
    
    for (ll i = 1; i <= N; i++) {
        A[i] += A[i - 1];
        B[i] += max(0LL, B[i - 1]);
    }
    
    ll ans = 0;
    for (ll i = 0; i <= N - K; i++) {
        // white
        ll white = B.back() - (B[i + K] - B[i]);
        
        // black
        ll black = B.back() - (B[i + K] - B[i]) + (A[i + K] - A[i]);
        ans = max(ans, max(black, white));
    }
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include <iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {X=X;}
#define TF(f) {f=f;}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 1000000;
#define NMAX 50
#define MAX 10

    int N,A,B;
    priority_queue<ll> v;
    vector<ll> mo;
    ll temp=0,id=0,mem,yui=1,sum=0;
    long double ans,av=0;
    int TR[1000]={0},bf;
    ll C[200][200];
    bool fir=true;

void Conb(int N){
    for(int i=0;i<=N;i++){
        for(int j=0;j<=i;j++){
            if(j==0||j==i)C[i][j]=1;
            else{
                C[i][j]=C[i-1][j-1]+C[i-1][j];
            }
        }
    }
}



int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>A>>B;
    REP(i,N){
        cin>>temp;
        v.push(temp);
        mo.push_back(temp);
    }
    sort(mo.begin(),mo.end(),greater<ll>());
        ll bu=0;
        for(int j=A;j>0;j--){
            bu+=v.top();
            v.pop();
        }
         av=(double)bu/(double)A;

        int count=0;
        int lo=0;
        Conb(N);
        yui=0;
        REP(i,N){
            if(mo[i]==mo[A-1]){
                count++;
                if(i<=A-1)lo++;
            }
DEB(count)DEB(lo)DEB(mo[i])DEB(mo[A-1])END
        }
        if(mo[0]==mo[A-1]){
                FOR(i,A,B+1){
                yui+=C[count][i];
                }
        }else{
            yui=C[count][lo];
        }

    cout<<fixed<<av<<setprecision(10)<<endl<<yui<<endl;
}
//ABC057 Maximum Average Sets


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

#define ll long long
#define N 200010
int n, q;
int bb[N];
struct qnode {
	int op, a, b;
	void scan() {
		scanf("%d", &op);
		if (op == 1) {
			scanf("%d%d", &a, &b);
			bb[++n] = a; 
		}
	}
}qrr[N];  
void Hash() {
	sort(bb + 1, bb + 1 + n);
	n = unique(bb + 1, bb + 1 + n) - bb - 1;
}
int getid(int x) {
	return lower_bound(bb + 1, bb + 1 + n, x) - bb;
}
struct BIT {
	ll a[N];
	void init() {
		memset(a, 0, sizeof a);
	}
	void update(int x, ll val) {
		for (; x < N; x += x & -x) {
			a[x] += val;
		}
	}
	ll query(int x) {
		ll res = 0;
		for (; x > 0; x -= x & -x) {
			res += a[x];
		}
		return res;
	}
	ll query(int l, int r) {
		return query(r) - query(l - 1);
	}
}bit;
struct SEG {
	int sum[N << 2];
	void init() {
		memset(sum, 0, sizeof sum);
	}
	void update(int id, int l, int r, int pos) {
		if (l == r) {
			++sum[id];
			return;
		}
		int mid = (l + r) >> 1;
		if (pos <= mid) update(id << 1, l, mid, pos);
		else update(id << 1 | 1, mid + 1, r, pos);
		sum[id] = sum[id << 1] + sum[id << 1 | 1];
	}
	int query(int id, int l, int r, int ql, int qr) {
		if (ql > qr) {
			return 0;
		}
		if (l >= ql && r <= qr) {
			return sum[id];
		}
		int mid = (l + r) >> 1;
		int res = 0;
		if (ql <= mid) res += query(id << 1, l, mid, ql, qr);
		if (qr > mid) res += query(id << 1 | 1, mid + 1, r, ql, qr);
		return res;
	}
	int query(int id, int l, int r, int k) {
		if (l == r) {
			return l;
		}
		int mid = (l + r) >> 1;
		if (k <= sum[id << 1]) {
			return query(id << 1, l, mid, k);
		} else {
			return query(id << 1 | 1, mid + 1, r, k - sum[id << 1]); 
		} 
	}
}seg;


int main() {
	while (scanf("%d", &q) != EOF) {
		n = 0; 
		for (int i = 1; i <= q; ++i) {
			qrr[i].scan();
		}
		Hash();
		bit.init();
		seg.init();
		int tot = 0, mid, id;
		ll lazy = 0;  
		for (int i = 1; i <= q; ++i) {
			switch(qrr[i].op) {
				case 1 :
					++tot;
					lazy += qrr[i].b; 
					id = getid(qrr[i].a);
					seg.update(1, 1, n, id);
					bit.update(id, qrr[i].a);
					break;
				case 2 :
					mid = (tot + 1) / 2;
					id = seg.query(1, 1, n, mid);
					printf("%d %lld\n", bb[id], lazy + 1ll * (seg.query(1, 1, n, 1, id - 1) - seg.query(1, 1, n, id + 1, n)) * bb[id] + bit.query(id + 1, n) - bit.query(1, id - 1));
					break;
				default : 
					assert(0);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 10240
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<map>
using std::cin;using std::cerr;
using std::max;using std::min;
#define N 100005
#define ll long long
#define db double
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
int n,m,ans;
struct info
{
	int l,r;
	friend bool operator<(info t1,info t2) {return t1.r-t1.l<t2.r-t2.l;}
}A[N*3];
class BIT
{
	int t[N];
public:
	void add(int x,int v) {for(;x<=m;x+=x&-x) t[x]+=v;}
	int ask(int x) {int res=0;for(;x;x-=x&-x) res+=t[x];return res;}
}B;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d%d",&A[i].l,&A[i].r);
	std::sort(A+1,A+1+n);
	for(int i=1,j=1;i<=m;i++)
	{
		for(;A[j].r-A[j].l+1<i&&j<=n;j++) B.add(A[j].l,1),B.add(A[j].r+1,-1);
		ans=n-j+1;
		for(int k=i;k<=m;k+=i) ans+=B.ask(k);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3712
def FF(E, s, t, nn):
    G = [[] for _ in range(nn)]
    for a, b, f in E:
        G[a].append([b, f, len(G[b])])
        G[b].append([a, 0, len(G[a])-1])
    
    def dfs(s, t, f):
        if s == t:
            return f
        used[s] = 1
        for i, (b, _f, r) in enumerate(G[s]):
            if used[b] or _f == 0: continue
            d = dfs(b, t, min(f, _f))
            if d > 0:
                G[s][i][1] -= d
                G[b][r][1] += d
                return d
        return 0
    
    flow = 0
    while 1:
        used = [0] * nn
        f = dfs(s, t, 10**100)
        if f == 0:
            return flow, G
        flow += f

E = []
N, M = map(int, input().split())
A = [[a for a in input()] for _ in range(N)]
X = [[1 if a == "." else 0 for a in aa] for aa in A]
s = N * M
t = s + 1
for i in range(N):
    for j in range(M):
        if X[i][j]:
            if (i ^ j) & 1 == 0:
                E.append((s, i * M + j, 1))
            else:
                E.append((i * M + j, t, 1))

for i in range(N - 1):
    for j in range(M):
        if X[i][j] and X[i+1][j]:
            a = i * M + j
            b = a + M
            if (i ^ j) & 1 == 0:
                E.append((a, b, 1))
            else:
                E.append((b, a, 1))
for i in range(N):
    for j in range(M - 1):
        if X[i][j] and X[i][j+1]:
            a = i * M + j
            b = a + 1
            if (i ^ j) & 1 == 0:
                E.append((a, b, 1))
            else:
                E.append((b, a, 1))

D = {}
for a, b, v in E:
    D[(a << 16) + b] = v

ans, mf = FF(E, s, t, t + 1)
for a in range(t + 1):
    for b, w, _ in mf[a]:
        ab = (a << 16) + b
        if ab not in D: continue
        if w == 0:
            if a >= N * M or b >= N * M: continue
            aa, bb = a, b
            i, j = aa // M, aa % M
            ii, jj = bb // M, bb % M
            v = D[ab] - w
            aa, bb = (a, b) if a < b else (b, a)
            i, j = aa // M, aa % M
            ii, jj = bb // M, bb % M
            if i == ii:
                A[i][j] = ">"
                A[ii][jj] = "<"
            else:
                A[i][j] = "v"
                A[ii][jj] = "^"

print(ans)
for x in A:
    print("".join(map(str, x)))


Measured memory_bytes: 124012
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define MP make_pair
#define llu unsigned long long
#define U unsigned int
#define ff first
#define ss second
#define SIZE 100005
#define pie 3.14159265358979323
#define minuss 1e-6
#define pair pair<ll,ll>
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define BIG 1000000000
#define INF 1000000000000005
#define N 10000
vector<ll>vec;
map<string,ll> mps;
map<ll,string> mpss;
set<ll>s1;
set<string>s2;
map<string,ll>::iterator str;
set<ll>::iterator itr;
/*
std::cout << std::fixed;
std::cout << std::setprecision(1);
std::cout << VALUE NAME<<endl;
*/
ll tra[100006],tra1[100006];


int main()
{
    fast_cin;
    ll t;

        map<ll,ll>mp;
        map<ll,ll>::iterator it;
        string s,s1;
        ll lock=0,sum=0,co=0;
        ll n,m;
        cin>>n>>m;

        if(n<=(m*2))
            cout<<"0"<<endl;
        else
            cout<<n-(m*2)<<endl;




        s1.clear();
        vec.clear();

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n,m,sum=0;
    cin>>n>>m;
    int a[m];
    for(int i=0;i<m;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>n)
    {
        cout<<"-1"<<endl;
    }
    else if(sum==n)
    {
        cout<<"0"<<endl;
    }
    else
    {
        cout<<n-sum<<endl;
    }
}



Measured memory_bytes: 3644
n,l=map(int,input().split())
if (l<=0 and l+n-1>=0):
    print(int(n*(l+l+n-1)/2))
elif (l+n-1<=0):
    print(int(n*(l+l+n-1)/2-l-n+1))
else:
    print(int(n*(l+l+n-1)/2-l))

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
	int n, in;
	int max = 0, sum = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &in);
		if(in > max){
			sum += max;
			max = in;
		}else{
			sum += in;
		}
	}
	if(max < sum)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.util.Map.Entry;
 
 
 
public class Main{
	
	public int num;
	public int vol;
 
	
	//最大公約数・最小公倍数（セットで使う）
	public static long gcm(long a, long b) {
		long result = a;
		long k = 0;
		long n = b;
		do {
			k = result % n;
			result = n;
			n = k;
		} while(k != 0);
		return result;
	}
	
	public static long lcm(long a, long b) {
		long g;
		g = gcm(a, b);
		return a/g*b;
	}
	
	static long gcd (long a, long b) {
		long temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	
	//等差数列
	static long tousasum(int n) {
		return (long)n*((long)n+1)/2;
	}
 
 
 
	//素数判定
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
		return true;
	}
 
 
	//倍数判定（10進数以外のときに有用）
	static boolean isMultiple (String s, int base, int m) {
		int temp = 0;
		for (int i=0; i<s.length(); i++) {
			temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
		}
		if (temp==0) {return true;}
		return false;
	}
 
 
	//階乗
	static long factorial (int i) {
		if (i==1) {return 1;}
		else {return i*factorial(i-1);}
	}
 
 
	//進数変換
	static String toNbase (String sm, int m, int n) {
		return Long.toString(Long.parseLong(sm,m),n);
	}
	
	public static final long gcd_n(long[] param) {
	    final int len = param.length;
	    long g = gcd(param[0], param[1]);    //gcd(a, b) は以前作ったもの
	    for (int i = 1; i < len - 1; i++) {
	        g = gcd(g, param[i + 1]);       //gcd(a, b) は以前作ったもの
	    }
	    return g;
	}
	
	public static long lcm_n(long[] numbers) {
		long l;
		l = numbers[0];
		for (int i = 1; i < numbers.length; i++) {
			l = lcm(l, numbers[i]);
		}
		return l;
	}
	
	
 public static void main(String[] args) {
	 Scanner sc=new Scanner(System.in);
	int N=sc.nextInt(),K=sc.nextInt();
	int[] h=new int[N];
	int result=0;
	for(int i=0;i<N;i++) {
		h[i]=sc.nextInt();
		if(h[i]>=K) {
			result++;
		}
	}
	
   System.out.println(result);
 }
}

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

int main() {
string s;
cin >>s;
int cnt = 0,ans = 0;
for (int i = 0;i < 3;i++) {
  if (s.at(i) == 'R') cnt++;
  else cnt = 0;
  ans = max(ans,cnt);
}
cout << ans << endl;
return 0;
}



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

using namespace std;

int s[14];
int h[14];
int c[14];
int d[14];

int main()
{
    int n;
    cin >> n;
    for(int i = 0 ; i < n ; i++){
        int a;
        char ch;
        cin >> ch >> a;
        if(ch == 'S')s[a] = 1;
        else if(ch == 'H')h[a] =1;
        else if(ch == 'C')c[a] = 1;
        else if(ch == 'D')d[a] = 1;
    }
    for(int i  = 1 ; i < 14 ; i++){
        if(s[i] == 0)cout << "S " << i << endl;
    }
    for(int i  = 1 ; i < 14 ; i++){
        if(h[i] == 0)cout << "H " << i << endl;
    }
    for(int i  = 1 ; i < 14 ; i++){
        if(c[i] == 0)cout << "C " << i << endl;
    }
    for(int i  = 1 ; i < 14 ; i++){
        if(d[i] == 0)cout << "D " << i << endl;
    }
    return 0;
}



Measured memory_bytes: 3108
(n, x) = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort()
for i in range(len(a)):
    if a[i] <= x:
        x -= a[i]
        a[i] = 0
    if i == (len(a) - 1):
        a[i] -= x
print(a.count(0))

Measured memory_bytes: 3060
#include <iostream>
 
using namespace std;
 
int main(){
    
   char s, t, u;
    cin >> s;
    cin >> t;
    cin >> u;
    int sum = 0;
    
    if (s=='1'){
    	sum++;
     } else {
    	;
    }

   if (t=='1'){
		sum++;
		     } else {
    	;
    }
   
   if  (u=='1'){
   			sum++;
		     } else {
    	;
    }
    cout << sum<< endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
	string s;
	cin>>s;
	int g=0,p=0,ans=0;
	for(int i=0;i<s.length();i++){
		if(g==p){
			g++;
			if(s[i]=='p')ans--;
		}
		else{
			p++;
			if(s[i]=='g')ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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


int main(void){
    int a,b;
    cin>>a>>b;
    if(a==b)cout<<0<<endl;
    else{
        if((a+b)%2==0)cout<<(a+b)/2<<endl;
        else cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2020;
int n,m;bool fl;char c[N][N],t[N][N];
void solve(int n){
    if(n==1){c[1][1]=1;return;}
    solve(n-1);int m=1<<n-1;
    for(int i=1;i<m;i++)for(int j=1;j<m;j++)
        t[i][j]=t[i][j+m]=t[i+m][j]=t[i+m][j+m]=c[i][j];
    t[m][m]=1;
    for(int i=1;i<2*m;i++)for(int j=1;j<2*m;j++)c[i][j]=t[i][j];
}
int main(){
    scanf("%d%d",&n,&m);
    if(n<m)swap(n,m),fl=1;
    int pn=1<<n,pm=1<<m;
    solve(n);for(int i=1;i<pn;i++)for(int j=1;j<pn;j++)c[i][j]+='0';
    if(fl){
        for(int i=1;i<pn;i++)for(int j=i;j<pn;j++)swap(c[i][j],c[j][i]);
        for(int i=1;i<pm;i++)printf("%s\n",c[i]+1);
    }
    else for(int i=1;i<pn;i++)c[i][pm]=0,printf("%s\n",c[i]+1);
    return 0;
}

Measured memory_bytes: 7424
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int n;
	cin >> n;
	vector<int> a(n);
	multiset<int> s;
	for (auto &t : a) {
		cin >> t;
		s.insert(t);
	}
	for (auto t : a) {
		s.erase(s.find(t));
		cout << *s.rbegin() << ' ';
		s.insert(t);
	}
	cout << endl;
}


Measured memory_bytes: 11776
from sys import stdin, stdout
import math
inp = lambda : stdin.readline().strip()
 
n = int(inp())
a = []
b = []
for i in range(n):
    d1, d2 = [int(x) for x in inp().split()]
    a.append(d1)
    b.append(d2)
c = 0
for i in range(n):
    if  a[i] == b[i]:
        c += 1
    else:
        c = 0
    if c == 3:
        print("Yes")
        break
else:
    print("No")

Measured memory_bytes: 62224
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    string s;
    cin >> s;
    string t=s;
    reverse(t.begin(),t.end());
    string k="";
    rep(i,(s.size()-1)/2){
        k += s[i];
    }
    string k2 = k;
    reverse(k2.begin(),k2.end());
    string l = "";
    for(int i = (s.size()+3)/2-1;i<s.size();i++){
        l += s[i];
    }
    string l2 = l;
    reverse(l2.begin(),l2.end());
    if(s == t && k == k2 && l == l2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var N, H, W int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &H)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &W)

	ans := 0
	for i := 1; i+W-1 <= N; i++ {
		for j := 1; j+H-1 <= N; j++ {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
vector<int> v[1010];
bool visited[1010];
char c[1010][1010];
int dp[1010][1010][2];

int dfs(int cur){
    visited[cur] = true;
    int ret = 1;
    REP(i, (int)v[cur].size()){
        if(!visited[v[cur][i]]){
            ret += dfs(v[cur][i]);
        }
    }
    return ret;
}

int calc(int odd, int even, int unused){
    int &ret = dp[odd][even][unused];
    if(ret != -1){
        return ret;
    }

    if(odd + even == 2){
        return ret = unused;
    }
    if(unused == 1 && !calc(odd, even, !unused)){
        return ret = 1;
    }
    if(odd && even && !calc(odd, even - 1, !unused)){
        return ret = 1;
    }
    if(odd >= 2 && !calc(odd - 2, even + 1, unused)){
        return ret = 1;
    }
    if(even >= 2 && !calc(odd, even - 1, !unused)){
        return ret = 1;
    }
    return ret = 0;
}

int main(){
    cin >> n;
    REP(i, n){
        REP(j, n){
            cin >> c[i][j];
            if(c[i][j] == 'Y')v[i].emplace_back(j);
        }
    }
    int odd = 0, even = 0;
    int unused = 0;
    REP(i, n){
        if(!visited[i]){
            int cnt = dfs(i);
            unused += cnt * (cnt - 1)/2;
            if(cnt%2){
                odd++;
            }else{
                even++;
            }
        }
        for(int j = i + 1;j < n;j++){
            unused -= (c[i][j] == 'Y');
        }
    }
    unused %= 2;
    REP(i, 1010)REP(j, 1010)REP(k, 2)dp[i][j][k] = -1;
    if(calc(odd, even, unused)){
        cout << "Taro" << endl;
    }else{
        cout << "Hanako" << endl;
    }
}


Measured memory_bytes: 12180
<?php
  list($s) = explode(" ", trim(fgets(STDIN)));
  $s=intval($s);

  $ans=[0,0,0];
  for($i=3;$i<=$s;$i++){
    $ans[$i]=1;
    for($j=1;$j<=$i-3;$j++){
      $ans[$i]+=$ans[$j];
      $ans[$i]%=1000000007;
    }
  }

  echo $ans[$s];

Measured memory_bytes: 16244
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int C = sc.nextInt();
		boolean aa=false;
		for(int i=0;i<10;i++) {
			for(int j=0;j<10;j++) {
				if(C==i*j)aa=true;
			}
		}
		if(aa) {
			System.out.print("Yes");
		}else {
			System.out.print("No");
		}
		sc.close();
			}
		}

Measured memory_bytes: 25044
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void){

	int n,a,b,c,d=0,cal=0,cal2=0,d2=0,to=0,an=0;
	int x[1000]={0};
	cin>>n>>a>>b>>c;
	cal+=c;
	cal2=cal;
	d+=a;
	d2=d;
	to=cal/d;
	for(int i=0;i<n;i++){
        cin>>x[i];

	}
	sort(x,x+n);
	for(int i=n-1;i>=0;i--){
        cal2+=x[i];
        d2+=b;
        an=cal2/d2;
        if(an<to)break;
        to=an;
	}
    cout<<to<<endl;

	return 0;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define INF LLONG_MAX/2
#define PI acos(-1.0)
#define MOD 1000000007

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

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;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m=MOD){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int count(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    int n,k;
    cin>>n>>k;
    Vi route(k+1);
    REPR(i,k,0){
        route[i]=mypow(k/i,n);
        for(int j=2; ;j++){
            if(i*j>k) break;
            route[i] -= route[i*j];
        }
        while(route[i]<0) route[i] += MOD;
    }
    //vout(route);
    int ans=0;
    REP(i,1,k+1){
        ans = (ans+route[i]*i)%MOD;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    friend std::istream &operator>>(std::istream &in, mint &o) {
        ll a;
        in >> a;
        o = a;
        return in;
    }

    friend std::ostream &operator<<(std::ostream &out, const mint &o) {
        out << o.x;
        return out;
    }

};


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

    mint ans = 1;

    int a = 0, b = 0, c = 0;
    rep(i, n) {
        int k = claim[i];
        int f = 0;
        if (a == k) f++;
        if (b == k) f++;
        if (c == k) f++;

        ans *= f;

        if (a == k) a++;
        else if (b == k)b++;
        else if (c == k) c++;

    }

    cout << ans << endl;

}


Measured memory_bytes: 3668
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
 
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  
  int r;
  cin >> r;

  cout << 2 * 3.1415926535 * r << endl;

  return 0;
}


Measured memory_bytes: 3800
n,C=map(int,input().split())
schedule=[]
time=[[0 for i in range(C)] for j in range(2*10**5+2)]

for i in range(n):
    s,t,c=map(int,input().split())
    schedule.append([s,t,c])

schedule.sort()

for s,t,c in schedule:
    if time[2*s][c-1]==-1:
        time[2*s][c-1]+=1
    else:
        time[2*s-1][c-1]+=1
    time[2*t][c-1]-=1

for i in range(2*10**5+1):
    for j in range(C):
        time[i+1][j]+=time[i][j]
ans=1
for i in range(2*10**5+2):
    tmp=0
    for j in range(C):
        tmp+=time[i][j]
    ans=max(ans,tmp)

print(ans)




Measured memory_bytes: 126556
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;

int a[80][80],b[80][80];
bool dp[81][81][26000];

template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}

signed main(){
  int h,w;cin>>h>>w;
  for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>a[i][j];
  for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>b[i][j];
  dp[0][0][13000]=1;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      for(int k=100;k<25000;k++){
        if(!dp[i][j][k])continue;
        dp[i+1][j][k+a[i][j]-b[i][j]]=dp[i+1][j][k-a[i][j]+b[i][j]]=1;
        dp[i][j+1][k+a[i][j]-b[i][j]]=dp[i][j+1][k-a[i][j]+b[i][j]]=1;
      }
    }
  }
  int ans=INF;
  for(int k=0;k<26000;k++)if(dp[h][w-1][k])chmin(ans,abs(k-13000));
  cout<<ans<<endl;
}


Measured memory_bytes: 165632
#include <iostream>

using namespace std;

int main(void){
    int k,x;
    cin >> k >> x;
    for(int i=x-k+1000001;i<x+k+1000000;i++){
        cout << i-1000000;
        if(i!=x+k+999999)cout << " ";
    }
    cout << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

void depth_init();
void depth();
void visit(int);
int t_time=0;
int n;
int d[MAX];
int f[MAX];
int c[MAX];
int M[MAX][MAX];

int main(){
  int i=0,j=0;;
  int u;
  int k;
  int v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  depth_init();
  depth();
  
  return 0;
}

void depth_init(){
  int i=0;
  for(i=0;i<n;i++) {
    c[i]=WHITE;
  }
  t_time=0;
}

void depth(){
  int i=0;
  for(i=0;i<n;i++){
    if(c[i]==WHITE)visit(i);
  }

  for(i=0;i<n;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
}


void visit(int u){
  int v;
  c[u]=GRAY;
  d[u]=++t_time;

  for(v=0;v<n;v++){
    if(M[u][v]==0) continue;
    if(c[v]==WHITE){
      visit(v);
    }
  }
  c[u]=BLACK;
  f[u]=++t_time;
}



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

using namespace std;

const int MOD = 998244353;
const int MaxN = 303;

int a[MaxN][MaxN];
int n, m;

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);

    cin >> n >> m;
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= m; ++j)
            cin >> a[i][j];

    int r = 0;

    for(int i = 1; i <= m; ++i)
    {
        int y = 0;
        for(int j = 1; y == 0 && j <= n; ++j)
            if(a[j][i] == 1)
                y = j;

        if(!y)
            continue;

        ++r;

        for(int j = 1; j <= n; ++j)
            if(a[j][i] == 1 && j != y)
                for(int k = i; k <= m; ++k)
                    a[j][k] ^= a[y][k];

        for(int k = i; k <= m; ++k)
            a[y][k] = 0;
    }

    int ans = 1;

    for(int i = 1; i <= n + m - 1; ++i)
        ans = (ans + ans) % MOD;

    int s = 1;
    for(int i = 1; i <= n + m - 1 - r; ++i)
        s = (s + s) % MOD;

    ans -= s;

    if(ans < 0)
        ans += MOD;
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 640
n, m = map(int, input().split())
a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]
for i in range(n - m + 1):
  for j in range(n - m + 1):
    ans = 0
    for k in range(m):
      for l in range(m):
        if b[k][l] == a[k + i][l + j]:
          ans += 1
    if ans == m * m:
      print("Yes")
      exit()
print("No")

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  //B
  int a, b, k;
  cin >> a >> b >> k;
  int itr = 1;
  vector<int> ans;
  while (itr <= a && itr <= b) {
    if (a % itr == 0 && b % itr == 0) ans.push_back(itr);
    itr++;
  }
  cout << *(ans.end() - k) << endl;
  return 0;	
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    W, H, N = map(int, readline().split())
    xl = 0
    xr = W
    yl = 0
    yh = H
    for _ in range(N):
        x, y, a = map(int, readline().split())
        if a==1:
            xl = max(xl,x)
        elif a==2:
            xr = min(xr,x)
        elif a==3:
            yl = max(yl,y)
        else:
            yh = min(yh,y)
    print(max(xr-xl,0)*max(yh-yl,0))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fi first
#define se second
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
#define pb push_back
#define IT iterator
#define SZ(a) ((int)a.size())
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N=17,size=1<<20,mod=998244353,inf=2e9;

template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

//math
ll mult(ll a,ll b,ll p) {
	a=(a%p+p)%p; b=(b%p+p)%p;
	ll c=(ld)a*b/p;
	return a*b-c*p;
}
ll gcd(ll a,ll b) {return !a?b:gcd(b%a,a);}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
ll power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=c*a%mod;
		b /= 2; a=a*a%mod;
	}
	return c;
}
ll Power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=mult(c,a,mod);
		b /= 2; a=mult(a,a,mod);
	}
	return c;
}

ll n,x[N],y[N],p[N],w[1<<N],f[1<<N][N],lg[1<<N];

struct rec {
	ll x,y;
	bool operator <(rec b) const {
		return x<b.x;
	}
} a[N];

ll calc(int now) {
	ll tot,s,ans=1e18,tmp,mid;
	
	tot=s=0;
	for(int i=0;i<n;i++)
		if(now>>i&1) a[++tot]=(rec){x[i],p[i]},s+=p[i];
	sort(a+1,a+tot+1);
	mid=s+1>>1;
	for(int i=1;i<=tot;i++)
		if(mid<=a[i].y) {
			tmp=0;
			for(int j=1;j<=tot;j++) tmp+=a[j].y*abs(a[i].x-a[j].x);
			ans=min(ans,tmp); break;
		}
		else mid-=a[i].y;
	
	tot=s=0;
	for(int i=0;i<n;i++)
		if(now>>i&1) a[++tot]=(rec){y[i],p[i]},s+=p[i];
	sort(a+1,a+tot+1);
	mid=s+1>>1;
	for(int i=1;i<=tot;i++)
		if(mid<=a[i].y) {
			tmp=0;
			for(int j=1;j<=tot;j++) tmp+=a[j].y*abs(a[i].x-a[j].x);
			ans=min(ans,tmp); break;
		}
		else mid-=a[i].y;
	
	return ans;
}

int main() {
	qr(n);
	for(int i=0;i<=n;i++) lg[1<<i]=i;
	for(int i=0;i<n;i++)
		qr(x[i]),qr(y[i]),qr(p[i]);
	int s=(1<<n)-1;
	memset(f,63,sizeof f);
	f[0][0]=0;
	for(int i=1;i<=s;i++) {
		f[i][0]=f[i&(i-1)][0];
		int j=lg[i&-i];
		f[i][0] += min(abs(x[j]),abs(y[j]))*p[j];
	}
	pr2(f[s][0]);
	for(int i=1;i<(1<<n);i++) w[i]=calc(i);
	for(int t=1;t<=n;t++) {
 		for(int i=1;i<=s;i++)
			for(int j=i;	;j=(j-1)&i) {
				f[i][t]=min(f[i][t],f[j][t-1]+w[i^j]);
				if(!j) break;
			}
		pr2(f[s][t]);
	}
	return 0;
}

Measured memory_bytes: 21336