akhauriyash/Code-Regression huggingface dataset:
sx, sy, tx, ty = map(int, input().split())
W = tx - sx
H = ty - sy
# tx - sx の R, ty - sy のU
# 同数の の L, ty - sy のD
# D + tx - sx + 1 の R, ty - sy +1 のU と L
# U + tx - sx + 1 の L, ty - sy +1 のD と R
print("R" * W + "U" * H  + "L" * W + "D" * H + 
      "D" + "R" * (W + 1) + "U" * (H + 1)  + "L" +
      "U" + "L" * (W + 1) + "D" * (H + 1)  + "R")

Measured memory_bytes: 3060
using System;

namespace _1_5_C
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] str = Console.ReadLine().Split(' ');
                int H = int.Parse(str[0]);
                int W = int.Parse(str[1]);
                if (H == 0 || W == 0) break;
                for (int i0 = 0; i0 < W; i0 += 1)
                {
                    Console.Write(i0 % 2 == 0 ? '#' : '.');
                }
                Console.Write("\n");
                for(int i1 = 0; i1 < H - 1; i1 += 1)
                {
                    if (i1 % 2 == 0)
                    {
                        for (int i0 = 0; i0 < W; i0 += 1)
                        {
                            Console.Write(i0 % 2 == 0 ? '.' : '#');
                        }
                    }
                    if (i1 % 2 == 1)
                    {
                        for (int i0 = 0; i0 < W; i0 += 1)
                        {
                            Console.Write(i0 % 2 == 0 ? '#' : '.');
                        }
                    }
                    Console.Write("\n");
                }
                Console.Write("\n");
            }
        }
    }
}

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

