akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using pll = pair<long long, long long>;

main()
{
    int N;
    cin >> N;
    vector<pll> xy(N);
    for (int i = 0; i < N; ++i) {
        cin >> xy[i].first >> xy[i].second;
    }

    int par = (abs(xy[0].first) + abs(xy[0].second)) % 2;
    for (int i = 0; i < N; ++i) {
        int par2 = (abs(xy[i].first) + abs(xy[i].second)) % 2;
        xy[i] = pll(xy[i].first + xy[i].second, xy[i].first - xy[i].second);
        if (par2 != par) {
            cout << -1 << endl;
            return 0;
        }
    }

    vector<long long> d;
    for (int i = 30; i >= 0; --i) {
        d.push_back(1LL << i);
    }
    if (par % 2 == 0) {
        d.push_back(1);
    }
    cout << d.size() << endl;
    for (int j = 0; j < d.size(); ++j) {
        cout << d[j] << " ";
    }
    cout << endl;

    for (int i = 0; i < N; ++i) {
        int xdir, ydir; // x, yが正方向に向いているかどうか判定する
        long long xsum = 0, ysum = 0; // x,y方向の距離の合計
        for (int j = 0; j < (int)d.size(); ++j) {
            if (xsum <= xy[i].first) {
                xdir = 1, xsum += d[j];
            } else {
                xdir = -1, xsum -= d[j];
            }
            if (ysum <= xy[i].second) {
                ydir = 1, ysum += d[j];
            } else {
                ydir = -1, ysum -= d[j];
            }

            if (xdir == 1 && ydir == 1) {
                cout << "R";
            } else if (xdir == 1 && ydir == -1) {
                cout << "U";
            } else if (xdir == -1 && ydir == -1) {
                cout << "L";
            } else {
                cout << "D";
            }
        }
        cout << endl;
    }
}

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

using namespace std;

typedef long long int ll;

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

  int n;
  cin >> n;
  vector < int > a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  ll ans = a[0] - 1;
  int mx = 2;
  for (int i = 1; i < n; i++) {
    if (a[i] == mx) mx++;
    else if (a[i] > mx) {
      ans += (a[i] - 1) / mx;
    }
  }

  cout << ans << '\n';
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  int n;cin>>n;
  int odd = n%2;
  if(odd)n--;

  vector<pair<ll, ll>> g;
  if((odd+n)>=5)rep(i, n/2-1){
    g.push_back(make_pair(i+1, i+2));
    g.push_back(make_pair(i+1, n-1-i));

    g.push_back(make_pair(n-i, i+2));
    g.push_back(make_pair(n-i, n-1-i));
  }

  if(odd){
   n++;
    g.push_back(make_pair(1, n));
    g.push_back(make_pair(n-1, n));
    if(n>3){
      g.push_back(make_pair(n, (n-1)/2));
      g.push_back(make_pair(n, (n-1)/2+1));
    }
  }else{
    g.push_back(make_pair(1, n/2));
    g.push_back(make_pair(1, n/2+1));
    g.push_back(make_pair(n, n/2));
    g.push_back(make_pair(n, n/2+1));
  }
  cout<<g.size()<<endl;
  rep(i, g.size())cout<<g[i].first<<' '<<g[i].second<<endl;

  return 0;
}

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

