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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

// {{{
template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar[0].size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}

template<typename T>
T digitsum(T x){
    T y=0;
    while(x){
        y += x % 10;
        x /= 10;
    }

    return y;
}
// }}}
/* vim:set foldmethod=marker: */


void bruteforce(){
    int n;
    cin >> n;
    vector<ll> A(n), B(n), C(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> C[i];
    }

    sort(all(A));
    sort(all(B));
    sort(all(C));

    ll ans=0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                if (A[i] < B[j] && B[j] < C[k]) {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;
}

void solve(){
    int n;
    cin >> n;
    vector<ll> A(n),B(n),C(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> C[i];
    }

    sort(all(A));
    sort(all(B));
    sort(all(C));


    // int s;
    // cin >> s;
    // cout << lower_bound(all(A), s) - A.begin() << endl;;
    ll ans=0;
    for (int i = 0; i < n; i++) {
        ll a, c;
        a = lower_bound(all(A), B[i]) - A.begin();
        c = upper_bound(all(C), B[i]) - C.begin();

        ans += a * (n-c);
    }

    cout << ans << endl;
}

int main(int argc, char const* argv[])
{

    // bruteforce();
    solve();

    return 0;
}

// sortの仕方
// int a[N];
// array<int,N> ar;
// vector<int> v;
//
// sort(a, a+N); // 配列
// sort(ar.begin(), ar.end()); // array
// sort(v.begin(), v.end()); // vector 昇順
// sort(v.begin(), v.end(), greater<int>()); // 降順

// Template
// template <class T>
// T foomax(T x, T y){
//   if (x > y){
//     return x;
//   }else{
//     return y;
//   }
// }

// string を int に変換 stoi("1010")
// int を string に変換 to_string(1010)


Measured memory_bytes: 2560
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        Arrays.sort(a);
        int kind = 1;
        for (int i = 1; i < n; i++) {
            kind += a[i - 1] == a[i] ? 0 : 1;
        }
        System.out.println(kind - (kind%2==1? 0 : 1));
    }
}

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

#define ll long long
#define ld long double
#define ull unsigned long long
#define pw(x) (1LL << (x))

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"

using namespace std;

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

    int n;
    cin >> n;
    vector<int> v(n);
    for (int &x : v)
        cin >> x;

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    cout << v.size() - (v.size() % 2 == 0) << '\n';

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<ll, int>> ab(n);
    rep(i, n) {
        ll a;
        int b;
        cin >> a >> b;
        ab[i] = {a, b};
    }
    sort(ab.begin(), ab.end());
    ll ans = 0;
    int cnt = 0;
    rep(i, n) {
        if ( cnt >= m ) break;
        if ( cnt + ab[i].second >= m ) {
            ans += ab[i].first * ( m - cnt );
            break;
        }
        else {
            ans += ab[i].first * ab[i].second;
            cnt += ab[i].second;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8)cout << "pon";
	else if (N % 10 == 3)cout << "bon";
	else cout << "hon";
}

Measured memory_bytes: 3636
#include <cstdio>
#include <algorithm>
#include <map>


using namespace std;



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

int C[9];

int A[30];


int main(){
	int T,t;
	int i,j,k;
	char c[40];
	bool f,g;	
	
	scanf("%d",&T);
	
	
	
	rep(t,T){
		rep(i,40)A[i]=0;
		
		rep(i,9){
			scanf("%d",&C[i]);
		}
		
		rep(i,9){
			scanf("%s",c);
			if(c[0]=='G'){
				C[i]+=10;
			}
			if(c[0]=='B'){
				C[i]+=20;
			}
			A[C[i]]++;
			
		}
		
		//rep(i,30)printf("%2d:%2d\n",i,A[i]);
		
		f=true;
		
		rep(i,30){
			if(A[i]!=1)continue;
			if(A[i+1]!=2)continue;
			if(A[i+2]!=3)continue;
			if(A[i+3]!=4)continue;
			if(A[i+4]!=5)continue;
			f=false;break;
		}
		
		if(f){
			rep(i,30){
				if(A[i]>=3)A[i]-=3;
			}
			
			
			rep(i,30){
				g=true;
				rep(j,3){
					if(A[i+j]==0)g=false;
				}
				if(g){
					rep(j,3)A[i+j]--;
					i--;
				}
			}
			f=false;
			rep(i,30){
				if(A[i]!=0)f=true;
			}
		}		
		//rep(i,30)printf("%2d:%2d\n",i,A[i]);
		
		if(f)puts("0");
		else puts("1");
			
	}
	
	
	

}

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

using namespace std;

int main()
{
	long long n,k,j,i;
	cin>>n>>k;
	vector<long long> h(n),dp(n,1000000000000);
	for(i=0;i<n;i++)
		cin>>h[i];
	dp[0]=0;
	dp[1]=abs(h[0]-h[1]);
	for(i=2;i<n;i++)
	{
		for(j=i-1;j>=0&&j>=i-k;j--)
			dp[i]=min(abs(h[i]-h[j])+dp[j],dp[i]);	
	}
	cout<<dp[n-1]<<endl;
  /*	for(i=0;i<n;i++)
      cout<<dp[i]<<" ";*/
}

