akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>

using namespace std;

int main(){
  int h, w;
  char s[50][50];
  cin >> h >> w;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> s[i][j];
    }
  }
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      vector<int> row;
      vector<int> col;
      int count = 0;
      if(i > 0){
        row.push_back(-1);
        col.push_back(0);
        count++;
      }
      if(j > 0){
        row.push_back(0);
        col.push_back(-1);
        count++;
      }
      if(i < h-1){
        row.push_back(1);
        col.push_back(0);
        count++;
      }
      if(j < w-1){
        row.push_back(0);
        col.push_back(1);
        count++;
      }
      if(s[i][j] == '#'){
        int a = 0;
        for(int k = 0; k < count; k++){
          if(s[i + row[k]][j + col[k]] == '#'){
            a++;
          }
        }
        if(a == 0){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b, c = MAP()
for i in range(b):
    if a * i % b == c:
        print("YES")
        exit()
print("NO")


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

#define ll long long
#define ull unsigned long long
#define ld long double

#define tiii tuple < int, int, int >
#define pii pair < int, int >
#define pll pair < ll, ll >
#define pci pair < char, int >
#define psi pair < string, int >
#define pis pair < int, string >

#define vi vector < int >
#define vd vector < double >
#define vld vector < ld >
#define vll vector < ll >
#define vs vector < string >
#define vc vector < char >
#define vpi vector < pii >
#define vpll vector < pll >
#define vpis vector < pis >

#define pb push_back
#define mt make_tuple
#define gt0 get < 0 >
#define gt1 get < 1 >
#define gt2 get < 2 >

#define pi acos(-1)

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

const int maxn = 1e5 + 5;
const int mod = 1e9 + 9;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    fast;

    string s;

    cin >> s;

    int cnt = 0;

    if(s == "RRR"){
        cout << 3 << endl;
        return 0;
    }

    if(s == "RRS" || s == "SRR"){
        cout << 2 << endl;
        return 0;
    }

    if(find(s.begin(), s.end(), 'R') != s.end()){
        cout << 1 << endl;
        return 0;
    }

    cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define range(i,a,b) for(long long i = (a); i < (b); i++)
#define rep(i,b) for(long long i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;
 
template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}
template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

// 右，左のくみあわせ 4通り
// 神社が先か寺が先か 2通り
// 合計8通り

const int INF = 1LL << 60;

pair<int,int> getLocation(vector<int>& a, int x){
	int l, r;
	auto it = lower_bound(all(a), x);
	if(*it == x){
		l = r = x;
	}else{
		r = *it;
		l = *(prev(it, 1));
	}
	return make_pair(l, r);
}

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

	vector<int> s(a + 2), t(b + 2);
	s[0] = -INF;
	rep(i,a) cin >> s[i + 1];
	s[a + 1] = INF;

	t[0] = -INF;
	rep(i,b) cin >> t[i + 1];
	t[b + 1] = INF;

	rep(i,q){
		int x;
		cin >> x;

		int ls, rs, lt, rt;
		tie(ls, rs) = getLocation(s, x);
		tie(lt, rt) = getLocation(t, x);
		//cout << ls << ' ' << rs << endl;
		//cout << lt << ' ' << rt << endl;

		int ans = INF;
		// r, r
		ans = min(ans, abs(x - rs) + abs(rs - rt));
		ans = min(ans, abs(x - rt) + abs(rt - rs));
		// r, l
		ans = min(ans, abs(x - rs) + abs(rs - lt));
		ans = min(ans, abs(x - rt) + abs(rt - ls));
		// l, r
		ans = min(ans, abs(x - ls) + abs(ls - rt));
		ans = min(ans, abs(x - lt) + abs(lt - rs));
		// l, l
		ans = min(ans, abs(x - ls) + abs(ls - lt));
		ans = min(ans, abs(x - lt) + abs(lt - ls));

		cout << ans << endl;
	}
}


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

using namespace std;