int main() {
	while(1){
		int n,m=0,c=0;
		cin>>n;
		if(n==0){
			break;
		}
		for(int i=0;i<n;i++){
			int k;
			cin>>k;
			if(k>=1){
				if(k>=2){
				m++;
				}else{
					c++;
				}
			}	
		}
		if(m==0){
			cout<<"NA"<<endl;
		}else if(m!=0&&c!=0){
			cout<<m+c+1<<endl;
		}else{
			cout<<(m+1)<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

int main(){
    for(int i=0 ; i< 3000 ; i++){
        int x, y;
        scanf("%d%d", &x, &y);
        
        if(x==0 && y==0) break;
        if(x<=y)printf("%d %d\n", x,y);
        else if(x>y)printf("%d %d\n", y,x);
        
    }
    return 0;
}


Measured memory_bytes: 1980
#include <stdio.h>

int main(){
  int i,n,r;
  int a[100];
  int flag=1, count=0;

  scanf("%d",&n);

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

  while(flag){
    flag=0;
    for(i=n-1; i>0; i--){
      if(a[i]<a[i-1]){
	r=a[i];
	a[i]=a[i-1];
	a[i-1]=r;
	count++;
	flag=1;
      }
    }
  }

  for(i=0; i<n-1; i++)
    printf("%d ",a[i]);
  
  printf("%d\n%d\n",a[i],count);

  return 0;
}
	
	



Measured memory_bytes: 2140
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        w: u64, h: u64, n: usize,
        xya: [(u64, u64, usize); n]
    }

    let mut x_range = (0, w);
    let mut y_range = (0, h);
    for i in 0..n {
        let (x, y, a) = xya[i];
        match a {
            1 => x_range = (std::cmp::max(x_range.0, x), x_range.1),
            2 => x_range = (x_range.0, std::cmp::min(x_range.1, x)),
            3 => y_range = (std::cmp::max(y_range.0, y), y_range.1),
            _ => y_range = (y_range.0, std::cmp::min(y_range.1, y))
        };
    }
    println!("{}", (x_range.1.saturating_sub(x_range.0)) * (y_range.1.saturating_sub(y_range.0)));
}

Measured memory_bytes: 4352
/**
 *    author:  tesnik      
**/
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, r;
  cin >> n >> r;
  if (n <= 10) {
    cout << r + 100 * (10 - n) << "\n";
  } else {
    cout << r << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
Public Class Program
  Shared Sub Main()
    Dim n As Integer = Integer.Parse(Console.ReadLine())
    Dim a(0 To n - 1) As Long
    Dim c(0 To n) As Long
    For i As Integer = 0 To n - 1
      a(i) = Long.Parse(Console.ReadLine())
      c(i) = -1
    Next
    c(n) = -1
    For i As Integer = 0 To n - 1
      Dim j As Integer = Search(c, a(i), 0, i)
      c(j) = a(i)
    Next
    For i As Integer = 0 To n
      If c(i) = -1 Then
        Console.WriteLine(i.ToString())
        Exit For
      End If
    Next
  End Sub

  Shared Function Search(c As Long(), target As Long, min As Integer, max As Integer) As Integer
    While min < max
      Dim mid As Integer = min + ((max - min) \ 2)
      If c(mid) >= target Then
        min = mid + 1
      Else
        max = mid
      End If
    End While
    Return min
  End Function
End Class

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

using namespace std;

#define pb push_back
#define sz(a) ((int)a.size())
#define mp make_pair
#define fi first
#define se second

const int maxn = 1e5 + 5;

const int maxv = 1e9;

int T, tc;

int main() {
//	freopen("inp.txt", "r", stdin);
    
    char x;
    cin >> x;
    if (x >= 'A' && x <= 'Z') {
		puts("A");
	}
	else puts("a");
    
    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i, N) cin >> a[i];
  sort(ALL(a));
  cout << a[N - 1] - a[0] << endl;
  return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  C
//
//  Created by 曾憲揚 on 2020/8/19.
//  Copyright © 2020 曾憲揚. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5+5;
int o[maxn];


int main(int argc, const char * argv[]) {
    int n; cin>>n;
    
    int a;
    for(int i=1; i<n; i++){
        cin>>a; o[a]++;
    }
    for(int i=1; i<=n; i++){
        cout<<o[i]<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 4388
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <string>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
using namespace std;
 
int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, x;
  cin >> x >> n;
  if(n==0){
    cout << x << endl;
    return 0;
  }
  vector<int> nmap(200);
  for(int i=0; i<200; i++){
    nmap[i] = i-50;
  }
 
  for(int i=0; i<n; i++){
    int temp;
    cin >> temp;
    nmap[temp+50] = -200;
  }
  
  sort(nmap.begin(), nmap.end());
  
  int ans=100, diff=100;
  for(int i=nmap.size(); i>=0; i--){
    if(abs(nmap[i]-x)<=diff){
      diff = abs(nmap[i]-x);
      ans = nmap[i];
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3652
n=int(input())
hoge=list(map(int,input().split()))
ans=0

while 1:
  flag=0
  for i in range(n):
    if(hoge[i]%2==1):
      flag=1
    else:
      hoge[i]=hoge[i]/2

  if(flag==0):
    ans+=1
  else:
    break

print(ans)

Measured memory_bytes: 3060
uses math;
const max=1000000007;
var
        f: text;
        x: array [0..1000,0..1000] of char;
        e: array [0..1001] of longint;
        a,b,c,i,j: longint;

begin

        readln( a,b);
        for i:=1 to a do
        begin
        for j:=1 to b do read (x[i,j]);
        readln;
        end;


        e[1]:=1;

        for i:=1 to a do
        for j:=1 to b do
        if x[i,j] = '#' then e[j]:= 0 else e[j]:= (e[j-1] + e[j] ) mod max ;

        write (e[b]);
        readln;

end.

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

int main(void){
    int n,m;
    priority_queue<int> a;
    long sum=0;
    cin >> n >>m;
    rep(i,n){
        int x;
        cin >> x;
        a.push(x);
    }
    while(m){
        int b = a.top();
      	a.pop();
        b = b/2;
        m--;
      	a.push(b);
        
    }
    while(!a.empty()){
        sum += a.top();
        a.pop();
    }
    
    
    cout << sum ;
    
    
    return 0;
}






Measured memory_bytes: 892
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
    ll n;
    cin>>n;
    ll a[n];
    long double ans=1;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==0)
        ans=0;
        if(ans!=-1)
        ans=ans*a[i];
        if(ans>1000000000000000000)
        ans=-1;
    }
    cout<<(ll)ans<<endl;
	return 0;
}

Measured memory_bytes: 4404
#include <cstdio>
#define N 2010
#define INF 1e18
long long n, m, a[N], b[N], c[N], d[N/2];
int main() {
	int i, j;
	scanf("%lld%lld", &n, &m);
	for(i=0; i<m; i++) scanf("%lld%lld%lld", &a[i], &b[i], &c[i]);
	for(i=1; i<=n; i++) d[i] = -INF;
	d[1] = 0;
	for(i=0; i<n; i++) for(j=0; j<m; j++) {
		if(d[a[j]] != -INF && d[b[j]] < d[a[j]] + c[j]) {
			d[b[j]] = d[a[j]] + c[j];
			if(i==n-1 && b[j]==n) d[0] = 1;
		}
	}
	d[0] ? puts("inf") : printf("%lld", d[n]);
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CStreamline solver = new CStreamline();
        solver.solve(1, in, out);
        out.close();
    }

    static class CStreamline {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] a = new int[m];
            for (int i = 0; i < m; i++) {
                a[i] = in.nextInt();
            }
            Arrays.sort(a);
            int[] b = new int[m];
            for (int i = 1; i < m; i++) {
                b[i] = a[i] - a[i - 1];
            }
            Arrays.sort(b);

            long ans = 0;
            for (int i = m - n; i >= 0; i--) {
                ans += b[i];
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main(){
  string a;
  cin>>a;
  int i=0;
  if(a[0]=='1') i++;
  if(a[1]=='1') i++;
  if(a[2]=='1') i++;
  
  cout<<i<<endl;
}
 
  
  

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vl vector<ll>
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N, M, P=1000000007;
  int a, b, c;
  std::cin >> N >> M;
  vector<vvi> dp(N+1, vv(N+1, N+1, 0, int));
  int check[N+1][N+1][N+1];
  for(int i=0;i<=N;i++)for(int j=0;j<=N;j++)for(int k=0;k<=N;k++)check[i][j][k] = 1;
  for(int i=0;i<M;i++){
    //scanf("%d %d %d", &a, &b, &c);
    std::cin >> a >> b >> c;
    for(int i=0;i<b;i++){
      for(int j=0;j<=i;j++){
        if((i!=0&&i==j)||(c==1&&(i>=a||j>=a))||(c==2&&!(i>=a&&j<a))||(c==3&&!(i>=a&&j>=a))) {
          check[b][i][j] = check[b][j][i] = check[i][b][j] = 0;
          check[i][j][b] = check[j][b][i] = check[j][i][b] = 0;
        }
      }
    }
  }
  dp[0][0][0] = 1;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<N;k++){
        int m = max({i, j, k});
        if(check[i][j][k]==0) continue;
        dp[m+1][j][k] = (dp[m+1][j][k]+dp[i][j][k])%P;
        dp[i][m+1][k] = (dp[i][m+1][k]+dp[i][j][k])%P;
        dp[i][j][m+1] = (dp[i][j][m+1]+dp[i][j][k])%P;
      }
    }
  }
  int ans = 0;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N;j++){
      for(int k=0;k<=N;k++){
        if(i==N||j==N||k==N) {
          if(check[i][j][k]==0) continue;
          ans = (ans + dp[i][j][k])%P;
        }
      }
    }
  }
  std::cout << ans << '\n';
  //-------------------------------------------------------------------
  return 0;
}