Measured memory_bytes: 4776
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int c = sc.nextInt();
        int n = sc.nextInt();
        int n2 = n / 2;

        int[][] arrays = new int[n2][n2];

        for (int i = 0; i < n; i++) {
            char[] chars = sc.next().toCharArray();
            for (int j = 0; j < n; j++) {
                if (chars[j] == '0') continue;
                int x = get_x(i, n2);
                int y = get_y(j, n2);
                arrays[x][y] ^= get_bits(get_area(i, j, n2));
            }
        }
        int diffs = count_diff(arrays);
        //System.err.println(diffs);
        //printarr(arrays);
        int ans = (diffs == 0 ? 1 : 0);
        for (int i = 0; i < c - 1; i++) {
            int d = sc.nextInt();
            for (int j = 0; j < d; j++) {
                int ri = sc.nextInt() - 1, ci = sc.nextInt() - 1;
                int diff = add(ri, ci, n2, arrays);
                diffs += diff;
            }
            /**
             * check symmetric
             */
            if (diffs == 0) ans++;
        }
        System.out.println(ans);
    }

    private static void printarr(int[][] arrays) {
        for(int[] array: arrays) {
            System.err.println(Arrays.toString(array));
        }
    }

    private static int count_diff(int[][] arrays) {
        int ret = 0;
        for (int[] array : arrays) {
            for (int num : array) {
                if (num == 0 || num == 15) {
                } else {
                    ret++;
                }
            }
        }
        return ret;
    }

    static int add(int r, int c, int n2, int[][] arrays) {
        int x = get_x(r, n2);
        int y = get_y(c, n2);
        int address = x * n2 + y;
        int area = get_area(r, c, n2);
        int pre = arrays[x][y];
        int now = arrays[x][y] ^= get_bits(area);
        if (pre == 0 || pre == 15) {
            return 1;
        } else {
            if (now == 0 || now == 15) {
                return -1;
            } else {
                return 0;
            }
        }
    }

    static int get_area(int r, int c, int n2) {
        if (r < n2 && c < n2) {//左上
            return 0;
        } else if (r >= n2 && c < n2) {//右上
            return 1;
        } else if (r < n2 && c >= n2) {//左下
            return 2;
        } else {//右下
            return 3;
        }
    }

    static int get_bits(int area) {
        return (1 << area);
    }

    static int get_x(int r, int n2) {
        if (r >= n2) {
            return r - n2;
        } else {
            return n2 - r - 1;
        }
    }

    static int get_y(int c, int n2) {
        if (c >= n2) {
            return c - n2;
        } else {
            return n2 - c - 1;
        }
    }
}



Measured memory_bytes: 339592
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<string.h>
#include<algorithm>
#include <cmath>

using namespace std;

int N,x[8],y[8],i,j,k;

double r;

int main()
{
  cin >> N ;
  
  for(i=0;i<N;i++)
  {
    cin >>x[i] >> y[i];
  }
  r=0.0;
    
  for(i=0;i<N;i++)
  {
    for(j=0;j<N;j++)
    {
      r+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    }
  }
  
  r=r/N;
  

  printf("%lf",r);
  


  
  
 return 0; 
}

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
void chmin(int &a,int b){ if(a>b) a=b;}
typedef unsigned long long ull;
typedef long long ll;

int A,B,C,N;
int L[1005];
const ll INF=1e9+9;

int rec(int idx,int a,int b,int c) {
    if(idx==N){
        if(!a||!b||!c) 
            return INF;
        return abs(a-A)+abs(b-B)+abs(c-C);
    }

    int res=rec(idx+1,a,b,c);

    res=min(res,rec(idx+1,a+L[idx],b,c)+(a?10:0));
    res=min(res,rec(idx+1,a,b+L[idx],c)+(b?10:0));
    res=min(res,rec(idx+1,a,b,c+L[idx])+(c?10:0));

    return res;
}

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    cin >> N >> A >> B >> C;
    FOR(i,0,N)
        cin >> L[i];
    cout << rec(0,0,0,0) << endl;

    return 0;
}


Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  [a, b, x] <- getInts
  putStrLn $ if a <= x && x <= a + b then "YES" else "NO"