int main(){
 int N,T;
 long long int c=0;
cin >>N>>T;  int M[N];
for( int i=0;i<N;i++){
cin >> M[i];
}

for(int i=0;i<N-1;i++){
  if(M[i+1]-M[i]<T) c+=M[i+1]-M[i];
  else c+=T;
}
c+=T;
cout <<c;
 }



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main ()
{
    int A,B, result;
    scanf ("%d %d", &A, &B);
    if (A>= 13)
        result = B;
    else if ( 12 >= A && A >=6){
        result = B/2;
    }
    else
       result=0;
       cout<<result<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll M = 1000000007LL;
ll inv(ll K) {
  ll A = M - 2;
  ll ret = 1;
  ll D = K;
  while (A > 0) {
    if (A % 2 == 1) {
      ret = (ret * D) % M;
    }
    D = (D * D) % M;
    A /= 2;
  }
  return ret;
}
ll F[2000005];
ll I[2000005];
int main() {
  ios::sync_with_stdio(false);
  ll r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  ll ret = 0;
  F[0] = 1;
  for (ll i = 1; i <= r2+c2+1; i++) {
    F[i] = (F[i-1] * i) % M;
  }
  I[r2+c2+1] = inv(F[r2+c2+1]);
  for (ll i = r2+c2; i >= 0; i--) {
    I[i] = (I[i+1] * (i+1)) % M;
  }
  for (ll i = c1; i <= c2; i++) {
    // sum(f(i+j, i)) = f(i+r2+1, i+1)
    // f(i+r2+1, i+1) = (i+r2+1)! / ((i+1)! * (r2)!)
    ll R = F[i+r2+1];
    //R = (R * inv(F[i+1])) % M;
    //R = (R * inv(F[r2])) % M;
    R = (R * I[i+1]) % M;
    R = (R * I[r2]) % M;
    // sum(f(i+j, i)) = f(r1, i+1)
    // f(i+r1, i) = (i+r1)! / ((i+1)! * (r1-1)!)
    ll L = F[i+r1];
    //L = (L * inv(F[i+1])) % M;
    //L = (L * inv(F[r1-1])) % M;
    L = (L * I[i+1]) % M;
    L = (L * I[r1-1]) % M;
    //cout << R << ' ' << L << endl;
    ret = (ret + R) % M;
    ret = ((ret - L) % M + M) % M;
  }
  cout << ret << endl;
}

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

struct ProblemResult {
    int wa;
    bool is_ac;
};

int main() {
    int n, m;
    std::cin >> n >> m;

    auto results = std::vector<ProblemResult>(n, ProblemResult{ 0, false });

    for(int i = 0; i < m; ++i) {
        int p;
        std::string s;
        std::cin >> p >> s;
        --p;

        if("AC" == s) {
            results[p].is_ac = true;
        } else {
            if(!results[p].is_ac) {
                ++results[p].wa;
            }
        }
    }

    int ac = 0;
    int wa = 0;

    for(const auto r: results) {
        if(r.is_ac) {
            ++ac;
            wa += r.wa;
        }
    }

    std::cout << ac << " " << wa << std::endl;

    return 0;
}


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

int main() {
  int n,m,sum;
  sum = 0;
  cin >> n >> m;
  vector<int> vec(m);
  for(int i=0; i<m; i++){
    cin >> vec.at(i);
    sum += vec.at(i);
  }
  if(n-sum >= 0)
    cout << n-sum;
  else
    cout << -1; 
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
int main(void){
    ll ANS=0;
    char S[5], T[5];
    scanf("%s %s", S, T);
    rep(i, 0, 3){
        if(S[i]==T[i])ANS++;
    }
    printf("%lld\n", ANS);
    return 0;
}
int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

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

    vector<int> kip(4);
    for (int i=0; i<4; i++)
        kip[i] = str[i] - '0';


    for (int i=0; i<2; i++) {
        int sum = kip[0];
        char hugo[5];

        if (i == 0) {
            sum += kip[1];
            hugo[0] = '+';
        } else {
            sum -= kip[1];
            hugo[0] = '-';
        }

        int tmp2 = sum;


        for (int j = 0; j < 2; j++) {

            sum = tmp2;

            if (j == 0) {
                sum += kip[2];
                hugo[1] = '+';
            } else {
                sum -= kip[2];
                hugo[1] = '-';
            }

            int tmp3 = sum;

            for (int k = 0; k < 2; k++) {

                sum = tmp3;

                if (k == 0) {
                    sum += kip[3];
                    hugo[2] = '+';
                } else {
                    sum -= kip[3];
                    hugo[2] = '-';
                }

                if (sum == 7) {
                    cout << str[0] << hugo[0] << str[1] << hugo[1] << str[2] << hugo[2] << str[3] << "=7" << endl;
                    return 0;
                }

            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include "math.h"
#include <string>
#include <vector>
#include <iomanip>

#define pai 3.14159265358979323846264338327950288
using namespace std;


// Snack
//*
int main() 
{
	long long int a, b,k,g;

	cin >> a >> b;


	if (a < b) 
	{
		k = a;
		a = b;
		b = k;
	}
	// a>b　になってる
	k = a * b;
	g = a % b;
	while (g!=0)
	{
		a = b;
		b = g;
		g = a % b;
	}
	
	
	cout << k/b;

	return 0;
}
//*/

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;

    double x = 0.0;
    for(int i=0; i<n; ++i){
        int a;
        cin >> a;
        x += 1.0 / a;
    }
    printf("%.10f\n", 1.0/x);

    return 0;
}


Measured memory_bytes: 256
alp_list = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
N = int(input())
S_list = list(input())
Slen = len(S_list)
S_return_list = []
for i in range(0,Slen):
  S_return_list.append(alp_list[(alp_list.index(S_list[i])+N)%26])
S_return="".join(S_return_list)
print('{}'.format(S_return))

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <map>
#include <algorithm>

using namespace std;

#define FAR (1<<22)
#define N 100

static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;


int n, color[N], d[N], p[N];
int m[N][N];

int prim(){
	for (int i = 0; i < n; ++i){
		color[i] = WHITE;
		d[i] = FAR;
		p[i] = -1;
	}

	d[0] = 0;
	int dist = FAR;

	while (1)
	{
		int u = -1;
		dist = FAR;
		for (int i = 0; i < n; ++i) {
			if (color[i] != BLACK && d[i] < dist){
				dist = d[i];
				u = i;
			}
		}

		if (-1 == u) break;
		color[u] = BLACK;

		for (int v = 0; v < n; ++v){
			if (color[v] != BLACK && (m[u][v] < d[v])){
				d[v] = m[u][v];
				p[v] = u;
				color[v] = GRAY;
			}
		}
	}
	dist = 0;
	for (int i = 0; i < n; ++i){
		if (p[i] != -1) dist += m[i][p[i]];
	}
	return dist;
}

int main(){
	cin >> n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			int val; cin >> val;
			m[i][j] = (val == -1) ? FAR : val;
		}
	}
 
	cout << prim() << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  ll a, b, x; scanf("%lld %lld %lld", &a, &b, &x);
  ll c = (a % x == 0) ? a : a + (x - (a % x));
  ll d = b - (b % x);
  ll ans = 0;
  if (d - c >= 0) {
    ans = (d - c) / x + 1;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
ds = set()
for _ in range(n):
    ds.add(ni())
    
print(len(ds))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
const int N=200005;
#define inf 1e18+8
const int mod=1e9+7;
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define set multiset
#define all(x) begin(x), end(x)
#define vpii vector<pair<int,int> > 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int dp[N];
int dp1[N];
vi adj[N];
vi adj2[N];
int vis[N];
void dfs(int x)
{
    if(vis[x]==1) return ;
    vis[x]=1;
    for(auto v:adj[x])
    {
        if(!vis[v])  dfs(v);
        dp[x]=max(1+dp[v],dp[x]);
    }
}
signed main()
{
    fastio;
    int n,m;
    cin>>n>>m;
 //   for(int i=1;i<=n;i++) parent[i]=i;

    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj2[v].pb(u);
       // parent[v]=u;

    }
    
        
    
   // dfs(1);
    int ans=0;
    
     for(int i=1;i<=n;i++)
    {
      //  cout<<dp[i];
      if(!vis[i])
        dfs(i);

    }
    for(int i=1;i<=n;i++)
    {
      //  cout<<dp[i];
        ans=max(ans,dp[i]);

    }
    cout<<ans;

}
 
    

Measured memory_bytes: 20864
// C++ code to find number of distinct numbers 
// in a subarray 
#include<bits/stdc++.h> 
using namespace std; 

const int MAX = 5000000; 

// structure to store queries 
struct Query 
{ 
	int l, r, idx; 
}; 

// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
	return x.r < y.r; 
} 

// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
	for (; idx <= n; idx += idx&-idx) 
		bit[idx] += val; 
} 

// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
	int sum = 0; 
	for (; idx>0; idx-=idx&-idx) 
		sum += bit[idx]; 
	return sum; 
} 