Measured memory_bytes: 216832
//https://arc096.contest.atcoder.jp/tasks/arc096_c
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, a) for (int i = 0; i < (a); ++i)
#define DEBUG(x) { cerr << #x << '=' << x << endl; }
#define Arr(a, l, r) { cerr << #a << " = {"; FOR(_, l, r) cerr << ' ' << a[_]; cerr << "}\n"; }
#define N 3030
#define pp pair<int, int>
#define endl '\n'
#define IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define taskname ""
#define bit(S, i) (((S) >> (i)) & 1)
using namespace std;

// f[n][k] : Divide n people into k group and someone can belong to no group.

int n;
long long MOD, f[N][N], c[N][N];

long long Pow(long long a, long long k, long long MOD) {
    if (k == 0) return 1;
    long long t = Pow(a, k >> 1, MOD);
    t = t * t % MOD;
    if (k % 2) t = t * a % MOD;
    return t;
}
long long POW[N], PPOW[N];
void Init() {
    cin >> n >> MOD;
    f[0][0] = c[0][0] = 1;
    FOR(nn, 1, n) {
        c[nn][0] = f[nn][0] = 1;
        FOR(k, 1, nn) {
            f[nn][k] = (f[nn - 1][k - 1] + f[nn - 1][k] * (k + 1)) % MOD;  
            c[nn][k] = (c[nn - 1][k] + c[nn - 1][k - 1]) % MOD;
        }
    } 
    POW[0] = 1;
    PPOW[0] = Pow(2ll, 1, MOD);
    FOR(i, 1, n) {
        POW[i] = POW[i - 1] * 2 % (MOD - 1);
        PPOW[i] = Pow(2ll, POW[i], MOD);
    }
}