readInts :: BC.ByteString -> [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words

getInts :: IO [Int]
getInts = readInts <$> BC.getLine


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

int main(){
    int N, A, B;
    int total;
    cin >> N >> A >> B;
    for (int i = 1; i <= N; ++i){
        int divi = -1;
        int res = -1;
        int sum = 0;
        int j = i;
        while (true){
            divi = j / 10;
            res = j % 10;
            sum += res;
            if (divi == 0) break;
            else j = divi;
        }
        if (sum >= A && sum <= B) total += i;
    }
    cout << total << endl;
}

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

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#define ll              long long int
#define ull             unsigned long long
#define vi              vector<int>
#define vl              vector<ll>
#define vvi             vector<vector<int> >
#define pi              pair<int,int>
#define vii             vector<pi>

#define sz(v)           ((int)(v).size())
#define all(s)          s.begin(),s.end()
#define allr(s)         s.rbegin(),s.rend()
#define unq(c)          (sort(all(c)), c.resize(distance(c.begin(),unique(all(c)))))
#define get_pos(c,x)    (lower_bound(all(c),x)-c.begin())

#define MS0(v)          memset((v), 0, sizeof((v)))
#define MS1(v)          memset((v), -1, sizeof((v)))
#define LEN(v)          strlen(v)

#define MP              make_pair
#define pb              push_back
#define pob             pop_back
#define ff              first
#define ss              second
#define sc              scanf
#define pf              printf
#define endl            "\n"

#define TEST_CASE       int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define PRINT_CASE      printf("Case %d: ",cs)

#define vpf(v)          for(int i=0;i<v.size();i++){cout<<v[i];if(i!=v.size()-1)cout<<" ";else cout<<"\n";}
#define vsc(v)          for(int i=0;i<v.size();i++)cin>>v[i];

#define REP(i, n)       for (int i = 0; i < (n); i++)
#define REPP(i, a, b)   for (int i = (a); i < (b); i++)
#define FOR(i, a, b)    for (int i = (a); i <= (b); i++)
#define FORS(i, s)      for (int i = 0; s[i]; i++)

#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fileio          freopen("in.txt","r",stdin);freopen("out.txt","w",stdout)

#define intlim          2147483648
#define infinity        (1LL<<50)

#define gcd(a, b)       __gcd(a, b)
#define lcm(a, b)       ((a)*((b)/gcd(a,b)))


int on_bit(int N,int pos){return N = N | (1<<pos);}
int off_bit(int N,int pos){return N = N & ~(1<<pos);}
bool check_bit(ll N,int pos){return (bool)(N & (1<<pos));}


#define start_clock     clock_t tStart = clock()
#define end_clock       printf("\n>>Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC)



//____________________________________________________________________________________________________________




int main(){ 
    int k, n;
    cin >> k >> n;
    vi v(n), a;
    vsc(v);
    sort(all(v)); a = v;

    a[0]=0;
    for(int i=1;i<n;i++){
        a[i] = a[i-1] + v[i] - v[i-1];
    }

    int mx = 0, idx;

    for(int i=1;i<n;i++){
        if(a[i] - a[i-1] > mx){
            mx = a[i] - a[i-1];
            idx = i;
        }
    }

    int x = k - v.back() + v.front(); 

    //vpf(a);
    //cout<<"mx = "<<mx<<", x = "<<x<<endl;

    if(x > mx) cout<<a.back()<<"\n";
    else  cout << k - v[idx] + v[idx-1] <<"\n";
    return 0;
}

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

int a[20][20],c[20];
#define REP(i,n) for(int i=0;i<n;i++)
void chmin(int &a,int b){
  if(a>b)a=b;
}

int main(){
  int n,m,x,ans=1e9;cin>>n>>m>>x;
  REP(i,n){
    cin>>c[i];
    REP(j,m)cin>>a[i][j];
  }
  REP(bit,1<<n){
    int res=0;
    vector<int> tmp(m,0);
    REP(i,n){
      if((bit>>i)&1){
        res+=c[i];
        REP(j,m)tmp[j]+=a[i][j];
      }
    }
    REP(j,m)if(tmp[j]<x)res=1e9;
    chmin(ans,res);
  }
  cout<<(ans>1e8?-1:ans)<<endl;
}
    


Measured memory_bytes: 3620
#include <cstdio>
#include <algorithm>
#define $ ios::sync_with_stdio(0);
#include <iostream>
#define MAXN 312345
using namespace std;
int v[MAXN], b[MAXN], resp[MAXN];
int main()
{$
    string s;
    int n, tam;

    cin>>n>>s;
    for(int i = 0; i<n-1; ++i){
        if(s[i]=='E')
            ++v[i+1];
        v[i+1]+=v[i];
//        cout<<v[i]<<endl;
    }
//    cout<<v[n-1]<<endl;
    for(int i = n-1; i>0; --i){
        if(s[i]=='W')
            ++b[i-1];
        b[i-1]+=b[i];

    }

    int f = 0;
    if(n>=2)
    {
        resp[0] = b[0];
        resp[n-1] = v[n-1];
    }
    for(int i = 1; i<n-1; ++i)
    {
        resp[i] = v[i]+b[i];

        if(resp[f]<resp[i])
            f = i;
    }

    cout<< n-1-max(resp[0],max(resp[f], resp[n-1]))<<'\n';
}


Measured memory_bytes: 4244
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)

int count(int N)
{

        int cnt = 0;
        while (N)
        {
                cnt++;
                N /= 10;
        }
        return cnt;
}

int main()
{
        int N;
        cin >> N;
        bool ok = true;
        vector<int> t(N + 1, 0), x(N + 1, 0), y(N + 1, 0);
        rep(i, N) cin >> t[i + 1] >> x[i + 1] >> y[i + 1];

        rep(i, N)
        {
                int T = t[i + 1] - t[i];
                int X = x[i + 1] - x[i];
                int Y = y[i + 1] - y[i];
                if (T % 2 != (abs(X) + abs(Y)) % 2 || T < (abs(X) + abs(Y)))
                {
                        ok = false;
                        break;
                }
        }
        if (ok)
        {
                cout << "Yes" << endl;
        }
        else
        {
                cout << "No" << endl;
        }

        return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAX_N = 100005;

int A[MAX_N], N;

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);

  sort(A + 1, A + N + 1);
  reverse(A + 1, A + N + 1);

  for (int i = 1, last = 1; i <= N; ++i) {
    int j = i;
    while (j <= N && A[j] == A[i]) j++;

    int x = ((j - i) ^ 1) & 1;
    if (i - 1 == A[i]) {
      if (x && last) puts("Second");
      else puts("First");
      break;
    } else if (i - 1 < A[i] && j - 1 >= A[i]) {
      int d = ((j - A[i]) ^ 1) & 1;
      if (d == 1) puts("First");
      else puts("Second");
      break;
    } else if (j - 1 < A[i] && j - 1 > A[j]) {
      int d = ((A[i] - j + 2) ^ 1) & 1;
      if (d == 1) puts("First");
      else puts("Second");
      break;
    }
    
    last = ((A[i] - A[j]) ^ 1) & 1;
    i = j - 1;
  }
  
  return 0;
}