void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
	// initialising bit array 
	int bit[n+1]; 
	memset(bit, 0, sizeof(bit)); 

	// holds the rightmost index of any number 
	// as numbers of a[i] are less than or equal to 10^6 
	int last_visit[MAX]; 
	memset(last_visit, -1, sizeof(last_visit)); 

	// answer for each query 
	int ans[q]; 
	int query_counter = 0; 
	for (int i=0; i<n; i++) 
	{ 
		// If last visit is not -1 update -1 at the 
		// idx equal to last_visit[arr[i]] 
		if (last_visit[arr[i]] !=-1) 
			update (last_visit[arr[i]] + 1, -1, bit, n); 

		// Setting last_visit[arr[i]] as i and updating 
		// the bit array accordingly 
		last_visit[arr[i]] = i; 
		update(i + 1, 1, bit, n); 

		// If i is equal to r of any query store answer 
		// for that query in ans[] 
		while (query_counter < q && queries[query_counter].r == i) 
		{ 
			ans[queries[query_counter].idx] = 
					query(queries[query_counter].r + 1, bit, n)- 
					query(queries[query_counter].l, bit, n); 
			query_counter++; 
		} 
	} 

	// print answer for each query 
	for (int i=0; i<q; i++) 
		cout << ans[i] << endl; 
} 

// driver code 
int main() 
{ 
  	int n , q ;
  	cin >> n >> q ;
  	int a[n];
  	for(int i = 0 ; i < n ; i++) cin >> a[i];
	Query queries[q];
  	for(int i = 0 ; i < q ; i++) cin >> queries[i].l >> queries[i].r , queries[i].idx = i , queries[i].l--, queries[i].r--;
	sort(queries, queries+q, cmp); 
	answeringQueries(a, n, queries, q); 
	return 0; 
} 


Measured memory_bytes: 35040
package main

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

func atoi(s string) int { v, _ := strconv.Atoi(s); return v }
func atou(s string) uint64 { v, _ := strconv.ParseUint(s, 10, 64); return v }
func atof(s string) float64 { v, _ := strconv.ParseFloat(s, 64); return v }
func max(a, b int) int { if a > b { return a }; return b }
func min(a, b int) int { if a < b { return a }; return b }

var (_ = fmt.Println; _red = bufio.NewScanner(os.Stdin); _tok []string)
func init() { _red.Buffer(make([]byte, 1e7), 1e7) }
func gettok() (t string, e bool) {
	if len(_tok) == 0 { if !_red.Scan() { return }; _tok = strings.Split(_red.Text(), " ") }
	t = _tok[0]; _tok = _tok[1:]; e = len(_tok) == 0; return
}
func read(vs ...interface{}) {
	for _, v := range vs {
		switch v := v.(type) {
		case *int: t, _ := gettok(); *v = atoi(t)
		case *int64: t, _ := gettok(); *v = int64(atou(t))
		case *uint64: t, _ := gettok(); *v = atou(t)
		case *float64: t, _ := gettok(); *v = atof(t)
		case *string: *v, _ = gettok()
		case *[]int:
			if len(*v) == 0 { for { t, e := gettok(); *v = append(*v, atoi(t)); if e { break } }
			} else { for j := range *v { t, _ := gettok(); (*v)[j] = atoi(t) } }
		case *[]int64:
			if len(*v) == 0 { for { t, e := gettok(); *v = append(*v, int64(atou(t))); if e { break } }
			} else { for j := range *v { t, _ := gettok(); (*v)[j] = int64(atou(t)) } }
		case *[]uint64:
			if len(*v) == 0 { for { t, e := gettok(); *v = append(*v, atou(t)); if e { break } }
			} else { for j := range *v { t, _ := gettok(); (*v)[j] = atou(t) } }
		case *[]float64:
			if len(*v) == 0 { for { t, e := gettok(); *v = append(*v, atof(t)); if e { break } }
			} else { for j := range *v { t, _ := gettok(); (*v)[j] = atof(t) } }
		case *[]string:
			if len(*v) == 0 { *v = append(*v, _tok...); _tok = _tok[:0]
			} else { for j := range *v { (*v)[j], _ = gettok() } }
		}
	}
}

func main() {
	var A, B int
	read(&A, &B)
	if A % 3 == 0 {
		fmt.Println("Possible")
	} else if B % 3 == 0 {
		fmt.Println("Possible")
	} else if (A + B) % 3 == 0 {
		fmt.Println("Possible")
	} else {
		fmt.Println("Impossible")
	}
}


Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {

		public static void main(String[] args) {

			Scanner sc=new Scanner(System.in);
			long n=sc.nextLong();
			long m=sc.nextLong();
			long mi=2;
			long ni=2;
			if(n==1) ni=0;
			if(m==1)mi=0;
			
			System.out.println((m-mi)*(n-ni));
		}
	}



Measured memory_bytes: 23764
#include <cstdio>
#include <map>
using namespace std;