// Way(i) = Sum(Way2(i, j)), j = 1..i
long long calWay2(int i, int j) {
    //Divide i first elements into j ramen and add ramen of (n - i) another elements to j groups or outside.
    long long res = f[i][j];
    //DEBUG(i);DEBUG(j);DEBUG(f[i][j]);
    res = res * Pow(2ll, 1ll * (n - i) * j, MOD) % MOD; 
    //return res;
    // (2 ^ (n - 1) -> number of ramen of j topping) ^ j -> into j groups
    res = res * PPOW[n - i] % MOD;
    // 2 ^ (2 ^ (n - 1)) -> Choose ramen of (n - i) topping outside
    // 2 ^ (p - 1) mod p = 1 mod p
    return res;
}

// Number ways to topping 1..i used at most one, i + 1..n is arbitrary.    
long long calWay(int i) {
    long long res = 0;
    FOR(j, 0, i) res = (res + calWay2(i, j)) % MOD;
    return res;
}

// -> Inclusion - exclusicion
void Solve() {
    long long hs = -1;
    long long res = 0;
    FOR(i, 0, n) {
        hs *= -1;
        res = (res + MOD + hs * c[n][i] * calWay(i) % MOD) % MOD;
    }
    cout << res << '\n';
}
int main() {
    #ifdef NERO
    //freopen("test.inp","r",stdin);
    //freopen("test.out","w",stdout);
    double stime = clock();
    #else 
        //freopen(taskname".inp","r",stdin);
        //freopen(taskname".out","w",stdout);
    #endif //NERO
    IO;
    Init();
    Solve();
    #ifdef NERO
    double etime = clock();
    cerr << "Execution time: " << (etime - stime) / CLOCKS_PER_SEC * 1000 << " ms.\n";
    #endif // NERO
}

Measured memory_bytes: 141952
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
s = [input() for _ in range(n)]
c = [Counter(s[i]) for i in range(n)]
res = []
for key in list(c[0]):
    m = c[0][key]
    for i in range(1,n):
        m = min(m, c[i][key])
    for _ in range(m):
        res.append(key)
res.sort()
print(''.join(res))

Measured memory_bytes: 5112
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using P = pair<int, int>;
using MATRIX = vector< vector<ll> >;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}

int N;
int a[200000];
int b[200000];
int c[200001] = {0};
int d[200000] = {0};

const int INF = 1000000000;