int main() {
	int H, W;
	cin >> H >> W;
	int ans = INT_MAX;
	int A[3];
	A[0] = H / 3 * W;
	A[1] = ( H - H / 3 )*( W / 2 );
	A[2] = ( H - H / 3 )*( W - W / 2 );
	ans = min( ans, max( A[0], max( A[1], A[2] ) ) - min( A[0], min( A[1], A[2] ) ) );
	A[0] = ( H / 3 + 1 ) * W;
	A[1] = ( H - H / 3 - 1 )*( W / 2 );
	A[2] = ( H - H / 3 - 1 )*( W - W / 2 );
	ans = min( ans, max( A[0], max( A[1], A[2] ) ) - min( A[0], min( A[1], A[2] ) ) );

	A[0] = H / 3 * W;
	A[1] = ( H - H / 3 ) / 2 * ( W );
	A[2] = ( ( H - H / 3 ) - ( H - H / 3 ) / 2 )*( W );
	ans = min( ans, max( A[0], max( A[1], A[2] ) ) - min( A[0], min( A[1], A[2] ) ) );

	swap( H, W );

	A[0] = H / 3 * W;
	A[1] = ( H - H / 3 )*( W / 2 );
	A[2] = ( H - H / 3 )*( W - W / 2 );
	ans = min( ans, max( A[0], max( A[1], A[2] ) ) - min( A[0], min( A[1], A[2] ) ) );
	A[0] = ( H / 3 + 1 ) * W;
	A[1] = ( H - H / 3 - 1 )*( W / 2 );
	A[2] = ( H - H / 3 - 1 )*( W - W / 2 );
	ans = min( ans, max( A[0], max( A[1], A[2] ) ) - min( A[0], min( A[1], A[2] ) ) );

	A[0] = H / 3 * W;
	A[1] = ( H - H / 3 ) / 2 * ( W );
	A[2] = ( ( H - H / 3 ) - ( H - H / 3 ) / 2 )*( W );
	ans = min( ans, max( A[0], max( A[1], A[2] ) ) - min( A[0], min( A[1], A[2] ) ) );
	cout << ans << endl;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N = 3;
    vi A(N); REP(i,N) cin >> A[i];
    int K; cin >> K;

    sort(A.begin(), A.end(), greater<int>());
    REP(i, K) A[0] *= 2;

    int ans = 0;
    REP(i, N) ans += A[i];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s;
    cin>>s;
    int k=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'&&s[i+1]=='C')
            k=1;
    }
    if(k==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

A.sort(reverse = True)
one = 0
two = 0
idx = 1
while idx < N:
  if A[idx-1]==A[idx]:
    one = A[idx]
    break
  idx += 1
idx += 2
while idx < N:
  if A[idx-1]==A[idx]:
    two =A[idx]
    break
  idx += 1
print(one*two)

Measured memory_bytes: 14244
n=int(input())
ans={}
for i in range(n):
    val=''.join(sorted(input()))
    if not val in ans:
        ans[val]=1
    else:
        ans[val]+=1

res=0
for key in ans.keys():
    res += int((ans[key] * (ans[key]-1)) / 2)

print(res)

Measured memory_bytes: 17848
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

vector<ll> ans;

void dfs( ll x ){
	if( x > 3234566667 ) return;
	ans.push_back(x);
	int t = x%10;
	if( t != 0 ) dfs( 10*x+t-1 );
	dfs( 10*x+t );
	if( t != 9 ) dfs( 10*x+t+1 );
}

int main(){
	for( int k = 1; k <= 9; ++k ) dfs(k);
	sort( ans.begin(), ans.end() );
	int k; cin >> k;
	cout << ans[k-1] << endl;
}

Measured memory_bytes: 1400
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {

	static BufferedReader reader;
	final static boolean MODE_DEBUG = false;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		long[] a = readLineLong();
		long A = a[0];
		long B = a[1];
		long N = a[2];
		
		long max_xB = 0;
		long max_x = 0;
		long loop_cnt = 0;
		for(long x=B-1;x<N;x+=B) {
			long calc = (A*x)/B-A*(x/B);
			if(calc>max_xB) {
				max_xB = calc;
				max_x = x;
			}
			loop_cnt++;
			if(loop_cnt<=A) {break;}
		}
		long calc = (A*N)/B-A*(N/B);
		if(calc>max_xB) {
			max_xB = calc;
			max_x = N;
		}
		print(max_xB);
	}
	
	//functions here
	//note that all methods should be STATIC


	private static <T> int arraySearch(T needle, T[] heystack) {
		for(int i=0;i<heystack.length;i++) {
			if(needle.equals(heystack[i])) {
				return i;
			}
		}
		return -1;
	}
	private static int[] sort(int[] base) {
		int[] copy = array_copy(base);
		Arrays.sort(copy);
		return copy;
	}
	private static int[] array_copy(int[] base) {
		int[] copy = new int[base.length];
		for(int i=0;i<base.length;i++) {
			copy[i] = base[i];
		}
		return copy;
	}
	private static int[] asArray(ArrayList<Integer> ints) {
		int[] intlist = new int[ints.size()];
		for(int i=0;i<intlist.length;i++) {
			intlist[i] = ints.get(i);
		}
		return intlist;
	}
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static int[] readLineInt(){
		try{
			String[] s = readLine();
			int[] ints = new int[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Integer.parseInt(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static long[] readLineLong(){
		try{
			String[] s = readLine();
			long[] ints = new long[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Long.parseLong(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static byte[] readLineByte(){
		try{
			String[] s = readLine();
			byte[] bytes = new byte[s.length];
			for(int i=0;i<bytes.length;i++) {
				bytes[i] = Byte.parseByte(s[i]);
			}
			return bytes;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static char[] readLineChar(){
		try{
			String[] s = readLine();
			char[] chars = new char[s.length];
			for(int i=0;i<chars.length;i++) {
				chars[i] = (char)Integer.parseInt(s[i]);
			}
			return chars;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
	private static void printd(Object o){
		if(MODE_DEBUG)System.err.println(o);
	}
	private static void printd(){
		if(MODE_DEBUG)System.err.println();
	}
}


Measured memory_bytes: 32668
#include <stdio.h>

int main(void)
{
	int car[10];
	int i;
	int n;
	
	i = 0;
	while (scanf("%d", &n) != EOF){
		if (n == 0){
			i--;
			printf("%d\n", car[i]);
		}
		else {
			car[i] = n;
			i++;
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long

signed main() {
  int d;
  cin >> d;
  vector<pair<int,int>> c(26);
  vector<int> cc(26);
  vector<int> dd(26);
  vector<int> t;
  rep(i,26) {
    int x;
    cin >> x;
    c[i] = {-x,i};
    cc[i]=x;
  }
  sort(c.begin(),c.end());
  
  vector<vector<int>> s(d);
  int ans = 0;
  rep(i,d) {
    int ma = 0;
    rep(j,26) {
      int num;
      cin >> num;
      ma = max(ma,num+cc[j]);
      if(ma==num+cc[j]) ans = j+1;
      s[i].push_back(num);
    }
    rep(j,26) {
      if(ans-1!=j) cc[j]+=dd[j];
      else cc[j]=dd[j];
    }
    //sort(s.begin(),s.end());
    //cout << ans << endl;
  }
  
  int cnt = 0;
  rep(i,d) {
    t.push_back(c[cnt].second+1);
    cnt++;
    cnt%=26;
  }

  cnt=0;
  while(cnt<5) {
  rep(i,d/13) {
    FOR(j,i*13+1,i*13+12) {
      if(j+13+cnt>=360) break;

      if(s[j][t[j]-1]<s[j+13+cnt][t[j]-1]+1000) {
        swap(t[j],t[j+1]);
      }
    }
  }
  cnt++;
  }

  rep(i,d) {
    cout << t[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3760
#include<stdio.h>
int main(){
  int i=0,j=0,v,N=15,k=0,l;
  int A[125];

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
     }
  for(i=0;i<N;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1] = v;

    for(l=0;l<N;++l){
      if(l!=N-1){
      printf("%d",A[l]);
      printf(" ");}
      if(l==N-1&&i!=N-1){
        printf("%d",A[l]);
      }
      if(l==N-1&&i==N-1){
        printf("%d",A[l]);
      }

    }
    printf("\n");
  }

  return 0;
}




Measured memory_bytes: 2088
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    a, b = LI()
    print(max(0, a -2*b))

if __name__ == '__main__':
    main()

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

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<int> c(9, 0);
    for(int i=0; i<N; i++){
        int x;
        cin >> x;
        if(x >= 3200){
            c[8]++;
            continue;
        }
        c[x/400]++;
    }
    int min = 0, max = 0;
    for(int i=0;i<8;i++){
        if(c[i] != 0) {
            min++;
            max++;
        }
    }
    if(min==0 && c[8] != 0) min = 1;
    max += c[8];

    cout << min << " " << max << endl;
    return 0;
}

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

#define rep(i, a, b) for (int i = a; i < (b); i++)
#define trav(a, x) for (auto & a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define endl "\n"
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int MAXN = 500'010;

int N, Q;
int cnt[MAXN], C[MAXN];
int diff = 0;

void add(int ind) {
  if(++cnt[C[ind]] == 1) diff++;
} // add a[ind]
void del(int ind) {
  if(--cnt[C[ind]] == 0) diff--;
} // remove a[ind]
int calc() { return diff; } // compute current answer

vi mo(vector<pii> Q) {
	int L = 0, R = 0, blk = 700; // ~N/sqrt(Q)
	vi s(sz(Q)), res = s;
#define K(x) pii(x.first/blk, x.second ^ -(x.first/blk & 1))
	iota(all(s), 0);
	sort(all(s), [&](int s, int t){ return K(Q[s]) < K(Q[t]); });
	trav(qi, s) {
		pii q = Q[qi];
		while (L > q.first) add(--L);
		while (R < q.second) add(R++);
		while (L < q.first) del(L++);
		while (R > q.second) del(--R);
		res[qi] = calc();
	}
	return res;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);

	cin >> N >> Q;
	fill(cnt, cnt+N+1, 0);

	rep(i, 0, N) cin >> C[i];

	vector<pii> Qs(Q);
	trav(q, Qs) cin >> q.first >> q.second, --q.first;

	vi ans = mo(Qs);
	rep(i, 0, Q) cout << ans[i] << endl;
}


Measured memory_bytes: 18756
#include<queue>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
inline void read(int &x)
{
	x=0;
	int p=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c^'0');c=getchar();}
	x*=p;
}
char s[60];
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	scanf("%s",s+1);
	int len=strlen(s+1);
	for(int i=1;i<=len-8;i++)printf("%c",s[i]);
	return 0;
}

Measured memory_bytes: 256
# frozen_string_literal: true

n = gets.to_i
s = n.times.map { gets.chomp }
h = Hash.new { 0 }
s.each do |e|
  h[e] += 1
end
%w[AC WA TLE RE].each do |e|
  puts e + ' x ' + h[e].to_s
end


Measured memory_bytes: 20640
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    int count=0;
    for(int i=0;i<s.length();i++){
      if(s.charAt(i)=='S'){
        count++;
      }else if(count>0){
        count--;
      }
    }
    System.out.println(count*2);
  }
}

Measured memory_bytes: 25560
#include <stdio.h>

int main(void) {
	int N, H, W;
	if (scanf("%d", &N) != 1) return 1;
	if (scanf("%d", &H) != 1) return 1;
	if (scanf("%d", &W) != 1) return 1;
	printf("%d\n", (N - H + 1) * (N - W + 1));
	return 0;
}


Measured memory_bytes: 1700
#include<iostream>
#include<vector>
using namespace std;
#define pb push_back
#define vi vector<int>
#define vvi vector<vi>

int n,m,ans;
vvi e;
vi dp;

int dfs(int x)
{
	if(dp[x]!=-1) return dp[x];
	for(int i=0;i<e[x].size();i++)
		dp[x]=max(dp[x],dfs(e[x][i])+1);
	return dp[x]; 
} 

int main()
{
	
	cin>>n>>m;
	e.resize(n);
	dp.resize(n,-1);
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		x--;
		y--;
		e[x].pb(y);
	}
	for(int i=0;i<n;i++)
		ans=max(ans,dfs(i));
	cout<<ans+1<<'\n';
	
	return 0;
} 

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

#define MAX 25
#define NIL -1

struct Node{
    int p,l,r;
};

struct Node T[MAX];

void print(int u){
    cout << " " << u;
}

void preorder(int u){
    if(u == NIL)    return;

    print(u);
    preorder(T[u].l);
    preorder(T[u].r);
}

void inorder(int u){
    if(u == NIL)     return;

    inorder(T[u].l);
    print(u);
    inorder(T[u].r);
}

void postorder(int u){
    if(u == NIL)     return;

    postorder(T[u].l);
    postorder(T[u].r);
    print(u);
}

int main(){
    int n, id, left, right;
    cin >> n;
    for(int i = 0; i < n; i++){
        T[i].p = NIL;
    }

    for(int i = 0; i < n; i++){
        cin >> id >> left >> right;
        T[id].l = left;
        T[id].r = right;
        if(left != NIL) T[left].p = id;
        if(right != NIL) T[right].p = id;
    }

    int root = 0;
    while(T[root].p != NIL){
        root = T[root].p;
    }

    cout << "Preorder" << endl;
    preorder(root);
    cout << endl;
    cout << "Inorder" << endl;
    inorder(root);
    cout << endl;
    cout << "Postorder" << endl;
    postorder(root);
    cout << endl;

    return 0;
}


Measured memory_bytes: 3120
f=lambda:map(int,input().split())
n,m=f()
g=[[] for _ in range(n)]
for _ in range(m):
  a,b=f()
  g[a-1]+=[b-1]
  g[b-1]+=[a-1]
from itertools import *
p=[*permutations(range(1,n))]
a=0
for t in p:
  v=0
  for c in t:
    if c in g[v]: v=c
    else: break
  else: a+=1
print(a)

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

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define For(i, a) for (int i=0; i<(a); i++)
#define FORR(i,a,b) for (int i = (b)-1; i >= a; i--)
#define Forr(i,a) for (int i = (a)-1; i >= 0; i--)

#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__) 
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args){
cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }

#define int ll
#define pb(x) push_back(x)
#define INF (int)1e17
#define PI 3.14159265358979323846
 
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

const int N=2e5+2;
vector<int> g[N];
int visited[N];
int sz;

void dfs(int u, int parent){
	visited[u]=1;
	for(int child : g[u]){
		if(!visited[child]){
			sz++;
			dfs(child,u);
		}
	}
}

void solve(){
	int n, m; cin >> n >> m;
	For(i,m){
		int u,v; cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}
	int ans = 0;
	FOR(i,1,n+1){
		if(!visited[i]){
			sz=0;
			dfs(i,0);
			ans=max(ans,sz+1);
		}
	}
	cout << ans << "\n";
	

}

int32_t main(){ 
	ios_base:: sync_with_stdio(false); 
	cin.tie(0); 
	int t=1;
	for(int tt=1;tt<=t;tt++){
		solve();
	}
}

Measured memory_bytes: 25448
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    vector<int> A(3);
    for(int i = 0; i < 3; i++) {
        cin >> A[i];
    }

    int max = *max_element(A.begin(), A.end());
    int min = *min_element(A.begin(), A.end());

    cout << max - min << endl;
}   

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

#define ll long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 500005

ll dp[3001][3001][2];
ll a[mxn];

ll solve(int i,int j,int turn){
if(i>j)return 0;
ll &ans=dp[i][j][turn];
if(ans!=-1)return ans;
if(turn==1)
    ans=max(a[i]+solve(i+1,j,turn^1),a[j]+solve(i,j-1,turn^1));
else ans=ans=min(-a[i]+solve(i+1,j,turn^1),-a[j]+solve(i,j-1,turn^1));
return ans;
}

int main(){
sp;
int n;
memset(dp,-1,sizeof dp);
cin>>n;
for(int i=1; i<=n; ++i)cin>>a[i];
cout<<solve(1,n,1);
return 0;}


Measured memory_bytes: 143104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
#define all(x) x.begin(),x.end()
const int inf=0x3f3f3f3f;

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

vector<int> prime;
int minfactor[1000010];
void linear_prime(int n){
	for(int i=2;i<=n;i++){
		if(!minfactor[i]) prime.push_back(i);
		for(auto j:prime){
			if(i*j>n) break;
			minfactor[i*j]=j;
			if(i%j==0) break;
		}
	}
}

int N,d[1000010];
bool chk[1000010];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	linear_prime(1000000);
	cin>>N;
	for(int i=0;i<N;i++) cin>>d[i];
	bool flag=1;
	for(int i=0;i<N;i++){
		int x=d[i];
		if(x==1) continue;
		vector<int> t;
		while(minfactor[x]){
			t.push_back(minfactor[x]);
			x/=minfactor[x];
			if(chk[x]) flag=0;
		}
		t.push_back(x);
		if(chk[x]) flag=0;
		for(auto i:t) chk[i]=1;
	}
	if(flag){
		cout<<"pairwise coprime";
		return 0;
	}
	int x=d[0];
	for(int i=1;i<N;i++) x=gcd(x,d[i]);
	if(x==1){
		cout<<"setwise coprime";
		return 0;
	}
	cout<<"not coprime";
	return 0;
}

Measured memory_bytes: 12532
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<string>s(N);
	for (auto &i : s) {
		cin >> i;
		for (auto &j : i)j += 1;
		i = string(1, 'a') + i;
		while (i.size() < 21)i.push_back('a');
	}
//	for (auto i : s)cout << i << endl;
	vector<vector<vector<long long int>>>dp(N, vector<vector<long long int>>(N + 1, vector<long long int>(22)));
	for (int i = 0; i < N; i++) {
		for (int j = 21; j < 22; j++) {
			dp[i][i + 1][j] = 1;
		}
	}
	for (int j = 20; j >= 0; j--) {
		for (int i = 0; i < N; i++) {
			vector<vector<long long int>>cdp(N + 1, vector<long long int>(29));
			cdp[i][0] = 1;
			for (int k = i; k < N; k++) {
				for (int l = 0; l < 27; l++) {
					int cnt = k;
					int kotei = -1;
					if (s[cnt][j] != '@')kotei = s[cnt][j] - 'a' + 1;
					cnt++;
					while (kotei != -2&&cnt<=N) {
						if (kotei == -1) {
							for (int m = max(2,l + 1); m <= 27; m++) {
								cdp[cnt][m] += cdp[k][l] * dp[k][cnt][j + 1] % MOD;
								cdp[cnt][m] %= MOD;
							}
						}
						else {
							if (kotei > l) {
								cdp[cnt][kotei] += cdp[k][l] * dp[k][cnt][j + 1] % MOD;
								cdp[cnt][kotei] %= MOD;
							}
						}
						if (cnt<N){
							if (s[cnt][j] != '@') {
								if (kotei == -1) {
									if (s[cnt][j] == 'a')kotei = -2;
									else kotei = s[cnt][j] - 'a' + 1;
								}
								else {
									if (kotei != s[cnt][j] - 'a' + 1)kotei = -2;
								}
							}
							else {
								if (kotei == 1)kotei = -2;
							}
						}
						cnt++;
					}
				}
			}
			for (int k = 0; k <= N; k++) {
				for (int l = 1; l <= 27; l++) {
					dp[i][k][j] += cdp[k][l];
					dp[i][k][j] %= MOD;
				}
			}
			
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j <= N; j++) {
			for (int k = 0; k <= 21; k++) {
		//		if(dp[i][j][k])cout << i << " " << j << " " << k << " " << dp[i][j][k] << endl;
			}
		}
	}
	cout << dp[0][N][0] << endl;
}


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

#define ll long long
#define ull unsigned long long
#define mii make_pair<int, int>
#define mll make_pair<ll, ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define all(v) (v).begin(), (v).end()

ofstream out("debug.txt");

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

    int n;
    cin >> n;
    cout << ceil((double)n / 1000) * 1000 - n << '\n';
}

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

int main() {
    int N; cin >> N;
    vector<int> p(N); for (int i = 0; i < N; i++) cin >> p[i];
    int res = 0;
    int tempflag = 1;
    for (int i = 0; i < N && tempflag; i++) if (p[i] != i+1) tempflag = 0;
    if (tempflag) {
        cout << "YES" << endl;
        return 0;
    }
    for (int i = 0; i < N-1 && !res; i++) {
        for (int j = i+1; j < N && !res; j++) {
            vector<int> pp = p;
            swap(pp[i], pp[j]);
            int flag = 1;
            for (int k = 0; k < N && flag; k++) {
                if (pp[k] != k+1) flag = 0;
            }
            res = flag;
        }
    }
    cout << (res ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
import math
a,b = map(int,input().split())

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

    # divisors.sort()
    return divisors

aa = make_divisors(a)
bb = make_divisors(b)

aaa = list(set(aa) & set(bb))

al = len(aaa)
count = 0



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

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

    return True


for i in range(al):
  if is_prime(aaa[i]):
    count += 1

print(count+1)


Measured memory_bytes: 5264
#include <stdio.h>
#include <string>
using namespace std;
int n;
char s[10];
double x, total=0;

int main(){
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%lf", &x);
        scanf("%s", s);
        if(s[0] == 'J'){
            total += x;
        } else {
            total += (x * 380000);
        }
    }

    printf("%f\n", total);

}


Measured memory_bytes: 128
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String C = sc.next();

        char[] c = C.toCharArray();
        for(char c1 : c) {
            int code = (int)c1;
            code = code + 1;
    
            char c2 = (char)code;
            System.out.println(c2);
        }
    }
}

Measured memory_bytes: 21716
import bisect

N,C = map(int,input().split())
STC = [list(map(int,input().split())) for _ in range(N)]
STC.sort(key=lambda x:x[1])
#print(STC)

P = {}
for p in STC:
  if p[2] not in P:
    P[p[2]] = [p[:2]]
  else:
    pe = P[p[2]][-1]
    if pe[1] == p[0]:
      P[p[2]][-1][1] = p[1]
    else:
      P[p[2]].append(p[:2])
#print(P)

P2 = []
maxt = 0
for val in P.values():
  for v in val:
    P2.append([v[0]-1,v[1]])
    maxt = max(maxt,v[1])
#print(P2)

T = [0 for _ in range(maxt+2)]
for p in P2:
  T[p[0]] += 1
  T[p[1]] -= 1
#print(T)
for i in range(1,maxt+2):
  T[i] += T[i-1]
#print(T)
print(max(T))


Measured memory_bytes: 92248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
    char a;
    cin >> a;
    for(char i='A';i<='Z';i++){
        if(a==i){
            cout << 'A' << endl;
        }   
    }
    for(char i='a';i<='z';i++){
        if(a==i){
            cout << 'a' << endl;
        }   
    }
}

Measured memory_bytes: 3644
def main():
    import itertools
    n,m = map(int,input().split())
    lt = []
    for i in range(m):
        lt.append(list(map(int,input().split())))
    p = list(map(int,input().split()))
    stats = ((0,1) for i in range(n))
    ans = 0
    for stat in itertools.product(*stats):
        flg = 0
        for i in range(m):
            cnt = 0
            for j in range(1,lt[i][0]+1):
                if stat[lt[i][j]-1]==1:
                    cnt+=1
            if cnt%2!=p[i]:
                flg = 1
                break
        if flg==0:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9252
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int h, w, a, b; cin >> h >> w >> a >> b;
	rep(i, b)
	{
		rep(j, a)cout << 0;
		for (int j = a; j < w; ++j)cout << 1;
		cout << "" << endl;
	}
	for (int i = b; i < h; ++i)
	{
		rep(j, a)cout << 1;
		for (int j = a; j < w; ++j)cout << 0;
		cout << "" << endl;
	}
}