int main(void)
{
    pair <char, char> set[26];
    char str[1001];
    scanf("%s", str);
    for (int i = 1; i <= 26; i++){
        set[i - 1].first = i + 0x40;
        set[i - 1].second = (((i + 3) % 26) + 0x40);
        if (set[i - 1].first == 'W'){
            set[i - 1].second = 'Z';
        }
    }
    for (int i = 0; str[i] != '\0'; i++){
        for (int j = 0; j < 26; j++){
            if (str[i] == set[j].second){
                printf("%c", set[j].first);
            }
        }
    }
    printf("\n");
    
    return (0);
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){

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

  int i,day[ n ];
  for ( i = 0 ; i < n ; i++ ){
    scanf("%d", &day[ i ]);
  }

  for ( i = 0 ; i < n ; i++ ){
    if ( i == n - 1 ) printf("%d", day[ 0 ] );
    else printf("%d ", day[ n - 1 - i ]);
  }

  printf("\n");

  return 0;
  
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
const int mod=998244353;
int n;
int a[200001];
int cnt[200001];
int quickpow(int x,int y)
{
	long long res=1,base=x;
	while(y)
	{
		if(y&1) res*=base,res%=mod;
		y>>=1; base*=base,base%=mod;
	}
	return res;
}
signed main()
{
	int mx=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),cnt[a[i]]++,mx=max(mx,a[i]);
	for(int i=0;i<=mx;i++)
		if(cnt[i]==0)
		{
			printf("0");
			return 0;
		}
	if(cnt[0]>=2||a[1]!=0)
	{
		printf("0");
		return 0;
	}
	int ans=1;
	for(int i=1;i<=mx;i++)
		ans=1ll*ans*quickpow(cnt[i-1],cnt[i])%mod;
	printf("%d",ans);
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) (V).begin(),(V).end()
#define MOD 1000000007
#define mod 998244353

ll rw1[100010], rw2[100010];

int main(){
	for (int i = 0;i < 100010;i++)rw1[i] = rw2[i] = 0;
	ll N, M, a, b, ans = 0;
	cin >> N >> M;
	cin >> a;
	for (int i = 1;i < N;i++) {
		cin >> b;
		if (a < b) {
			rw1[a + 1]++;
			rw1[b + 1]--;
			rw2[a + 1]--;
			rw2[b + 1] -= b - a - 1;
			ans += b - a;
		}
		else {
			rw1[1]++;
			rw1[b + 1]--;
			rw2[0] += M - a - 1;
			rw2[b + 1] -= b + (M - a - 1);
			rw1[a + 1]++;
			rw2[a + 1]--;
			ans += M - a + b;
		}
		a = b;
	}
	a = 0;

	for (int i = 1;i <= M;i++)rw1[i] += rw1[i - 1];
	rw2[0] += rw1[0];
	for (int i = 1;i <= M;i++)rw2[i] += rw2[i - 1] + rw1[i];
	for (int i = 1;i <= M;i++)a = max(a, rw2[i]);
	cout << ans - a << endl;
}

Measured memory_bytes: 1920
import sys
s = input()
N = len(s)
for i in range(N-1):
    if s[i] == s[i+1]:
        print(*[i+1, i+2])
        sys.exit()
for i in range(N-2):
    if s[i] == s[i+2]:
        print(*[i+1, i+3])
        sys.exit()
print(*[-1, -1])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  int d=0;
  for (int i=0;i<N;i++){
    if (i%2==0){
      d+=vec.at(i);
    }
    else{
      d-=vec.at(i);
    }
  }
  cout << d << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class DDoubleDots {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N, M;
        cin >> N >> M;
        vector<vector<int>> G(N);
        REP(i, M) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            G[a].push_back(b);
            G[b].push_back(a);
        }

        vector<int> res(N, -1);
        queue<int> q;
        q.push(0);
        while (!q.empty()) {
            int x = q.front();
            q.pop();
            for (auto to : G[x]) {
                if (res[to] != -1) continue;
                res[to] = x;
                q.push(to);
            }
        }

        for (int i = 1; i < N; i++) {
            if (res[i] == -1) {
                cout << "No" << endl;
                return;
            }
        }
        cout << "Yes" << endl;
        for (int i = 1; i < N; i++) cout << res[i] + 1 << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DDoubleDots solver;
    solver.solve(in, out);
    return 0;
}


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

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

  if ((a + b) % 2){
    cout << (a + b) / 2 + 1 << endl;
  }
  else {
    cout << (a + b) / 2 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string str1, str2, str3;
    cin >> str1;
    cin >> str2;
    cin >> str3;
     
    int m = atoi(str1.c_str());
    int f = atoi(str2.c_str());
    int b = atoi(str3.c_str());
     
    if( m + f < b){
        cout << "NA";
    }else if(m >= b){
        cout << 0;
    }else{
        cout << b-m;
    }
     
    cout << (0?" ":"") << endl;
     
}