int main() {
  cin >> N;
  rep(i, N) {
    cin >> a[i];
    c[a[i]]++;
  }
  rep(i, N) {
    cin >> b[i];
    d[b[i]]++;
  }
  rep(i, N) {
    if(c[i+1] + d[i+1] > N) {
      cout << "No" << endl;
      return 0;
    }
  }
  rep(i, N) {
    c[i+1] += c[i];
    d[i+1] += d[i];
  }
  int x = INF;
  rep(i, N) {
    x = min(x, d[i]-c[i+1]+N);
  }
  cout << "Yes" << endl;
  rep(i, N) {
    cout << b[(i+x+N)%N] << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 6708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for(ll i=(ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
constexpr ll INF = 1LL<<60;

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

    ll t = min(b-1, n), ans = -INF;
    for(ll i=t; i>=t-10000000; --i) {
        chmax(ans, (a*i)/b - a*(i/b));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3564
#include <stdio.h>
#include <math.h>

int main()
{
    int a, b, C;

    scanf("%d %d %d", &a, &b, &C);

    printf("%lf\n", (double)1/2*a*b*sin(C*M_PI/180.0));
    printf("%lf\n", (double)a+b+sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(C*M_PI/180.0)));
    printf("%lf\n", (double)b*sin(C*M_PI/180.0));
    return 0;
}

Measured memory_bytes: 2908
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;

int main(){
  ll n;
  cin >> n;
  ll total = 1;
  bool flag = true;
  bool zflag = false;
  ll limit = pow(10, 18);
  vector<ll> a(n);
  rep(i, n){
    cin >> a[i];
    if (a[i] == 0)
      zflag = true;
  }
  rep(i, n){
    double t1 = log10(total);
    double t2 = log10(a[i]);
    if (t1 + t2 > 18.0 || zflag){
      flag = false;
      break;
    }
    total *= a[i];
    if (total > limit){
      flag = false;
      break;
    }
  }
  if (zflag)
    cout << 0 << endl;
  else if (flag)
    cout << total << endl;
  else
    cout << -1 << endl;
  
  return 0;
}

Measured memory_bytes: 4112
# AtCoder Beginner Contest 126
# https://atcoder.jp/contests/abc126
import sys
import math
#import numpy as np

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, K = i2nn()
    ans = max((N - K + 1) / N, 0)
    n = min(N, K - 1)
    l = 1
    r = 1.0
    while True:
        if n <= 0:
            break
        l *= 2
        r *= 0.5
        d = n * l - (K-1)
        if d > 0:
            d2 = math.ceil(d / l)
            ans += (d2 / N) * r
            n -= d2
    print(ans)

main()


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

long long func(long long a) {
  return a < 0 ? 0 : a;
}

int main () {
  long long N, A, B;
  cin >> N >> A >> B;
  cout << (B - A < 0 || (A != B && N <= 1)? 0 : func(N - 2) * (B - A) + 1) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  double a,b;
  int x;
  scanf("%lf %lf",&a,&b);
  if((a+b)/2-(int)((a+b)/2)!=0.0)x=(a+b)/2+1;
  else x=(a+b)/2;
  printf("%d\n",x);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a[4];
int main() {
   for (int i=0; i<6; i++) {
       int t; cin >> t; a[t-1]++;
   } sort(a,a+4);
   //for (int x: a) cout << x;
   for (int i=0; i<4; i++) {
       if ((i==2 || i==3) && a[i]>=2) continue;
       if ((i==0 || i==1) && a[i]>=1) continue;
       cout << "NO"; return 0;
   }
   cout << "YES";
}

Measured memory_bytes: 3516
using System;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputPrice = int.Parse(Console.ReadLine());
            var inputCount = int.Parse(Console.ReadLine());

            var s = new Sample();
            var reminder = s.GetReminderDividedBy500(inputPrice);
            var result = s.Solve(reminder, inputCount);
            Console.WriteLine(result);
        }
    }
  
  	class Sample
    {
        public int GetReminderDividedBy500(int x)
        {
            return x % 500;
        }

        public string Solve(int price, int n)
        {
            if (n < price)
            {
                return "No";
            }
            return "Yes";
        }
    }
}

Measured memory_bytes: 27376
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <iterator>
#include <algorithm>

typedef long long lint;

using namespace std;

void showIntArray(lint a[], lint n);

int upper_sum(vector<int> w, int N, int T) {
  int s = 0;
  for (int i = 0; i < N; i++) {
    if (w[i] >= T) {
      s += w[i];
    }
  }
  return s;
}

int lower_sum(vector<int> w, int N, int T) {
  int s = 0;
  for (int i = 0; i < N; i++) {
    if (w[i] < T) {
      s += w[i];
    }
  }
  return s;
}

int sum(vector<int> w, int start, int end) {
  int s = 0;
  for (int i = start; i < end; i++) {
    s += w[i];
  }
  return s;
}

int main() {
  int N, tmp;
  vector<int> w;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    w.push_back(tmp);
  }
  // sort(w.begin(), w.end());
  int result = -1, pre_result = -1;
  for (int i = 0; i < N; i++) {
    // int left_sum = lower_sum(w, N, T);
    int left_sum = sum(w, 0, i);
    // cout << left_sum << endl;
    // int right_sum = upper_sum(w, N, T);
    int right_sum = sum(w, i, N);
    // cout << right_sum << endl;
    // cout << endl;
    result = abs(right_sum - left_sum);
    if (left_sum >= right_sum) {
      result = min(result, pre_result);
      break;
    } else {
      pre_result = result;
    }
  }
  cout << result << endl;
  return 0;
}

void showIntArray(lint a[], lint n) {
  for (int i=0; i<n; i++) {
    cout << a[i] << ' ';
  } cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d",res);
#define pfl(res) printf("%lld",res);
#define pfd(res) printf("%lf",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
typedef vector<int> vi;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int a[maxii];
int b[maxii];
int c[maxii];

int main()
{
    int n;
    sc(n);
    for(int i=0;i<n;i++)
    {
        sc(a[i]);
        sc(b[i]);
        sc(c[i]);
    }
    for(int i=1;i<n;i++)
    {
        a[i]+=max(b[i-1],c[i-1]);
        b[i]+=max(c[i-1],a[i-1]);
        c[i]+=max(a[i-1],b[i-1]);
    }
    int res=max(a[n-1],max(b[n-1],c[n-1]));
    pf(res);
}






Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N,M;
    cin>>N>>M;
    ll sum=0;
    F0R(x,M)
    {
    	int nb;
    	cin>>nb;
    	sum+=nb;
    }
    if(N-sum<0)
    	cout<<-1<<endl;
    else
    	{
			cout<<N-sum<<endl;
		}
	
	return 0;
}
 


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

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


signed main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    for(auto& x : s)
        cin >> x;
    vector<vector<int>> a(h, vector<int>(w));
    int sx = -1, sy = -1;
    for(int i = 0; i < h; ++i)
        for(int j = 0; j < w; ++j){
            a[i][j] = (s[i][j] == '#');
            if(s[i][j] == 'S'){
                sx = i, sy = j;
            }
        }

    vector<int> dx{1, 0, -1, 0};
    vector<int> dy{0, 1, 0, -1};
    auto ptoi = [&](auto x, auto y){return x * w + y;};
    auto itop = [&](auto x){return make_pair(x / w, x % w);};
    vector<vector<int>> range(h, vector<int>(w, MOD));

    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> que;
    range[sx][sy] = 0;
    que.emplace(0, ptoi(sx, sy));
    while(!que.empty()){
        int x, y, dist;
        dist = que.top().first;
        tie(x, y) = itop(que.top().second);
        que.pop();
        if(range[x][y] != dist || dist >= k)
            continue;
        for(int d = 0; d < 4; ++d){
            int nx = x + dx[d];
            int ny = y + dy[d];
            if(nx < 0 || ny < 0 || nx >= h || ny >= w || a[nx][ny])
                continue;
            if(range[nx][ny] > range[x][y] + 1){
                range[nx][ny] = range[x][y] + 1;
                que.emplace(range[nx][ny], ptoi(nx, ny));
            }
        }
    }


    for(int i = 0; i < h; ++i){
        if(range[i][0] <= k){
            cout << 1 << endl;
            return 0;
        }
        if(range[i][w - 1] <= k){
            cout << 1 << endl;
            return 0;
        }
    }
    for(int i = 0; i < w; ++i){
        if(range[0][i] <= k){
            cout << 1 << endl;
            return 0;
        }
        if(range[h - 1][i] <= k){
            cout << 1 << endl;
            return 0;
        }
    }

    for(int i = 0; i < h; ++i)
        for(int j = 0; j < w; ++j)
            if(range[i][j] != MOD){
                que.emplace(0, ptoi(i, j));
                range[i][j] = 0;
            }

    while(!que.empty()){
        int x, y, dist;
        dist = que.top().first;
        tie(x, y) = itop(que.top().second);
        que.pop();
        if(range[x][y] != dist)
            continue;
        for(int d = 0; d < 4; ++d){
            int nx = x + dx[d];
            int ny = y + dy[d];
            if(nx < 0 || ny < 0 || nx >= h || ny >= w)
                continue;
            if(range[nx][ny] > range[x][y] + 1){
                range[nx][ny] = range[x][y] + 1;
                que.emplace(range[nx][ny], ptoi(nx, ny));
            }
        }
    }

    int val = MOD;
    for(int i = 0; i < h; ++i){
        val = min(val, range[i][0]);
        val = min(val, range[i][w - 1]);
    }
    for(int i = 0; i < w; ++i){
        val = min(val, range[0][i]);
        val = min(val, range[h - 1][i]);
    }
    cout << (val + k - 1) / k + 1 << endl;

}


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