Measured memory_bytes: 1280
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cstdint>

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

  int res=1;
  for (int i=0; i<N; ++i)
    res = std::min(res*2, res+K);

  printf("%d\n", res);
}


Measured memory_bytes: 128
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        var ope = new int[,] { { 2,4,1,3,0,5}, { 3,5,2,1,4,0 }, { 5,3,2,0,4,1 }, { 4,2,0,3,1,5 }};
        var dict = new Dictionary<string, int>() { { "N", 0 }, { "E", 1 }, { "W", 2 }, { "S", 3 } };
        var dicebase = new int[] { 1, 6, 5, 3, 2, 4 };
        string[] line = Console.ReadLine().Trim().Split(' ');
        var label = Array.ConvertAll(line, int.Parse);
        var dice = new int[6];
        for (int i = 0; i < 6; i++)
            dice[i] = label[dicebase[i]-1];
        var cs = Console.ReadLine().Trim();
        var top = 0;
        for (int i = 0; i < cs.Length; i++)
             top = GetResult(ope, dice, dict[cs[i].ToString()]);
        Console.WriteLine(top);
        
    }
    public static int GetResult(int[,] o, int[] d, int cmd)
    {
        var ary = new int[6];
        for (int i = 0; i < 6; i++)
            ary[o[cmd, i] ] = d[i];
        for (int i = 0; i < 6; i++)
            d[i] = ary[i];
        return d[0];
    }
}