Measured memory_bytes: 3172
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int L = sc.nextInt();
        int R = sc.nextInt();
        long mod=0;

        int l = L%2019;
        int r = R%2019;
        int l1 = L/2019;
        int r1 = R/2019;

        if(R-L +1 >=2019){//large enough to contain 2019 multiples
            mod =0;
        }else if(l==0 || r ==0){//contain 2019 multiple at edge
            mod = 0;
        }else if ( r1!=l1){// contains 2019 in between
            mod =0;
        }else{
            int min = Integer.MAX_VALUE;
            for(int i= l; i < r ; ++i){
                for (int j = l+1; j <=r ; j++) {
                    int multi = i*j;
                    int mod2 = multi%2019;
                    min = Math.min(min, mod2);
                }
            }
            if(min!=Integer.MAX_VALUE){
                mod = min;
            }
        }



        System.out.println(mod);

    }

}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
#define lson (o<<1)
#define rson (o<<1|1)
#define fi first
#define sc second
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
using namespace std;
const double pi=acos(-1);
const double eps=1e-6;
inline int lowbit(int x){return x&(-x);}
inline int read(){
    int f=1,x=0;char ch;
    do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
    do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
    return f*x;
}
template<typename T> inline T max(T x,T y,T z){return max(max(x,y),z);}
template<typename T> inline T min(T x,T y,T z){return min(min(x,y),z);}
template<typename T> inline T sqr(T x){return x*x;}
template<typename T> inline void checkmax(T &x,T y){x=max(x,y);}
template<typename T> inline void checkmin(T &x,T y){x=min(x,y);}
template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
template<typename A,typename B,typename C> inline A fpow(A x,B p,C yql){
    A ans=1;
    for(;p;p>>=1,x=1LL*x*x%yql)if(p&1)ans=1LL*x*ans%yql;
    return ans;
}
struct FastIO{
    static const int S=1310720;
    int wpos;char wbuf[S];
    FastIO():wpos(0) {}
    inline int xchar(){
        static char buf[S];
        static int len=0,pos=0;
        if(pos==len)pos=0,len=fread(buf,1,S,stdin);
        if(pos==len)return -1;
        return buf[pos++];
    }
    inline int read(){
        int c=xchar(),x=0;
        while(c<=32&&~c)c=xchar();
        if(c==-1)return -1;
        for(;'0'<=c&&c<='9';c=xchar())x=x*10+c-'0';
        return x;
    }
}io;
ll a,b,c;
int main()
{
    a=read();b=read();c=read();
    if(a<=c && c<=b) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
N = int(input())
s = []
ab_num = 0
b_start = 0
a_end = 0
ba_word = 0
for i in range(N):
    tmp = input()
    s.append(tmp)
    rep = tmp.replace("AB", "")
    ab_num += (len(tmp) - len(rep)) // 2
    if tmp[0] == "B":
        b_start += 1
    if tmp[-1] == "A":
        a_end += 1
    if tmp[0] == "B" and tmp[-1] == "A":
        ba_word += 1
if b_start == a_end == ba_word != 0:
    print(max(ab_num + min(a_end, b_start) - 1, 0))
else:
    print(ab_num + min(a_end, b_start))

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

using namespace std;
#define mp(a,b) make_pair(a,b)
#define fast cin.tie(0);cout.tie(0);std::ios_base::sync_with_stdio(0);
#define fuf -1;
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define min3(a,b,c) min(min(a,b),c)
#define max3(a,b,c) max(max(a,b),c)
#define mid3(a,b,c) a+b+c-max3(a,b,c)-min3(a,b,c)
#define nullptr NULL
//typedef long long int ll;
#define int long long

const double EPS = 0.0000000001;
const int mod1 = 998244353;
const int mod2 = 1000000007;
const int mod3 = 1000000009;
const int inf = 1000000000000000000;
using namespace std;

signed main(){
    string s;
    cin >> s;
    string p1,p2;
    p1 = p2 = "";
    for(int i = 0;i<s.size();i++){
        if(i&1){
            p1 += "1";
            p2 += "0";
        }
        else{
            p1 += "0";
            p2 += "1";
        }
    }
    int c1 = 0,c2 = 0;
    for(int i = 0;i<p1.size();i++){
        if(p1[i] != s[i]) c1++;
        if(p2[i] != s[i]) c2++;
    }
    cout << min(c2,c1);
}


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

using namespace std;

using ll=long long;

const ll maxn=100005;

ll dp[101][1000000];

int main()
{
    ll n,W;
    cin>>n>>W;
    vector<pair<ll,ll>>v;
    for(int i=0;i<n;i++)
    {
        ll w,va;
        cin>>w>>va;
        v.push_back({w,va});
    }

    for(ll j=1;j<=maxn;j++)
    {
        dp[0][j]=(ll)(1e18);
    }

    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=maxn;j++)
        {

            if(j>=v[i-1].second)

                dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i-1].second]+v[i-1].first);

            else

                dp[i][j]=dp[i-1][j];

        }
    }

    ll ans=0;

    for(ll j=1;j<=maxn;j++)
    {
        if(dp[n][j]<=W)
            ans=max(ans,j);
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 287744
#include <iostream>
#include <cstdio>

using namespace std;
using ll=long long;

int main()
{
    int N;
    
    cin >> N;
    
    if (N / 10 == 9 || N % 10 == 9)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
N = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]
data = sorted(data) + [0]

if N == 1 and data[0] == 1:
    print(0)

elif N == 1 and data[0] != 1:
    print(1)

else:
    ans = 0
    num = data[0]
    cnt = 0
    for i in range(N+1):
        if data[i] == num:
            cnt += 1
        else:
            if cnt < data[i-1]:
                ans += cnt
            else:
                ans += (cnt-data[i-1])
            cnt = 1
            num = data[i]
    print(ans)

Measured memory_bytes: 14620
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}