#define pb push_back
#define ff first
#define ss second

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

ll s;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> s;
	ll x = s / 1000000000 + 1, y = 1000000000 - (s % 1000000000);
	if (s % 1000000000 == 0)
		x = s / 1000000000, y = 0;
	cout << "0 0 1 1000000000 " << x << ' ' << y << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n,s,x,a[10],e[11],c,i,j,m;
    int l[]={9,26,50,80,115,154,196,240,285,330};
    while(~scanf("%d%d",&n,&s)){
        x=c=m=0;
        for(i=0;i<11;i++)e[i]=0;
        for(i=0;i<n;i++){
            a[i]=n-i-1;
            e[a[i]]=1;
            x+=a[i]*(i+1);
        }
        if(s>330) m=n;
        do{
            if(x==s)c++;
            if(x>=s)m++;
            for(i=0;i<n;i++){
                x-=a[i]*(i+1);
                e[a[i]]=0;
                if(i<m)continue;
                if(i==0)
                    a[i]=(s-x<10&&!e[s-x]?s-x:10);
                else
                    do{a[i]++;}while(e[a[i]]);
                if(a[i]>9){m++;continue;}
if(s-x>l[m]){
while(s-x>l[m])m++;
continue;
}
                e[a[i]]=1;
                x+=a[i]*(i+1);
                for(i--;i>=0;i--){
                    for(j=0;j<10;j++){
                        if(e[j])continue;
                        a[i]=j;
                        e[a[i]]=1;
                        x+=a[i]*(i+1);
                        break;
                    }
                }
                if(x>s) {
                    m++;
                    if(m>=n) break;
                    continue;
                }
                m=0;
                break ;
            }
        } while(m<n);
        printf("%d\n",c);
    }
    return 0;
}