Measured memory_bytes: 512
N, M, C  = map(int, raw_input().split())
B_source = map(int, raw_input().split())

A_sources = []
for A_input in range(N):
  A_sources.append(map(int, raw_input().split()))

ok_source_count = 0
for i in range(N):
  i_results = []
  for j in range(M):
    i_results.append(A_sources[i][j] * B_source[j])

  check_value = sum(i_results, C)
  if check_value > 0:
    ok_source_count = ok_source_count + 1

print(ok_source_count)


Measured memory_bytes: 2568
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N = int(input())
a = []
for _ in range(N):
  x, y, d = input().split()
  x, y = map(int, (x, y))
  a.append((x, y, d))
a.sort()
c = dd(lambda: -1)
res = float("inf")
for x, y, d in a:
  if d == "R": c[y] = x
  if d == "L":
    if c[y] >= 0:
      res = min(res, (x - c[y]) * 5)
      c[y] = -1
c = dd(lambda: -1)
a.sort(key = lambda x: x[1])
for x, y, d in a:
  if d == "U": c[x] = y
  if d == "D":
    if c[x] >= 0:
      res = min(res, (y - c[x]) * 5)
      c[x] = -1

for i in range(N):
  a[i] = (a[i][0] + a[i][1], a[i][0] - a[i][1], a[i][2])
a.sort()
c = dd(lambda: -float("inf"))
for x, y, d in a:
  if d == "R": c[y] = x
  if d == "D":
    if c[y] != -float("inf"):
      res = min(res, (x - c[y]) * 5)
      c[y] = -float("inf")
c = dd(lambda: -float("inf"))
for x, y, d in a:
  if d == "U": c[y] = x
  if d == "L":
    if c[y] != -float("inf"):
      res = min(res, (x - c[y]) * 5)
      c[y] = -float("inf")
a.sort(key = lambda x: x[1])
c = dd(lambda: -float("inf"))
for x, y, d in a:
  if d == "R": c[x] = y
  if d == "U":
    if c[x] != -float("inf"):
      res = min(res, (y - c[x]) * 5)
      c[x] = -float("inf")
c = dd(lambda: -float("inf"))
for x, y, d in a:
  if d == "D": c[x] = y
  if d == "L":
    if c[x] != -float("inf"):
      res = min(res, (y - c[x]) * 5)
      c[x] = -float("inf")
#print(a, c)
if res == float("inf"): print("SAFE")
else: print(res)

Measured memory_bytes: 192672
import java.io.*;
import java.util.*;
public class Main{
public static void main(String[]args) throws IOException{
BufferedReader cin = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(cin.readLine());
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
int c = Integer.parseInt(st.nextToken());
boolean ret = false;
if(a == b)
if(b==c) ret = false;
else ret = true;
if(b==c) 
if(a==b) ret = false;
else ret = true;
if(a==c)
if(a==b) ret = false;
else ret = true;
if(ret) System.out.println("Yes");
else System.out.println("No");
}
}


Measured memory_bytes: 21076
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N, A, B = map(int, input().split())
    if N == 1 and A>B:
        print(0)
    else:
        mn=B+A*(N-1)
        mx=A+B*(N-1)
        print(max(mx-mn+1,0))

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#include <stdio.h>

int main(void){
	int N;
	scanf("%d",&N);
	long long C[N],S[N],F[N];
	int i,j;
	for(i=0;i<N-1;i++)scanf("%lld %lld %lld",&C[i],&S[i],&F[i]);
	for(i=0;i<N;i++){
		long long t = 0;
		
		for(j=i;j<N-1;j++){
			if(t<S[j])t=S[j];
			else if((t-S[j])%F[j]==0);
			else t=t+F[j]-(t-S[j])%F[j];
			t+=C[j];
		}
		printf("%lld\n",t);
	}
	return 0;
}

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