Measured memory_bytes: 9268
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rrep(i,n) for(long long i=(n);i>=0;--i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

// ========== debug ==========
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif
// ===========================

int main() {
  int N;
  ins(N);

  vi A(N);
  rep(i, N) {
    cin >> A[i];
  }
  all(sort, A);
  all(reverse, A);
  priority_queue<int> q;
  q.push(A[0]);
  ll ans = 0;
  rep(ii, N-1) {
    int i = ii+1;
    ans += q.top(); q.pop();
    q.push(A[i]); q.push(A[i]);
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<long long int> a(n);
  for(int i=0;i<m;i++){
    int p;
    cin >> p;
    a.at(p-1)=1;
  }
  long long int k=1;
  for(int i=1;i<n;i++){
    if(a.at(i)==1&&a.at(i-1)==1){
      k=0;
      break;
    }
  }
  
  if(k!=0){
    vector<int> s(0);
    
    for(int i=0;i<n;i++){
      int x=0;
      while(i<n&&a.at(i)==0){
        x++;
        i++;
      }
      s.push_back(x);
    }
    long long int size=s.size()-1;
    if(a.at(0)==0)s.at(0)++;
    sort(s.begin(),s.end());
    vector<long long int> f(2,1);
    
    for(int i=2;i<s.at(size);i++)
      f.push_back((f.at(i-2)+f.at(i-1))%1000000007);//フィボナッチ
    
    for(int i=0;i<=size;i++){//配列sのすべてに対して
      if(s.at(i)!=0){
        k*=f.at(s.at(i)-1);
        k=k%1000000007;
      }
    }
  }
  cout << k << endl;
}

Measured memory_bytes: 2168
#include <cstdio>

using namespace std;

const int mod = 1'000'000'007;

int add(int a, int b) {
  a += b;
  return a >= mod ? a - mod : a;
}

int sub(int a, int b) {
  a -= b;
  return a < 0 ? a + mod : a;
}

int mul(int a, int b) {
  return (int)((long long)a * b % mod);
}

int pw(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b /= 2;
  }
  return res;
}

int inv(int a) {
  return pw(a, mod - 2);
}

const int N = 200'009;

int f[N];
int rf[N];

int choose(int n, int k) {
  return mul(f[n], mul(rf[k], rf[n - k]));
}

int main() {
  f[0] = 1;
  rf[0] = 1;
  for (int i = 1; i < N; ++i) {
    f[i] = mul(f[i - 1], i);
    rf[i] = inv(f[i]);
  }
  int n, k;
  scanf("%d%d", &n, &k);
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (n - i > k) {
      continue;
    }
    ans = add(ans, mul(choose(n, i), choose(n - 1, n - i)));
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 1664
import sys

c = []

for _ in range(3):
    *C, = map(int, input().split())
    c.append(C)

for a1 in range(0,101,1):
    b1 = c[0][0]-a1
    b2 = c[0][1]-a1
    b3 = c[0][2]-a1

    a2 = c[1][0]-b1
    if (a2+b2)!=c[1][1]:
        print("No")
        sys.exit()
    if (a2+b3)!=c[1][2]:
        print("No")
        sys.exit()
    a3 = c[2][0]-b1
    if (a3+b2)!=c[2][1]:
        print("No")
        sys.exit()
    if (a3+b3)!=c[2][2]:
        print("No")
        sys.exit()   
print("Yes")     

Measured memory_bytes: 3064
n,q=map(int,input().split())
s=input()
L=[0 for i in range(n+1)]

for i in range(2,n+1):
    if s[i-1]=="C" and s[i-2]=="A":
        L[i]=L[i-1]+1
    else:
        L[i]=L[i-1]

for que in range(q):
    l,r=map(int,input().split())
    print(L[r]-L[l])

Measured memory_bytes: 11392
k, q = map(int, input().split())
d = [int(i) for i in input().split()]
nxm = [[int(i) for i in input().split()] for _ in range(q)]

for n, x, m in nxm :
  an = x
  for i in range(k) :
    if d[i] % m != 0 :
      an += ((n - i - 2) // k + 1) * (d[i] % m)
    else :
      an += ((n - i - 2) // k + 1) * m
  print(n - 1 - (an // m - x // m))

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
typedef vector<vector<int>> Graph;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

class MaxFlow {
public:
    struct Edge { int to, cap, rev, cost; };
    int n;
    vector<vector<Edge>> G;
    vector<bool> used;
    
    MaxFlow(int _n) : n(_n), G(n, vector<Edge>()), used(n) {}
    
    void add_edge(int from, int to, int cap) {
        G[from].push_back((Edge){to, cap, (int)G[to].size(), 0});
        G[to].push_back((Edge){from, 0, (int)G[from].size()-1, 0});
    }
    
    int dfs(int v, int t, int f) {
        if (v==t) return f;
        used[v] = true;
        for (int i=0; i<(int)G[v].size(); i++) {
            Edge &e = G[v][i];
            if (!used[e.to] && e.cap>0) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d>0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
    
    int max_flow(int s, int t) {
        int flow = 0;
        for (;;) {
            fill(used.begin(), used.end(), false);
            int f = dfs(s, t, INF);
            if (f==0) return flow;
            flow += f;
        }
    }
};

int main()
{
    ios::sync_with_stdio(false);

    int N; cin >> N;
    vector<PII> red(N), blue(N);
    rep(i, N) cin >> red[i].first >> red[i].second;
    rep(i, N) cin >> blue[i].first >> blue[i].second;

    const int SOURCE = 2 * N;
    const int SINK = 2 * N + 1;
    const int NN = 2*N + 2;

    MaxFlow mf(NN);

    rep(i, N) {
        mf.add_edge(SOURCE, i, 1);
        mf.add_edge(N+i, SINK, 1);

        rep(j, N) {
            if (red[i].first < blue[j].first &&
                red[i].second < blue[j].second) {
                mf.add_edge(i, N+j, 1);
            }
        }
    }

    cout << mf.max_flow(SOURCE, SINK) << endl;

}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define IO(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);
const int INF = 0x3f3f3f3f;
const int maxn=1e5+7;
int a[maxn];
bool cmp(int a,int b) { return a>b; }
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1,cmp);
	int len=0,wid=0;
	for(int i=1;i<n;i++)
	{
		if(a[i]==a[i+1]) 
		{
			if(len==0) {len=a[i]; i++; continue;}
			else { wid=a[i]; break; } 
		}
	}
	ll ans;
//	de(len);
//	de(wid);
	ans=(ll)len*(ll)wid;
    cout<<ans<<endl;
	
	return 0;
} 

Measured memory_bytes: 640
n = int(input())
s1 = str(input())
s2 = str(input())
mod = 10**9+7
if s1[0] == s2[0]:
  c = 3
  state = True
  i = 1
else:
  c = 6
  state = False
  i = 2
while i < n:
  if s1[i] == s2[i]:
    i += 1
    if state:
      c *= 2
    else:
      state = True
  else:
    i += 2
    if state:
      c *= 2
      state = False
    else:
      c *= 3
print(c%(mod))
  
  

Measured memory_bytes: 9064
package main

import "fmt"

func shuffle(card string, h int) string {
	return card[h:] + card[:h]
}

func main() {
	var card string
	var m, h int

	for {
		fmt.Scanf("%s", &card)
		if card == "-" {
			break
		}

		fmt.Scanf("%d", &m)

		for i := 0; i < m; i++ {
			fmt.Scanf("%d", &h)
			card = shuffle(card, h)
		}

		fmt.Println(card)
	}
}


Measured memory_bytes: 1152
function readInt(str){
    return parseInt(str, 10);
}
function range(begin, end){
    if(begin > end) return range(end, begin).reverse();
    const ans=[];
    for(let i=begin; i<=end; i++){
        ans.push(i);
    }
    return ans;
}

function solve(N,W,C,B,A:number[][]){
    return A.map((a,n)=>
        a.map((value,index)=>value*B[index])
        .reduce((prev,cur)=>prev+cur,0)+C>0?1:0
    ).reduce((prev,cur)=>prev+cur,0);
}
function Main(raw:string) {
    const input = raw.split("\n");
    const [N, W, C] = input[0].split(" ").map(readInt);
    const B = input[1].split(" ").map(readInt);
    const A=[];
    for(let i=0; i < N ;i++){
        A[i] = input[i+2].split(" ").map(readInt);
    }

    
    //出力
    console.log("%d", solve(N,W,C,B,A));
}

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

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

// global variables
#define debug(x) cout << #x << ": " << x << endl
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;

// typedef
typedef pair<int, int> P;
// sort by P.first (asd)
bool comPair(const P &firstElof, const P &secondElof) {
    return firstElof.first < secondElof.first;
}

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

#define MAX_N 100000 //10^5

template <class Abel>
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n);
        rank.resize(n);
        diff_weight.resize(n);
        for (int i = 0; i < n; ++i)
            par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        } else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x);
        w -= weight(y);
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

struct Edge {
    int to;
    int weight;
};
const int MAX = 1e5 + 5;
vector<Edge> Graph[MAX];
bool checked[MAX];
int color[MAX];

void dfs(int start, int c) {
    checked[start] = true;
    color[start] = c;
    for (auto gra : Graph[start]) {
        if (!checked[gra.to]) {
            if (gra.weight % 2 == 0)
                dfs(gra.to, c);
            else
                (c == 0) ? dfs(gra.to, 1) : dfs(gra.to, 0);
        }
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 1; i < n; i++) {
        int f, t, w;
        cin >> f >> t >> w;
        Graph[f].emplace_back(Edge{t, w});
        Graph[t].emplace_back(Edge{f, w});
    }
    dfs(1, 1);
    for (int i = 1; i <= n; i++) {
        cout << color[i] << endl;
    }
}


Measured memory_bytes: 7680
from fractions import gcd
from functools import reduce

def gcd_list(numbers):
    return reduce(gcd, numbers)

N, X=map(int, input().split())
x=list(map(int, input().split()))
y=list()

for i in x:
    y.append(abs(X-i))

#print(y)
print(gcd_list(y))


Measured memory_bytes: 16280
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

const ll divider = 1000000007;

// dpで解くべし

int main(void)
{
    int N, M;
    cin >> N >> M;

    vector<int> oks(N + 1, true);
    int num;
    for (int i = 0; i < M; i++)
    {
        cin >> num;
        oks[num] = false;
    }

    vector<ll> dp(N + 1);
    dp[0] = 1;
    for (int now = 0; now < N; now++)
    {
        for (int next = now + 1; next <= min(N, now + 2); next++)
        {
            if (oks[next])
            {
                dp[next] += dp[now];
                dp[next] %= divider;
            }
        }
    }

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

    cout << dp[N] << endl;
}

Measured memory_bytes: 1408