Measured memory_bytes: 1028
#include<cstdio> 
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
typedef long long ll;
const int N=1e6+5,M=2e6+5,mo=998244353;
int n,x,y,z,i,f[N],siz[N],len[N],mn,ce[5],p;
ll ans;
int tt,fst[N],nxt[N],b[N],c[N];
void cr(int x,int y,int z)
{
	tt++;
	b[tt]=y;
	c[tt]=z;
	nxt[tt]=fst[x];
	fst[x]=tt;
}
void dfs(int x,int y)
{
	siz[x]=1;
	for(int p=fst[x];p;p=nxt[p])
		if (b[p]!=y)
		{
			len[b[p]]=c[p];
			dfs(b[p],x);
			siz[x]+=siz[b[p]];
			cmax(f[x],siz[b[p]]);
		}
}
int main()
{
	scanf("%d\n",&n);
	fo(i,1,n-1)
	{
		scanf("%d %d %d",&x,&y,&z);
		cr(x,y,z);
		cr(y,x,z);
	}
	dfs(1,0);
	fo(i,1,n) 
	{
		ans+=1ll*min(siz[i],siz[1]-siz[i])*len[i];
		cmax(f[i],siz[1]-siz[i]);
	}
	ans*=2ll;
	fo(i,1,n) 
		if ((!ce[1])||(f[i]<f[ce[1]]))
		{
			ce[0]=1;ce[1]=i;
		}else if (f[i]==f[ce[1]])
		{
			ce[0]++;ce[2]=i;
		}
	if (ce[0]==2)
	{
		for (p=fst[ce[1]];p;p=nxt[p])
			if (b[p]==ce[2])
				ans-=c[p];
	}else
	{
		mn=1e9;
		for(p=fst[ce[1]];p;p=nxt[p])
			cmin(mn,c[p]);
		ans-=mn;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 21376
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}

char c[1000][1000];
int d[1000][1000];

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int h,w,k;
  cin>>h>>w>>k;
  P s;

  rep(i,h){
    cin>>c[i];
    rep(j,w){
      if(c[i][j]=='S') s=P(i,j);
    }
  }

  
  rep(i,h){
    rep(j,w){
      d[i][j]=INF;
    }
  }

  d[s.F][s.S]=0;
  queue<P> q;
  q.push(s);
  while(q.size()){
    P p=q.front(); q.pop();
    rep(k,4){
      int y=p.F+vy[k],x=p.S+vx[k];
      if(!(0<=x&&x<w&&0<=y&&y<h)) continue;
      if(c[y][x]!='#'&&d[y][x]>d[p.F][p.S]+1){
        d[y][x]=d[p.F][p.S]+1;
        q.push(P(y,x));
      }
    }
  }

  int ans=INF;

  rep(i,h){
    rep(j,w){
      if((i==0||i==h-1||j==0||j==w-1)&&d[i][j]<=k){
        //cout<<d[i][j]<<endl;
        //cout<<i<<j<<endl;
        ans=1;
      }else if(d[i][j]<=k){
        int res=(i+k-1)/k;
        res=min(res,(j+k-1)/k);
        res=min(res,(h-i-1+k-1)/k);
        res=min(res,(w-j-1+k-1)/k);
        ans=min(ans,res+1);
        //cout<<i<<' '<<j<<res<<endl;
      }
    }
  }

  cout<<ans<<endl;


}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define pb push_back
#define MAXN 21010
#define Scan(a) scanf("%I64d", &a)
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

int n;
string s;

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n;
    cin >> s;
    int res = 0;
    int now = 0;
    FOR(i,0,n-1) {
        if (s[i] == 'I') now++;
        else now--;
        res = max(res, now);
    }
    cout << res;
    return 0;
}


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

using namespace std;

const int p = 998244353;

int C[maxn][maxn], pw[maxn];

int n, k;

inline int f(int x, int y, int z){
	int sum = 0;
	for(int i = 0;i <= z;i++){
		if(i + y - 1 >= 0) sum = (sum + 1ll * C[x][i] * pw[i] % p * C[z + y - 1][i + y - 1]) % p;
	}
	//printf("%d %d %d %d--\n", x, y, z, sum);
	return sum;
}

int main(){
	scanf("%d%d", &k, &n);//是反着的 我吐了 
	C[0][0] = 1;
	for(int i = 1;i < maxn;i++){
		for(int j = 0;j <= i;j++){
			C[i][j] = C[i - 1][j];
			if(j){
				C[i][j] += C[i - 1][j - 1];
				if(C[i][j] >= p) C[i][j] -= p;
			}
		}
	}
	pw[0] = 1;
	for(int i = 1;i < maxn;i++) pw[i] = pw[i - 1] * 2 % p;
	for(int i = 2;i <= 2 * k;i++){
		int cnt = 0;
		for(int j = 1;j <= k;j++) cnt += i - j >= 1 && i - j <= k;
		if(i & 1) printf("%d\n", f(cnt / 2, k - cnt, n));
		else printf("%d\n", (f((cnt - 1) / 2, k - cnt, n) + f((cnt - 1) / 2, k - cnt, n - 1)) % p);
	}
}

Measured memory_bytes: 50696
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 1000 * 100 + 47;
const int MIN = 404;
const int MOD = INF;

int S[MIN][MIN];
PII E[MAX];