int main()
{
	long long N;
	cin >> N;

	vector<pair<long long, long long>> AB(N);
	for (long long i = 0; i < N; ++i) {
		cin >> AB[i].first >> AB[i].second;
	}

	sort(AB.begin(), AB.end(), [](pair<long long, long long>& x, pair<long long, long long>& y) {return x.second < y.second; });

	long long time = 0;
	bool isFailed = false;
	for (long long i = 0; i < N; ++i) {
		time += AB[i].first;
		if (time > AB[i].second) {
			isFailed = true;
			break;
		}
	}

	if (isFailed) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
const int N=500005;
struct node{int y,nxt;}e[N*2];
int h[N],n,m,x,w,c=0;
void add(int x,int y){
    e[++c]=(node){y,h[x]};h[x]=c;
    e[++c]=(node){x,h[y]};h[y]=c;
} int dfs(int x,int fa){
    int v=0;
    for(int i=h[x],y;i;i=e[i].nxt)
    if((y=e[i].y)!=fa) v^=(dfs(y,x)+1);
    return v;
} int main(){
    scanf("%d",&n);
    for(int i=1,x,y;i<n;i++)
    scanf("%d%d",&x,&y),add(x,y);
    if(n==1) return puts("Bob"),0;
    if(dfs(1,0)==0) puts("Bob");
    else puts("Alice");return 0;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
#include <fstream>
using namespace std;
ll fac[1000005];
void seive() {
    ll i,j;
    for(i=2;i<=1000;i++) {
        if(fac[i]==i)
        {
            for(j=i*i;j<=1000000;j+=i) {
                if(fac[j]==j)
                    fac[j]=i;
            }
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--) {
    ll n,m,i,j;
    cin>>n;
    ll arr[n+1];
    for(i=0;i<n;i++)
        cin>>arr[i];
    for(i=1;i<=1000000;i++)
        fac[i]=i;
    seive();
    map<ll,ll> mp;
    map<ll,ll> :: iterator it;
    set<ll> st;
    set<ll>:: iterator it2;
    ll f=1;
    for(i=n-1;i>=0;i--)
    {
        map<ll,ll> temp;
        ll x=arr[i];
        while(x>1) {
            ll y=fac[x];
            x/=y;
            temp[y]++;
        }
        if(i==n-1) {
        for(it=temp.begin();it!=temp.end();it++) {
                //cout<<it->first<<" "<<it->second<<"\n";
                st.insert(it->first);
                    mp[it->first]=it->second;
        }
        continue;
        }
         for(it=temp.begin();it!=temp.end();it++)
        {
           // cout<<"HII\n";
        //cout<<it->first<<" "<<it->second<<"\n";
            if(st.find(it->first)!=st.end())
                f=0;
            st.insert(it->first);
        }
        for(it=mp.begin();it!=mp.end();it++)
        {
            it->second=min(it->second,temp[it->first]);
        }

    }
    if(f)
        cout<<"pairwise coprime";
    else
    {
        for(it=mp.begin();it!=mp.end();it++)
            if(it->second)
            break;
        if(it==mp.end())
            cout<<"setwise coprime";
        else
            cout<<"not coprime";
    }

}
}


Measured memory_bytes: 22908
#include <stdio.h>
int main(){
    int time[5] = {0}, i;
    for (i = 0; i < 4; i++) {
        scanf("%d", &time[i]);
        time[4] += time[i];
    }
    
    printf("%d\n%d\n", time[4] / 60, time[4] % 60);
    return 0;
}

Measured memory_bytes: 592
function gcd(a, b) {
	while (true) {
		if (a > b) {
			a = a % b;
			if (a === 0) return b;
		} else {
			b = b % a;
			if (b === 0) return a;
		}
	}
}

function Main(input) {
const lines = input;
const NS = lines[0].split(' ');
const N = Number(NS[0]);
const S = Number(NS[1]);
 
console.log(3 * (N - gcd(N - S, S)));
}
 
Main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n'));
 


Measured memory_bytes: 7372
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
 	int n,l;
  	scanf("%d%d",&n,&l);
  	char string[n+1][l+1];
  	for(int i=0; i<n; i++){
     scanf("%s",string[i]); 
    }
  	for(int i=0; i<n; i++){
     for(int j=0; j<n-1-i; j++){
      if(strcmp(string[j],string[j+1]) > 0){
       	char temp[l+1];
        strcpy(temp,string[j]);
        strcpy(string[j],string[j+1]);
        strcpy(string[j+1],temp);
      }
     }
    }
  	for(int i=0; i<n; i++){
     printf("%s",string[i]); 
    }
}


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll n,ans=0;
    cin >> n;
    vector<ll> v(n),c(n);
    rep(i,n) cin >> v[i];
    rep(i,n) cin >> c[i];
    rep(i,n){
        if(v[i]-c[i]>0) ans += (v[i]-c[i]); 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int maxsumEx(int a,int b,int c,int count);
int max(int a,int b,int c);
int main() {
	int A,B,C,count;
	cin >> A >> B >> C >> count;
	cout << maxsumEx(A,B,C,count);
	return 0;
}
int maxsumEx(int a,int b,int c,int count){
	if (count==0) return a+b+c;
	else return max(maxsumEx(a*2,b,c,count-1),maxsumEx(a,b*2,c,count-1),maxsumEx(a,b,c*2,count-1));
}
int max(int a,int b,int c){
	if(a>=b&&a>c) return a;
	else if(b>a&&b>=c) return b;
	else return c;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n, a, b, c;
	cin>>n;
	while(n) {
		cin>>a>>b>>c;
		if(a*a==b*b+c*c || b*b==a*a+c*c || c*c==a*a+b*b)
			printf("YES\n");
		else printf("NO\n");
		n--;
	}
	return 0;
} 


Measured memory_bytes: 3056
N = int(input())

primes = [2,3,5,7]
ans = []
for n in range(11,55555+1):
    for p in primes:
        if n % p == 0:
            break
    else:
        primes.append(n)
        if n%5==1:
            ans.append(n)
            if len(ans) >= N:
                break
print(" ".join(map(str,ans)))

Measured memory_bytes: 3060
import std.stdio, std.string, std.conv, std.algorithm;
void main(){
	long n, m, v, p, z, s;
	scanf("%d %d %d %d\n", &n, &m, &v, &p);
	auto A = readln.split.to!(long[]);
	A.sort!"a>b"();
	z = p - 1;
	auto B = A[z .. $];

	foreach(u, a; B){
		if(a + m >= B[0] && u * a - s + m * n >= m * v) s += a, z += 1;
		else break;
	}
	z.writeln;
}

Measured memory_bytes: 4440
#include<bits/stdc++.h>
using namespace std;
int main(){
  char b; cin >> b;
  if(b == 'A')
    cout << "T" << endl;
  else if(b == 'T')
    cout << "A" << endl;
  else if(b == 'C')
    cout << "G" << endl;
  else
    cout << "C" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	set<int> st;
	rep(i, 3) {
		int a;
		cin >> a;
		st.insert(a);
	}
	cout << st.size() << endl;
	return 0;
}


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    for (;;) {
        c -= b;
        if (c <= 0) {
            puts("Yes");
            return 0;
        }
        a -= d;
        if (a <= 0) {
            puts("No");
            return 0;
        }
    }
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define pb push_back
#define in(x) int x; cin>>x;
#define inn(x, y) int x, y; cin>>x>>y;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;

//int gcd(int a, int b){
//	return b==0 ? a : gcd(b, a%b);
//}

int32_t main(void){
	IOS;
	
	inn(a, b);
	in(c);
	int temp = a;
	a = b;
	b = temp;
	temp = a;
	a = c;
	c = temp;
	cout<<a<<" "<<b<<" "<<c;
	
	
}

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

int main() {
    int N;
    cin >> N;
    ll sum = 0;
    for (int i = 1; i <= N; i++) {
        if (i % 3 == 0 && i % 5 == 0) {

        } else if (i % 3 == 0) {
            
        } else if (i % 5 == 0) {

        } else {
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

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

	    if (a.equals ("A"))
	    	System.out.println("T");
	    else if (a.equals("T"))
	    	System.out.println("A");
	    else if (a.equals("C"))
	    	System.out.println("G");
	    else
	    	System.out.println("C");
	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 1e9;
constexpr long long INFLL = 1LL<<60;

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

  int h, w; cin >> h >> w;
  vector<vector<int>> a(h, vector<int>(w));
  rep(i, h) rep(j, w) cin >> a[i][j];

  vector<vector<int>> ans;

  rep(i, h) {
    rep(j, w) {
      if (a[i][j] % 2 == 0) continue;
      if (j < w-1) {
        ans.push_back({i, j, i, j+1});
        a[i][j+1]++;
      } else if (i < h-1) {
        ans.push_back({i, j, i+1, j});
        a[i+1][j]++;
      }
    }
  }

  cout << ans.size() << endl;
  for (auto& v : ans) {
    for (int j = 0; j < v.size(); j++) {
      cout << v[j] + 1;
      if (j == v.size() - 1) cout << endl;
      else cout << " ";
    }
  }

  return 0;
}


Measured memory_bytes: 10032
#include <stdio.h>

#define M 100

/*

int main(){

  int i,j,n,g[M][M],count=0,min,ti,tj;

  scanf("%d",&n);

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

  for(i=0;i<n;i++){

    min=2000;

    for(j=0;j<n;j++){

      if(g[i][j]!=-1){

	if(min>=g[i][j]){
	  min=g[i][j];
	  ti=i;
	  tj=j;
	}
      }
    }


    if(g[ti][tj])    count+=g[ti][tj];

    //   g[tj][ti]=-1;

  }


  printf("%d\n",count);

  return 0;

}



typedef struct{
  int omomi;
  int flag;
} gyouretu;

int main(){

  int i,j,n,count=0,min,ti,tj;
  gyouretu g[M][M];

  scanf("%d",&n);

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

  for(i=0;i<n;i++){

    min=2000;

    for(j=0;j<n;j++){

      if(g[i][j].omomi!=-1){
	if(min>=g[i][j].omomi){
	  min=g[i][j].omomi;
	  ti=i;
	  tj=j;
	}
      }
    }

    g[ti][tj].flag=1;

    if(g[tj][ti].flag!=1) count+=g[ti][tj].omomi;

  }

  printf("%d\n",count);

  return 0;

}
*/

#define inf 1000000
#define WHITE 1
#define BLACK 0

int g[M][M];

int prim(int,int);

int main(){

  int i,j,n,count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++) scanf("%d",&g[i][j]);
}
  printf("%d\n",prim(n,0));

  return 0;

}

int prim(int n,int r){

  int i,j,u,d[M],pi[M],color[M],mincost,v,count=0,a;

  for(u=0;u<n;u++){

    d[u]=inf;
    pi[u]=NULL;
    color[u]=WHITE;
}

  d[r]=0;

  for(a=0;a<n;a++){

    mincost=inf;

    for(i=0;i<n;i++){

      if(color[i]!=BLACK && d[i]<mincost){
	mincost=d[i];
	u=i;
      }

    }

    for(v=0;v<n;v++){

      if(color[v]!=BLACK && g[u][v]<d[v] && g[u][v]!=-1){
      
	pi[v];
	d[v]=g[u][v];

      }

    }

    color[u]=BLACK;

  }


  for(j=0;j<n;j++) count+=d[j];

  return count;

}

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

using namespace std;

#define REPEAT(i, N) for (int i = 0; i < (N); i++)

int main() {
  int R;
  
  cin >> R;
  cout << (double)R * 2 * 3.14159265358979;
  
  return 0;
}


Measured memory_bytes: 3784
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
#define D 100010
vector<pair<ll,ll> > y_x[D],x_y[D];
int h,w,n;

#define N 400010
typedef pair<ll,ll> P;
vector<P> v[N];
ll d[N];
priority_queue<P,vector<P>,greater<P> >Q;
ll Dijkstra(){
    fill(d,d+N,(ll)mod*(ll)mod);
    Q.push(make_pair(0,2*n));
    while(!Q.empty()){
	ll cost=Q.top().first;
	ll x=Q.top().second;
	Q.pop();
	if(d[x]<=cost)continue;
	d[x]=cost;
	for(auto u:v[x]){
	    Q.push(make_pair(cost+u.second,u.first));
	}
    }
    return (d[2*n+1]==(ll)mod*(ll)mod?-1:d[2*n+1]);
}
void MakeEdge(ll a,ll b,ll c){
    v[a].push_back(make_pair(b,c));
    v[b].push_back(make_pair(a,c));
}
int main(){
    cin>>h>>w>>n;
    lol(i,n){
	ll x,y;cin>>y>>x;
	y_x[y].push_back(make_pair(x,i));
	x_y[x].push_back(make_pair(y,i));
	MakeEdge(i,i+n,1);
    }
    lol(i,D){
	if(y_x[i].size()>0){
	    sort(y_x[i].begin(),y_x[i].end());
	    if(i==1){
		MakeEdge(2*n,y_x[i][0].second,y_x[i][0].first-1);
	    }
	    if(i==h){
		int t=y_x[i].size()-1;
		MakeEdge(2*n+1,y_x[i][t].second,w-y_x[i][t].first);
	    }
	    for(int j=0;j<y_x[i].size()-1;j++){
		MakeEdge(y_x[i][j].second,y_x[i][j+1].second,y_x[i][j+1].first-y_x[i][j].first);
	    }
	}
	if(x_y[i].size()>0){
	    sort(x_y[i].begin(),x_y[i].end());
	    if(i==w){
		int t=x_y[i].size()-1;
		MakeEdge(2*n+1,x_y[i][t].second+n,h-x_y[i][t].first);
	    }
	    for(int j=0;j<x_y[i].size()-1;j++){
		MakeEdge(x_y[i][j].second+n,x_y[i][j+1].second+n,x_y[i][j+1].first-x_y[i][j].first);
	    }
	}
    }
    //cout<<"#"<<endl;
    cout<<Dijkstra()<<endl;
    return 0;
}



Measured memory_bytes: 63324
fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    val W = listOf<String>().toMutableList()
    val alreadySaid = setOf<String>().toMutableSet()

    (1..N).forEach {
        val w = readLine()!!
        W.add(w)
    }

    var ok = true
    var lastChar : Char? = null

    W.forEach {
        if (alreadySaid.contains(it)) {
            ok = false;
            println("No")
            return
        }

        if (lastChar != null && it.get(0) != lastChar) {
            ok = false
            println("No")
            return
        }

        alreadySaid.add(it)
        lastChar = it.get(it.length - 1)
    }


    var answer = if (ok) "Yes" else "No"
    println(answer)
}


Measured memory_bytes: 33528
import java.util.Arrays;
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
      int k = sc.nextInt();
      int n = sc.nextInt();
      int[] a = new int[n];
      int max = 0;
      for(int i=0;i<n;i++){
        a[i] = sc.nextInt();
      }
      for(int i=0;i<n;i++){
        if(i==0){
          max = a[1]-a[0];
        }else if(i==n-1){
          if(max<(k-a[i])+a[0]){
            max = (k-a[i])+a[0];
          }
        }else{
          if(max<a[i+1]-a[i]){
            max = a[i+1]-a[i];
          }
        }
      }
      int ans = k-max;
      System.out.println(ans);
    }
}