const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, m; cin >> n >> m;
	VE a(n); rep(i, n)cin >> a[i];
	vector<P> t;
	rep(i, m) {
		int b, c; cin >> b >> c;
		t.push_back(make_pair(c, b));
	}
	sort(ALL(a));
	sort(ALLR(t));
	int now = t[0].second;
	int idx = 0;
	rep(i, n) {
		if (idx >= m) {
			break;
		}
		if (a[i] >= t[idx].first) {
			break;
		}
		a[i] = t[idx].first;
		now--;
		if (now == 0) {
			idx++;
			if(idx < m)now = t[idx].second;
		}
	}
	int ans = 0;
	rep(i, n) {
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

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

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

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

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

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

vll G[200005];
ll cost[200005];
bool visited[200005];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,q; cin>>n>>q;
  rep(i,n-1){
    ll a,b; cin>>a>>b; a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  rep(i,q){
    ll p,x; cin>>p>>x; p--;
    cost[p]+=x;
  }
  // rep(i,n) cout<<cost[i]<<endl;
  // cout<<endl;
  
  queue<pll> que;
  que.emplace(0,cost[0]);
  while(!que.empty()){
    auto p=que.front(); que.pop();
    ll v=p.first, c=p.second;
    visited[v]=true;
    for(auto nv: G[v]){
      if(visited[nv]) continue;
      cost[nv]+=c;
      que.emplace(nv,cost[nv]);
      // cout<<cost[nv]<<endl;
    }
  }
  rep(i,n){
    cout<<cost[i]<<endl;
  }
}

Measured memory_bytes: 19696
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int N, M, K, H, W, L, R, T;
string S;
signed main(){
  cin >> N;
  int sum = 0;
  int mx = 0;
  rep(i,N){
    int a; cin >> a;
    sum += a;
    mx = max(mx,a);
  }
  sum -= mx/2;
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <numeric>
#include <iomanip>
#define FI first
#define SE second
#define EB emplace_back
#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 1100000000
#define LLINF 1100000000000000000LL
#define Decimal fixed << setprecision(20)
#define ALL(c) c.begin(),c.end()
#define SHOWVEC(v, sz) for(int i = 0; i < sz; i++) cerr << v[i] << ' '; cerr << endl;
#define SHOWX(x) cerr << #x << ": " << x << endl;
#define SHOWP(p) cerr << "[" << p.first << ',' << p.second << "]";
#define MOD 998244353

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

void halt(int x) {
  cout << x << endl;
  exit(0);
}

ll mypow(ll n, ll k) {
  ll ret = 1;
  REP(i, k) (ret *= n) %= MOD;
  return ret;
}

int main()
{
  int N; cin >> N;
  vector<int> D(N); REP(i, N) cin >> D[i];
  if (D[0] > 0) halt(0);

  const int M = *max_element(ALL(D));
  vector<int> hist(M + 1, 0);
  for (auto&& e : D) hist[e]++;
  if (hist[0] > 1) halt(0);

  ll ans = 1;
  for (int i = 1; i < hist.size(); i++) {
    ll n = hist[i-1];
    ll k = hist[i];
    (ans *= mypow(n, k)) %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


X = LMI()
print(X.index(0) + 1)

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

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

const ll INF = 1LL << 60;



//大文字小文字気をつけろ

int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;

  if(x<y){
     swap(a,b);
     swap(x,y);
  }

  if(a+b>c*2){
    cout << min(c*2*x,c*2*y+a*(x-y)) << endl;
  }else{
    cout << a*x+b*y << endl;
  }


}


Measured memory_bytes: 256
c = [0] * 100
while 1:
    try:
        a, b = map(int, input().split())
    except:
        break
    c[a - 1] += 1
    c[b - 1] += 1
    if a == 0:
        for i in range(2, 100):
            if c[i] & 1:
                print('NG')
                break
        else:
            print('OK' if c[0] & 1 and c[1] & 1 else 'NG')
        c = [0] * 100


Measured memory_bytes: 5600
#include <iostream>

using namespace std;

int main()
{
    long long N,K;
    cin>>N>>K;
    if(N > K){
        if((N % K) > abs((N % K) - K)){
            cout<<abs((N % K) - K)<<endl;
        }else {
            cout<<(N % K)<<endl;
        }
    } else if(N < K){
        if(N > abs(N-K)){
            cout<<abs(N-K)<<endl;
        }else{
            cout<<N<<endl;
        }
    } else {
        cout<<0<<endl;
    }

    return 0;
}


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

void solve(){

	int n ;
	cin>>n ;

	if(n==1)
		cout<<0 ;
	else
		cout<<1 ;
	

}

int main(){
	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
const int maxn=400100;
const int mod=1000000007;
int n,cir[maxn],f[maxn],rd[maxn],sz[maxn],tal,tci,o,cnte,now[maxn];
bool vis[maxn];
ll jie[maxn],inv[maxn];
ll ksm(ll a,int b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
ll C(int a,int b){return jie[a]*inv[b]%mod*inv[a-b]%mod;}
struct edge
{
	int t;
	edge *next;
}*con[maxn],*gra[maxn];
void ins(int x,int y,edge **a)
{
	edge *p=new edge;
	p->t=y;
	p->next=a[x];
	a[x]=p;
}
void findcir(int v,int fa)
{
	vis[v]=1;
	for(edge *p=con[v];p&&!o;p=p->next)
		if(p->t!=fa)
			{if(!vis[p->t]) findcir(p->t,v);else {o=p->t;break;}}
	//cout<<"findcir:"<<v<<' '<<o<<endl;		
	if(o) cir[++tci]=v;
	else vis[v]=0;
	if(v==o) o=0;	
}
void check(int v)
{
	vis[v]=1;
	now[++tal]=v;
	for(edge *p=con[v];p;cnte++,p=p->next)
		if(!vis[p->t]) check(p->t);
}
void dfs(int v)
{
	vis[v]=1;
	for(edge *p=con[v];p;p=p->next)
		if(!vis[p->t]) f[p->t]=v,dfs(p->t);	
}
void build()
{
	for(int i=1;i<=tal;i++)
		gra[now[i]]=NULL,rd[now[i]]=0;
	gra[0]=NULL;	
	for(int i=1;i<=tal;i++)
		for(edge *p=con[now[i]];p;p=p->next)
			if(p->t<f[now[i]]) ins(now[i],p->t,gra),rd[p->t]++;
	for(int i=1;i<=tal;i++)
		if(rd[now[i]]==0) ins(0,now[i],gra);
//	cout<<"f:"<<endl;
//	for(int i=1;i<=tal;i++)
//		cout<<now[i]<<','<<f[now[i]]<<' ';
//	cout<<endl;		
//	for(int i=0;i<=tal;i++)
//		for(edge *p=gra[now[i]];p;p=p->next)
//			cout<<now[i]<<' '<<p->t<<endl;			
}
ll dp(int v,int fa)
{
	ll re=1;
	sz[v]=0;
	for(edge *p=gra[v];p;p=p->next)
		if(p->t!=fa)
		{
			ll tmp=dp(p->t,v);
			sz[v]+=sz[p->t];
			re=re*tmp%mod*C(sz[v],sz[p->t])%mod;
			//cout<<v<<' '<<p->t<<' '<<re<<' '<<sz[v]<<' '<<sz[p->t]<<endl;
		}
	sz[v]++;
	//cout<<"dp:"<<v<<' '<<re<<endl;
	return re;	
}
ll work(int v)
{
	//cout<<"work:"<<v<<endl;
	ll re=0;
	tci=tal=o=cnte=0;
	check(v);
	//cout<<"check:"<<tal<<' '<<cnte<<endl;
	if(tal*2!=cnte) return 0;
	for(int i=1;i<=tal;i++)
		vis[now[i]]=0;
	findcir(v,-1); 
//	cout<<tci<<endl;
//	for(int i=1;i<=tci;i++)
//		cout<<cir[i]<<' ';
//	cout<<endl;	
	for(int i=1;i<=tci;i++)
		dfs(cir[i]);
	for(int i=1;i<tci;i++)
		f[cir[i]]=cir[i+1];
	f[cir[tci]]=cir[1];
	build();
	re=(re+dp(0,-1))%mod;
	for(int i=2;i<=tci;i++)
		f[cir[i]]=cir[i-1];
	f[cir[1]]=cir[tci];
	build();		
	re=(re+dp(0,-1))%mod;
	return re;
}
int main()
{
	
	scanf("%d",&n);
	jie[0]=1;
	for(int i=1;i<=2*n;i++)
		jie[i]=jie[i-1]*i%mod;
	inv[2*n]=ksm(jie[2*n],mod-2);
	for(int i=2*n-1;i>=0;i--)
		inv[i]=inv[i+1]*(i+1)%mod;
	//cout<<"C:"<<C(4,2)<<endl;
	for(int i=1;i<=2*n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		ins(x,y+n,con);
		ins(y+n,x,con);
	}
//	for(int i=1;i<=2*n;i++)
//		for(edge *p=con[i];p;p=p->next)
//			cout<<i<<' '<<p->t<<endl;
	ll ans=1;int tot=0;
	for(int i=1;i<=2*n;i++)
		if(!vis[i]) 
		{
			ans=ans*work(i)%mod*C(tot+tal,tal)%mod;
			tot+=tal;
		}
	printf("%lld",ans);	
	return 0;
}

Measured memory_bytes: 47872
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64 = int64_t;

bool check(i64 x, i64 k, const vector<i64> &a) {
  i64 cnt = 0;
  i64 n = a.size();
 
  rep(i, n) {
    i64 ci = 0;
    long double t = 0;
    if (a[i] == 0) {
      if (x >= 0) {
        ci = n - 1 - i;
      }
    } else {
      t = x / (long double)a[i];
      if (a[i] > 0) {
        ci = upper_bound(a.begin() + i + 1, a.end(), t) - (a.begin() + i + 1);
      } else {
        ci = a.end() - lower_bound(a.begin() + i + 1, a.end(), t);
      }
    }
    cnt += ci;
  }
    return cnt >= k;
}

int main(){
    i64 n,k;
    cin >> n >> k;
  	vector<i64> a(n);
    rep(i,n){cin >> a[i];}
    sort(all(a));
    const i64 MAX = 1e18 * 2;
    i64 ok = MAX;
    i64 ng = -MAX;
    while(abs(ok-ng) > 1){
        i64 mid = (ok+ng)/2;
        if(check(mid,k,a)) 
            ok = mid;
        else 
            ng = mid;
    }
    cout << ok << endl;
  return 0;
}


Measured memory_bytes: 1920
from math import cos
from math import sin
from math import sqrt
from math import pi
A,B,H,M=list(map(int,input().split(' ')))


angleB=2*pi*M/60
angleA=2*pi*(H/12+M/12/60)


pointA=[A*cos(angleA),A*sin(angleA)]
pointB=[B*cos(angleB),B*sin(angleB)]

print(sqrt((pointA[0]-pointB[0])**2+(pointA[1]-pointB[1])**2))

Measured memory_bytes: 9524
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }

int n;
bool f[100][10];
ll p[100][11];

int main() {
    cin >> n;
    rep(i, n) rep(j, 10) cin >> f[i][j];
    rep(i, n) rep(j, 11) cin >> p[i][j];

    ll ans = -LLINF;
    for (int b = 1; b < 1<<10; b++) {
        ll tmp = 0;
        for (int i = 0; i < n; i++) {
            int cnt = 0;
            for (int j = 0; j < 10; j++) {
                if (f[i][j] && (b & 1<<j)) cnt++;
            }
            tmp += p[i][cnt];
        }
        chmax(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    ll n;cin>>n;
    ll a=0,b=0,c=0,ans=0;
    for(ll i=0;i<n;i++){
        string s;cin>>s;
        for(ll j=0;j<ll(s.size())-1;j++)if(s[j]=='A' && s[j+1]=='B')ans++;

        if(s[0]=='B' && s[s.size()-1ll]=='A')c++;
        else if(s[0]=='B')b++;
        else if(s[s.size()-1ll]=='A')a++;
    }

    if(a>0 && b>0)ans+=min(a,b) + c;
    else if(a>0)ans+=c;
    else if(b>0)ans+=c;
    else ans+=max(0ll,c-1);

    cout<<ans;
}





Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
    	Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
	    
        if(N==1){
            System.out.println(1);
        }else if(N<=3){
            System.out.println(2);
        }else if(N>3 && N<8){
            System.out.println(4);
        }else if(N>=8 && N<16){
            System.out.println(8);
        }else if(N>=16 && N<31){
            System.out.println(16);
        }else if(N>=32 && N<64){
            System.out.println(32);
        }else{
            System.out.println(64);
        }
	    

    }
}


Measured memory_bytes: 23252
import sys
import bisect
from collections import deque

input = sys.stdin.readline
N = int(input())
xy = sorted([[i] + list(map(int, input().split())) for i in range(N)], key=lambda x: x[1])


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(N)
ys = deque([(xy[0][2], xy[0][0])])  # union毎に最小のyのみ保持する
for i, x, y in xy[1:]:
    if ys[0][0] >= y:
        ys.appendleft((y, i))
        continue
    miny, minj = ys[0]
    while len(ys)>0:
        y_, j = ys.popleft()
        if y_ >= y:
            ys.appendleft((y_, j))
            break
        uf.union(i, j)
    ys.appendleft((miny, minj))
for i in range(N):
    print(uf.size(i))


Measured memory_bytes: 121844
#include <iostream>
#include <string>

int main() {
  int sx, sy, tx, ty;
  std::cin >> sx >> sy >> tx >> ty;

  int dx = tx-sx;
  int dy = ty-sy;

  std::string res;

  // s -> t
  res += std::string(dx, 'R');
  res += std::string(dy, 'U');

  // t -> s
  res += std::string(dx, 'L');
  res += std::string(dy, 'D');

  // s -> t
  res += 'D';
  res += std::string(dx+1, 'R');
  res += std::string(dy+1, 'U');
  res += 'L';

  // t -> s
  res += 'U';
  res += std::string(dx+1, 'L');
  res += std::string(dy+1, 'D');
  res += 'R';

  std::cerr << res.length() << std::endl;
  std::cout << res << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);
	ll l,r;cin>>l>>r;
	if(r-l >= 2019){
		cout << 0 << endl;
	}else{
		ll ans = INF;
		for(ll i = l; i < r; i++){
			for(ll j = i+1; j <=r;j++){
				ans = min(ans,(i%2019*j%2019)%2019);
			}
		}
		cout << ans << endl;
	}
}



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

using namespace std;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

int a, b, c, d;

int main()
{
	a = gi(), b = gi(), c = gi(), d = gi();
	if (d == 1) puts("1");
	else puts("0");
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
long long a[100010];
bool cmp(long long x,long long y)
{
	return x>y;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a,a+n,cmp);
	long long x=0,y=0;
	int p=0,k=0;
	for(int i=0;i<n-1;i++)
	{
		if(a[i]==a[i+1])
		{
			if(k==0)
			{
				x=a[i];
			}
			else
			{
				y=a[i];
			}
			k=1;
			p++;
			i++;
		}
		if(p==2)
		{
			break;
		}
	}
	printf("%lld\n",x*y);
}

Measured memory_bytes: 1152