int main()
{
    // freopen("in.txt", "r", stdin);
    int n, m;
    scanf("%d%d", &n, &m);
    FOR(i, 0, m)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        --x, --y;
        E[i] = MP(x, y);
        
    }
    
    FOR(i, 0, m)
    {
        int x = E[i].first;
        int y = E[i].second;
        if (S[x][x] || S[y][y])
        {
            S[x][x] = S[y][y] = 1;
        }
        else
        {
            FOR(i, 0, n)
            {
                if (S[x][i] && S[y][i])
                {
                    S[x][x] = S[y][y]  = 1;
                }
                else if (S[x][i] || S[y][i])
                {
                    S[x][i] = S[y][i] = 1;
                }
            }
        }
        
        S[x][y] = S[y][x] = 1;
    }
    int ans = 0;
    FOR(i, 0, n)
    {
        FOR(j, 0, i)
        {
            if (S[i][i] || S[j][j]) continue;
            if (S[i][j] || S[j][i]) continue;

            bool ok = 1;
            FOR (k, 0, n)ok &= !(S[i][k] & S[j][k]);
            if(ok)ans++;
        }
    }
    
    cout << ans << endl;
    
    
    return 0;
}





Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
constexpr int MOD = 1000000007;

signed main(){
    string s; cin >> s;
    int N = s.size();
    auto memo = vectors( N + 2,13,-1LL);
    vector<int>base(s.size() + 1,0LL);
    base[ N - 1] = 1;
    
    for(int i = N - 2; i >= 0; --i)
        base[i] = (9 * base[i + 1] + base[i + 1]) % 13;
    
    for(int i = 0; i < 13; ++i)
        memo[s.size() - 1][i] = (i <= 9 and (s.back() == '?' or s.back() - '0' == i) ? 1 : 0);
    
    function<int(int,int)>solver = [&](int digit,int cmod){
        if( memo[digit][cmod] != -1LL) return memo[digit][cmod];
        memo[digit][cmod] = 0;
        int idx = digit;
        if(s[idx] == '?'){
            for(int num = 0; num < 10; ++num){
                int temp =  ( base[digit] * num ) % 13;
                int nmod =  (cmod - temp <= 0 ? cmod - temp + 13 : cmod - temp) % 13;
                memo[digit][cmod] += solver(digit + 1,nmod);
                memo[digit][cmod] %= MOD;
            }
        } else {
            int num = s[idx] - '0';
            int temp =  ( base[digit] * num ) % 13;
            int nmod =  (cmod - temp <= 0 ? cmod - temp + 13 : cmod - temp) % 13;
            memo[digit][cmod] += solver(digit + 1, nmod);
            memo[digit][cmod] %= MOD;
        }
        return (memo[digit][cmod]) % MOD;
    };
    cout << (solver(0,5)) << endl;
}



Measured memory_bytes: 25472
use std::io;
use std::collections::HashMap;
use std::cmp;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();

    let n: usize = buf.trim().parse().unwrap();

    let mut map = HashMap::new();
    for _ in 0..n {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let count = map.entry(buf).or_insert(0);
        *count += 1
    }
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let m: usize = buf.trim().parse().unwrap();
    for _ in 0..m {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let count = map.entry(buf).or_insert(0);
        *count -= 1
    }
    let max = cmp::max(*map.iter().max_by_key(|&(_, v)| v).unwrap().1, 0);
    println!("{}", max)

}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;

int main()
{
	LL a,b,x,ans;
	while(~scanf("%lld%lld%lld",&a,&b,&x)){
		if(!a) a = -x;
		else a--;
		printf("%lld\n",b/x - a/x);
	}
    return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
	"math"
)

func main() {
	var x, a, b float64
	fmt.Scan(&x, &a, &b)

	if math.Abs(x-a) < math.Abs(x-b) {
		fmt.Println("A")
		return
	}
	fmt.Println("B")
}


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

int main(){
	
	int a[10000],n,i;
	long long int sum=0;
	
	
	cin >> n;
	
	for(i=0;i<n;i++){
		cin >> a[i];
		sum+=a[i];
	}
	sort(a,a+n);
	cout << a[0] << " " << a[n-1] << " " << sum << endl;
}

Measured memory_bytes: 1220
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}
void YES(bool ok){
    cout << (ok ? "Yes" : "No") << endl;
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,m; cin >> n >> m;
    YES(n == m);
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N,M;
  cin >> N >> M;
  vi S(N),T(M);
  rep(i,N) cin >> S[i];
  rep(i,M) cin >> T[i];
  
  vvl dp(N+1,vl(M+1,1));
  rep(i,N) {
    rep(j,M) {
      if(S[i]!=T[j]) dp[i+1][j+1]=(dp[i+1][j]+dp[i][j+1]-dp[i][j]+INF)%INF;
      else dp[i+1][j+1]=(dp[i+1][j]+dp[i][j+1])%INF;
    }
  }
  
  cout << dp[N][M] << endl;
}

Measured memory_bytes: 34520
#!/usr/bin/env python3
import sys


def solve(H: int, W: int, h: int, w: int):
    res = (H-h)*(W-w)
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    h = int(next(tokens))  # type: int
    w = int(next(tokens))  # type: int
    solve(H, W, h, w)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if (N % 1000 == 0){
    cout << "Yes" << endl;
  }
  else if ((N - N % 1000) % 111 == 0 || (N - N % 10) % 111 == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256