Measured memory_bytes: 87356
#include <stdio.h>
#include <ctype.h>

struct entry
{
  int x1;
  int y1;
  int x2;
  int y2;
  int level;
  char *name;
};
static char         * e;
static struct entry   lis[ 1024 ];
static int            len;

static int
nanikaka (
  void
  )
{
  int nol;
  int res = 0;

  if ( e[ 0 ] != '<'
    || e[ 1 ] == '/' ) return ( 0 );

  nol = len++;
  lis[ nol ].name = ++e;
  while ( *e != '>' ) ++e;
  *( e++ ) = '\0';
  lis[ nol ].x1 =
  lis[ nol ].y1 =
  lis[ nol ].x2 =
  lis[ nol ].y2 = 0;
  while ( isdigit ( *e ) )  lis[ nol ].x1 = ( lis[ nol ].x1 * 10 )
                                          + ( *( e++ ) - '0' );
  ++e;
  while ( isdigit ( *e ) )  lis[ nol ].y1 = ( lis[ nol ].y1 * 10 )
                                          + ( *( e++ ) - '0' );
  ++e;
  while ( isdigit ( *e ) )  lis[ nol ].x2 = ( lis[ nol ].x2 * 10 )
                                          + ( *( e++ ) - '0' );
  ++e;
  while ( isdigit ( *e ) )  lis[ nol ].y2 = ( lis[ nol ].y2 * 10 )
                                          + ( *( e++ ) - '0' );

  for ( ; ; )
  {
    const int ret = nanikaka ( );

    if ( !ret ) break ;
    ++res;
  }
  lis[ nol ].level = res;

  while ( *( e++ ) != '>' ) ;

  return ( res + 1 );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    char s[ 1024 ];
    int n;

    scanf ( " %d", &n );
    if ( !( n ) ) break ;

    scanf ( " %s", s );
    e = s;
    len = 0;
    nanikaka ( );

    while ( n-- )
    {
      int x, y;

      scanf ( " %d %d", &x, &y );

      for ( i = len - 1; i >= 0; --i )
      {
        if ( x >= lis[ i ].x1
          && x <= lis[ i ].x2
          && y >= lis[ i ].y1
          && y <= lis[ i ].y2 )
        {
          printf ( "%s %d\n", lis[ i ].name, lis[ i ].level );
          break ;
        }
      }

      if ( i < 0 )
      {
        puts ( "OUT OF MAIN PANEL 1" );
      }
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
n, k = map(int, input().split())
mod = 10**9+7

def cmb1(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5+50
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = [0]*k
for i in range(1, k+1):
    ans[i-1] = cmb1(n-k+1, i, mod)*cmb1(k-1, i-1, mod)
    ans[i-1] %= mod
for i in range(k):
    print(ans[i])


Measured memory_bytes: 58096
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            int C = int.Parse(input[2]);

            if (C >= A)
            {
                if (B >= C)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }

            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>
using namespace std;


int n, m;
string s;
pair<char, char> a[200005];


bool f_l(int mid) {
    for (int i = 1; i <= m; ++i) {
        if (a[i].first == s[mid]) {
            if (a[i].second == 'L') --mid;
            else ++mid;
        }
        if (mid == 0) return true;
        if (mid > n) return false;
    }
    return false;
}

bool f_r(int mid) {
    for (int i = 1; i <= m; ++i) {
        if (a[i].first == s[mid]) {
            if (a[i].second == 'L') --mid;
            else ++mid;
        }
        if (mid > n) return true;
        if (mid == 0) return false;
    }
    return false;
}

int main(int argc, const char * argv[]) {
 //   freopen("/Users/danya.smelskiy/Documents/Danya/Resources/input.txt","r",stdin);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    cin >> s;
    s = "#" + s;
    for (int i = 1; i <= m; ++i) {
        cin >> a[i].first >> a[i].second;
    }
    int l = 1;
    int r = n;
    while (l < r) {
        int mid = (l + r + 1) >> 1;
        if (f_l(mid)) l = mid;
        else r = mid - 1;
    }
    int ll = 0, rr = 0;
    if (f_l(l)) ll = l; else ll = 0;
    l = 1;
    r = n;
    while (l < r) {
        int mid = (l + r) >> 1;
        if (f_r(mid)) r = mid;
        else l = mid + 1;
    }
    if (f_r(l)) rr = n - l + 1;
    else rr = 0;
    cout << n - min(ll + rr, n) << '\n';
}



Measured memory_bytes: 976
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

	ll N, M;
	cin >> N >> M;
	if(N > M) swap(N, M);

	if(N == 1 && M == 1) {
		cout << 1 << endl;
	} else if(N == 1 && M != 1) {
		cout << M - 2 << endl;
	} else {
		ll res = (N - 2) * (M - 2);
		cout << res << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
const int MAX_N = 100000;
const int INF = 1e9;



int n;
int a[MAX_N+10];


signed main(){
  cin>>n;
  for(int i=1;i<=n;i++)cin>>a[i];

  int ans=0;
  for(int i=1;i<=n;i++){
    ans+=a[i]/2;
    a[i]%=2;
    if(a[i]==1 && a[i+1]!=0 && i!=n){
      a[i+1]--;
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};

int dp[100000]={0},tonum[100000]={0};
vector<int> from[100000];

int main(){
  int N,M;
  cin>>N>>M;
  int x,y;
  for(int i=0;i<M;i++){
    cin>>x>>y;
    from[x-1].push_back(y-1);
    tonum[y-1]++;

  }

  queue<int> q;
  for(int i=0;i<N;i++){
    if(tonum[i]==0) q.push(i);
  }
  int ans=0;
  while(!q.empty()){
    int pos=q.front();
    q.pop();
    for(int i=0;i<from[pos].size();i++){
      int to=from[pos][i];
      tonum[to]--;
      if(tonum[to]==0){
        dp[to]=dp[pos]+1;
        ans=max(ans,dp[to]);
        q.push(to);
      }
    }
  }

  cout<<ans<<endl;

  return 0;
}

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)

const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool check_prime(int n)
{
    if(n<2)
        return false;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            return false;
    }
    return true;
}

int setbits(int n)
{
    int count=0;
    while(n)
    {
        if(n%2==1)
            count++;
        n>>=1;
    }
    return count;
}

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

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    string s;
    cin>>s;
    cout<<s.substr(0,3);


    return 0;
}


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

using namespace std;

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

    for(int i=0;i<s.size()-1;i++)
    {
        if(s[i] == s[i+1])
        {
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
    }

    for(int i=0;i<s.size()-2;i++)
    {
        if(s[i] == s[i+2])
        {
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }

    cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512