akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    int n = nextInt();

    String[] s = new String[n];
    for(int i=0;i<n;i++){
      s[i] = next();
    }

    Arrays.sort(s);

    int[] cnt = new int[n];
    int m = 0;

    for(int i=0;i<n;i++){
      if(i==0){
        cnt[m]++;
      }
      else{
        if(s[i-1].equals(s[i])){
          cnt[m]++;
        }
        else{
          m++;
          cnt[m]++;
        }
      }
    }
/*
    for(int i=0;i<n;i++){
      System.out.println("s["+i+"]="+s[i]);
    }
    for(int i=0;i<=m;i++){
      System.out.println("cnt["+i+"]="+cnt[i]);
    }
*/

    int max = max(cnt);
    for(int i=0;i<n;i++){
      if(i==0){
        m=0;
      }
      else if(!(s[i-1].equals(s[i]))){
        m++;
      }
      if(cnt[m]==max){
        System.out.println(s[i]);
        i += (max-1);
      }
    }






    //System.out.println();

  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

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

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] H = new int[N+1];
        for(int i = 1; i < N+1; i++){
            H[i] = sc.nextInt();
        }
        sc.close();
        int[] dp = new int[N+1];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[1] = 0;
        for(int i = 2; i <= N; i++){
            for(int j = i-1; j >= Math.max(1, i-K); j--){
                dp[i] = Math.min(dp[j] + Math.abs(H[i] - H[j]), dp[i]);
            }
        }
        System.out.println(dp[N]);

    }

}


Measured memory_bytes: 49720
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<cstdio>
#include<string>
#include<vector>
#include<math.h>
#include<time.h>
#include<utility>
#include<cstdlib>
#include<sstream>
#include<cstring>
#include<stdio.h>
#include<iomanip>
#include<iostream>
#include<algorithm>
//#include<conio.h>
using namespace std;
int n,a[100032],mp[100032],mn=1000000,mx;
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;mp[x]++;
		if(x<mn) mn=x;
		if(x>mx) mx=x;
	}
	int ans=0;
	for(int i=mn;i<mx+1;i++){
		ans=max(ans,mp[i]+mp[i+1]+mp[i+2]);
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 640
program main
 implicit none
 integer n,i,flag
 read(*,*) n
 flag = 0
 do i=1,9
  if(mod(n,i) == 0 .and. (n/i) < 10) then
   write(*,*) 'Yes'
   flag = 1
   exit
  end if
 end do
 
 if(flag == 0) then
  write(*,*) 'No'
 end if
end program main
 

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n,i,t,x;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		t=0;
		x=i;
		while(x!=0){
			if(x%10==3){
				t++;
				break;
			}
			x/=10;
		}
		if(!(i%3)||t)printf(" %d",i);
	}
	puts("");
	return 0;
}


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

struct Linear_Sieve{
int n;
vector<int> lp,primes;
//lp[i]...the least prime of i. primes...prime numbers
Linear_Sieve(int n = 1):n(n),lp(n+1){
    for(int i = 2;i < n+1;i++){
        if(lp[i] == 0) {
            primes.push_back(i);
            lp[i] = i;
        }
        for(int j = 0;j<primes.size() && primes[j] <= lp[i] && i*primes[j] < n+1; ++j) lp[i*primes[j]] = primes[j];
    }
}
bool isPrime(int x) {return lp[x] == x;}

vector<int> factorList(int x){
    //make list which contains prime factors of x. Ans it toralates multipled components.
    vector<int> res;
    while(x != 1){
        res.push_back(lp[x]);
        x /= lp[x];
    }
    return res;
}

vector<pair<int,int>> factor(int x){
        //make list of pairs which couple prime factor and multiplicity.
    vector<int> fl = factorList(x);
    if(fl.size() == 0) return{};
    vector<pair<int,int>> res(1,pair<int,int>(fl[0],0));
    for(int p : fl){
        if(res.back().first == p){
            res.back().second++;
        }else{
            res.emplace_back(p,1);
        }
    }
    return res;
}
};

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
    return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int main(){
    int n;
    cin >> n;
    vector<int> num(n+1,1);
    Linear_Sieve s(n);
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    for(int i = 2;i<=n;i++){
        for(auto p:s.factor(i)){
            num[p.first] += p.second;
        }
    }
    mint ans = 1;
    for(int i = 2;i<=n;i++){
        ans *= num[i];
    }
    
    cout << ans << endl;

}


Measured memory_bytes: 3604
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

int n;
void solve(string s,char mx){
    if(s.size()==n){
        cout<<s<<'\n';
        return;
    }
    for(char c='a';c<=mx;c++){
        solve(s+c,(c==mx?mx+1:mx));
    }
}
signed main(){
    FastIO;
    cin>>n;
    solve("",'a');
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <map>
#include <list>
#include <queue>
#include <string.h>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std; 
typedef long long ll; 


int main(){
    
    int n,m; 
    cin>>n>>m; 
    ll a[n]; 
    map<int,int> cnt; 
    for(int i=0;i<n;i++){
        cin>>a[i]; 
        if(i>0)
            a[i]+=a[i-1]; 
        a[i]%=m; 
        cnt[a[i]]++; 
    }
    ll ans=0 ;
    for(pair<int,int> p:cnt){
        ans+=(ll)(p.second)*(p.second-1)/2; 
        if(p.first==0){
            ans+=p.second; 
        }
    }
    cout<<ans; 
}


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

int main() {
  int A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;
  int x = min(min(min(min((A-1) % 10, (B-1) % 10), (C-1) % 10), (D-1) % 10), (E-1) % 10) + 1;
  int ans = ((A + 9) / 10 + (B + 9) / 10 + (C + 9) / 10 + (D + 9) / 10 + (E + 9) / 10) * 10;
  if (x != 0) {
    ans = ans - 10 + x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n, k;
    scanf("%ld%ld", &n, &k);
    k++;

    vector<long> a(n);
    vector<pair<long, long> > z(n);   // a[i],b[i]
    long i;
    for(i=0; i<n; i++) {
        long b;
        scanf("%ld%ld", &a[i], &b);
        z[i] = make_pair(a[i], b);
    }
    sort(a.begin(), a.end());
    sort(z.begin(), z.end());

    ll ans=0;
    for(i=30; i>=0; i--) {
        if(k & (1<<i)) {
            ll add = (1<<i);
            long i1 = lower_bound(a.begin(), a.end(), add) - a.begin();
            ll val = 0;
            long p;
            for(p=0; p<i1; p++) {
                val += z[p].second;
            }
            ans = MAX(ans, val);

            for(p=0; p<n; p++) {
                z[p].first &= ~(1<<i);
            }
            sort(z.begin(), z.end());
            for(p=0; p<n; p++) {
                a[p] = z[p].first;
            }
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 2560
/*
      author : nishi5451
      created: 11.08.2020 20:04:31
*/

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


int main(){
    string a,b,c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << endl;
    return 0;
}

Measured memory_bytes: 3624
import numpy as np
import math 
n,k = map(int,input().split())
ans = 0
for i in range(1,n+1):
    if i >= k:
        ans += 1/n
    else:
        num = math.ceil(np.log2(k/i))
        ans += (1/n)*(1/2)**num
    
print(ans)

Measured memory_bytes: 12488
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
	    int a = scan.nextInt();
	    int b = scan.nextInt();
	    int c = scan.nextInt();
	    int k = scan.nextInt();
	    scan.close();
	    int max=Math.max(a, Math.max(b, c));
	    int ans=max*(int)Math.pow(2,k);
	    System.out.println(ans+a+b+c-max);
	}

}


Measured memory_bytes: 22740
N = gets.chomp.to_i
H = gets.chomp.split(" ").map(&:to_i)

max_cnt = 0
cnt = 0
prev_h = H.first

1.upto(N-1) do |i|
  if prev_h < H[i]
    max_cnt = cnt if cnt > max_cnt
    cnt = 0
  else
    cnt += 1
  end
  prev_h = H[i]
end
max_cnt = cnt if cnt > max_cnt
puts max_cnt


Measured memory_bytes: 10780
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	string a, b;
	cin >> a >> b;
	if (a.size() > b.size()) {
		cout << "GREATER" << endl;
		return 0;
	}
	else if (a.size() < b.size()) {
		cout << "LESS" << endl;
		return 0;
	}
	else {
		for (int i = 0; i < a.size(); i++) {
			if (a[i] > b[i]) {
				cout << "GREATER" << endl;
				return 0;
			}
			else if (a[i] < b[i]) {
				
					cout << "LESS" << endl;
					return 0;
				
			}
		}
	}
	cout << "EQUAL" << endl;
	return 0;

}




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

int main(){
  int k, s;
  cin >> k >> s;
  
  int count = 0;
  int z;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      z = s - x - y;
      if (z <= k && z >= 0) {
        count++;
      }
    }
  }
  cout << count;
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    int n,k; cin >> n >> k;
    int ans = 0;
    while(n) ans++,n/=k;
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

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

#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define md(l, r) l + (r - l) / 2
#define ll long long
#define btw(a, l, r) a.begin() + l, a.begin() + r + 1
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int(x.size()))
#define sqr(x) (x) * (x)
#define endl '\n'

#define getfiles ifstream cin("input.txt"); ofstream cout("output.txt");
#define clr(x, y) memset((x), (y), sizeof (x))
#define ld long double

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<vector<pair<int, int> > > vvpii;
typedef vector<vector<pair<ll, ll> > > vvpll;
typedef pair<int, pair<int, int> > piii;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef vector<vector<ll> > vvll;
typedef vector<pair<ll, pair<ll, ll> > > vplll;
typedef pair<ll, ll> pll;

const ld eps = -1e9;
const long long N = 200001, P = 1e9 + 7, P1 = 1e9 + 13, iINF = 1e9, INF = 2e18, K = 73, K1 = 79;

ll dstF(ll x, ll y, ll xx, ll yy) {
    return (sqr(x - xx) + sqr(y - yy));
}

ld dstSqrtF(ll x, ll y, ll xx, ll yy) {
    return (sqrt(sqr(x - xx) + sqr(y - yy)));
}

ll _bp(ll val, ll st, ll p) {
    if (st == 0) {
        return 1;
    }
    ll temp = _bp(val, st / 2, p);
    temp = sqr(temp);
    temp %= p;
    if (st % 2 == 1) {
        temp *= val;
        temp %= p;
    }
    return temp;
}

ll _bp(ll val, ll st) {
    if (st == 0) {
        return 1;
    }
    ll temp = _bp(val, st / 2);
    temp = sqr(temp);
    if (st % 2 == 1) {
        temp *= val;
    }
    return temp;
}

ll nok(ll a, ll b) {
    return (a / __gcd(a, b) * b);
}

/*
ll fact[N];

void buildFacts(ll n, ll p) {
    fact[0] = 1;
    for (ll i = 1; i <= n; i++) {
        fact[i] = (fact[i - 1] * i) % p;
    }
}

ll C(ll n, ll k, ll p = -1) {
    if (p == -1) {
        ll x = fact[n];
        ll y = (fact[k] * fact[n - k]);
        return (x / y);
    } else {
        ll x = fact[n];
        ll y = (fact[k] * fact[n - k]) % p;
        x = (x * _bp(y, p - 2, p)) % p;
        return x;
    }
}
*/

void solve() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(max(b * d, a * c), max(a * d, b * c)) << endl;
}

signed main() {
    //freopen("checklist.in", "r", stdin);
    //freopen("checklist.out", "w", stdout);
    //fast_io;
    int q;
    q = 1;
    //cin >> q;
    while (q != 0) {
        solve();
        --q;
    }
}

/*
*/


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;

int main(){
  int n,h;
  cin >> n >> h;
  vector<int> a(n),b(n);
  rep(i,n) cin >> a[i] >> b[i];
  int m = *max_element(a.begin(),a.end());
  queue<int> q;
  sort(b);
  reverse(b);
  rep(i,n) if(b[i]>m) q.push(b[i]);
  int ans = 0;
  while(!q.empty()){
    h -= q.front();
    ans ++;
    q.pop();
    if(h<=0){
      cout << ans << endl;
      return 0;
    }
  }
  while(h>0){
    h -= m;
    ans ++;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int r, c;
  cin >> r >> c;
  vector<vector<int>> v(r + 1, vector<int>(c + 1, 0));
  for(int i = 0; i < r; i++) {
    for(int j = 0; j < c; j++) {
      cin >> v[i][j];
      v[i][c] += v[i][j];
      v[r][j] += v[i][j];
      v[r][c] += v[i][j];
    }
  }
  
  for(int i = 0; i < r + 1; i++) {
    for(int j = 0; j < c + 1; j++) {
      if(j == c) cout << v[i][c];
      else printf("%d ", v[i][j]);
    }
    cout << "\n";
  }
}


Measured memory_bytes: 3252
#include <iostream>

int main(){
  int N;
  long sum=0;
  std::cin>>N;
  long a[N+1];
  
  for(int i=1;i<=N;i++)
    std::cin>>a[i];
  
  for(int i=1;i<=N;i++)
    while(a[i]%2==0){
      a[i]=a[i]/2;
      sum+=1;
    }
    
  std::cout<<sum<<std::endl;
  
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    vvi c(3, vi(3));
    rep(i, 3) rep(j, 3) cin >> c[i][j];
    bool ans = true;
    rep(i, 2) {
        int x = c[i+1][0] - c[i][0];
        bool flag = true;
        for (int j = 1; j <= 2; ++j) {
            if (c[i+1][j] - c[i][j] != x) flag = false;
        }
        if (!flag) ans = false;
    }
    cout << (ans ? "Yes" : "No") << endl;
}

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int M, N;

int main(){
  while(scanf("%d", &M) && M){
    double f = 0, s = 0;
    int r = 360;
    rep(i, M-1){
      int v;
      scanf("%d", &v);
      f += sin(v / 180.0 * M_PI);
      r -= v;
    }
    f += sin(r / 180.0 * M_PI);

    scanf("%d", &N);
    r = 360;
    rep(i, N-1){
      int v;
      scanf("%d", &v);
      s += sin(v / 180.0 * M_PI);
      r -= v;
    }
    s += sin(r / 180.0 * M_PI);

    if(abs(f-s) < EPS) puts("0");
    else if(f > s) puts("1");
    else puts("2");
  }
  return 0;
}

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

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

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int a;
	for (int i = 0; i < 18; i++) {
		cin >> a;
	}
	cout << 0 << " " << 0 << " " << 1 << endl;
	cout << 0 << " " << 0 << " " << 59 << endl;
	cout << 15 << " " << 59 << " " << 59 << endl;
}

Measured memory_bytes: 3084
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

bool is_prime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return n!=1;
}

vector<int> G[5];

void solve(int n){
    for(int i=2;i<=55555;i++){
        if(is_prime(i)){
            if(i%5==1) G[1].push_back(i);
            if(i%5==2) G[2].push_back(i);
            if(i%5==3) G[3].push_back(i);
            if(i%5==4) G[4].push_back(i);
        }
    }
    int u,v=0;
    for(int i=1;i<5;i++){
        if(G[i].size()>v){
            u=i;
            v=G[i].size();
        }
    }
    for(int i=0;i<n;i++) cout<<G[u][i]<<' ';
    cout<<endl;
}

signed main(){
    int n;
    cin>>n;
    solve(n);
}

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}

int main()
{
	fast;
	int n, k, ans = 0;
	cin >> n >> k;
	while (n /= k)
		ans++;
	cout << ans + 1;
}

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

int n;
double x[100],y[100];

double distance(double p){
  double sum=0;
  for(int i=0;i<n;i++){
    double w=abs(x[i]-y[i]);
    sum += pow(w,p);
  }
  return pow(sum,1.0/p);
}

int main(){
  cout<<fixed<<setprecision(12);

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  for(int i=0;i<n;i++){
    cin>>y[i];
  }
  
  cout<< distance(1) <<endl;
  cout<< distance(2) <<endl;
  cout<< distance(3) <<endl;

  double mx=0;
  for(int i=0;i<n;i++){
    mx=max(mx, abs(x[i]-y[i]) );
  }
  cout<< mx <<endl;
  
  return 0;
}



Measured memory_bytes: 3436
#ifndef LOCAL
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#else
#include <iostream>
#include <iomanip> 
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; } eni(!=) cerr << boolalpha << i; ris; } eni(==) ris << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
#define fix(a) fixed << setprecision(a)
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'

const ll inf = 1e18;
void solve(){
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  if (abs(a-b) > inf){
    cout << "Unfair";
  } else {
    ll ans = (a-b);
    if (k%2) ans *= -1ll;
    cout << ans;
  }
  
}

int main() {
  ios::sync_with_stdio(false);
  // cin.tie(0); cout.tie(0);
  int t = 1;
  // cin >> t;
  forn(i, t){
    solve();
  }
}

/* 


*/

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  set<string> s;
  for(int i=0;i<n;i++)
  {
    string t;cin>>t;
    s.insert(t);
  }
  cout<<s.size()<<endl;
  return 0;
}

Measured memory_bytes: 19184
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<map>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXP = 31;

int main()
{
    string s;
    int n, w, l, e;
    bool sec = false;
    while(cin >> n && n)
    {
        if(sec) cout << endl;
        vector<string> teams[MAXP];
        
        REP(n)
        {
            cin >> s >> w >> l >> e;
            teams[w * 3 + e].push_back(s);
        }
        
        for(int i = MAXP-1;i!= -1; i--)rep(j,teams[i].size())
            cout << teams[i][j] << "," << i << endl;
        
        sec = true;

    }

    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<cctype>

using namespace std;

int main(){

	int n,k;
	int num=0;
	cin>>n>>k;
	
	if(n%k!=0)num+=1;
	
	if((n/k+num)>=(n/k)){
		cout<<(n/k+num)-(n/k)<<endl;
	}else cout<<(n/k)-(n/k+num)<<endl;


}

Measured memory_bytes: 256
//ABC145-D
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

using ll = long long;
template <ll MOD = 1e9 + 7>
struct Mint{
    ll x;

    Mint() : x(0) {}
    Mint(ll t){
        x = t % MOD;
        if(x < 0) x += MOD;
    }
    
    Mint pow(ll n){
        Mint res(1), t(x);
        while(n > 0){
            if(n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        ll a = x, b = MOD, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint & operator += (Mint a){
        x += a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    Mint & operator -= (Mint a){
        x += MOD - a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    Mint & operator *= (Mint a){
        x = 1LL * x * a.x % MOD;
        return *this;
    }
    Mint & operator /= (Mint a){
        return (*this) *= a.inv();
    }

    Mint operator + (Mint a) const { return Mint(x) += a; }
    Mint operator - (Mint a) const { return Mint(x) -= a; }
    Mint operator * (Mint a) const { return Mint(x) *= a; }
    Mint operator / (Mint a) const { return Mint(x) /= a; }

    Mint operator - () const{ return Mint(-x); }

    bool operator == (const Mint a){ return x == a.x; }
    bool operator != (const Mint a){ return x != a.x; }
    bool operator < (const Mint a){ return x < a.x; }

    friend ostream & operator << (ostream & os, const Mint &a){
        return os << a.x;
    }

    friend istream & operator >> (istream & is, Mint &a){
        ll t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

template <typename T>
struct Comb{
    vector<T> fac, fin;

    Comb(int sz) : fac(sz + 1), fin(sz + 1){
        fac[0] = fin[sz] = T(1);
        for(int i = 1; i <= sz; i++){
            fac[i] = fac[i - 1] * T(i);
        }
        fin[sz] /= fac[sz];
        for(int i = sz - 1; i >= 0; i--){
            fin[i] = fin[i + 1] * T(i + 1);
        }
    }

    inline T fact(int k) const { return fac[k]; }
    inline T finv(int k) const { return fin[k]; }

    T P(int n, int k) const {
        if(k < 0 || n < k) return T(0);
        return fac[n] * fin[n - k];
    }

    T C(int n, int k) const {
        if(k < 0 || n < k) return T(0);
        return fac[n] * fin[n - k] * fin[k];
    }

    T H(int n, int k) const {
        if(n < 0 || k < 0) return T(0);
        return k == 0 ? T(1) : C(n + k - 1, k);
    }
};

signed main(){
    ll x,y;
    cin >> x >> y;
    ll sum = x + y;
    if(sum % 3 == 0 && sum / 3 <= x && x <= sum / 3 * 2 && sum / 3 <= y && y <= sum / 3 * 2){
        ll mn = min(x, y);
        Comb<Mint<MOD>> C(1e6);
        cout << C.C(sum / 3, mn - sum / 3) << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 15872
#include <stdio.h>

int main(){
int a[100001];
int n;
int sum=0;
int x;
scanf("%d",&n);
for(int i=1;i<=n;i++){
    scanf("%d",&a[i]);
}
for(int i=1;i<=n;i++){
        x=0;
    while(a[i]%2==0){
        x++;
        a[i]=a[i]/2;
    }
    sum=sum+x;
}
printf("%d",sum);
return 0;
}

Measured memory_bytes: 256
using System;

namespace ITP_7_A{
    public class Program{
        public static void Main(string[] args){
            while(true){
                string[] temp = Console.ReadLine().Split(' ');
                int first = int.Parse(temp[0]);
                int second = int.Parse(temp[1]);
                int re = int.Parse(temp[2]);
                int testResult = first + second;

                if(first==-1 && second==-1 && re==-1) return;

                //F?????????????????????
                if(first==-1 || second==-1) Console.WriteLine("F");
                //A??????????????????
                else if(testResult>=80) Console.WriteLine("A");
                //B??????????????????
                else if(testResult>=65) Console.WriteLine("B");
                //C??????????????????
                else if(testResult>=50) Console.WriteLine("C");
                //F?????????????????????
                else if(testResult<30) Console.WriteLine("F");
                //C??????????????????
                else if(re>=50) Console.WriteLine("C");
                //?????????D??????
                else Console.WriteLine("D");
            }
        }
    }
}

Measured memory_bytes: 8812
#include<iostream>
#include<cstdio>
#include<cctype>
#include<string>
using namespace std;

string toUpper(string s);

int main(){
    string target, source;
    cin >> target;
    target = toUpper(target);
    
    int cnt=0;
    
    while(1){
        cin >> source;
        if(source=="END_OF_TEXT") break;
        source = toUpper(source);
        if(target==source) cnt++;
    }
    
    cout << cnt << endl;
    
    return 0;
}

string toUpper(string s){
    string t = s;
    for(int i=0; i < s.size(); i++){
        t[i] = toupper(s[i]);
    }
    return t;
}

Measured memory_bytes: 3152
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 黒のコマを表す文字 */
	private static final char BLACK = '#';

	/** 上下左右の座標を表す配列 */
	private static final int[] X = { 0, 1, 0, -1 };
	private static final int[] Y = { 1, 0, -1, 0 };

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int h = scanner.nextInt(), w = scanner.nextInt();
			boolean[][] s = new boolean[h][w];
			IntStream.range(0, h).forEach(i -> {
				char[] t = scanner.next().toCharArray();
				IntStream.range(0, w).forEach(j -> s[i][j] = (t[j] == BLACK));
			});
			for (int i = 0; i < h; i++) {
				KOMA: for (int j = 0; j < w; j++) {
					if (s[i][j]) {
						for (int k = 0; k < X.length; k++) {
							int newX = i + X[k], newY = j + Y[k];
							if ((newX >= 0) && (newX < h) && (newY >= 0) && (newY < w)) {
								if (s[newX][newY]) {
									continue KOMA;
								}
							}
						}
						System.out.println("No");
						return;
					}
				}
			}
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 36192
N = gets.to_i
A = gets.split.map(&:to_i)

B = A.map{|a| [a/400, 8].min }.uniq

s = B.size

r = A.count{|a| [a/400, 8].min == 8 }

if s == 1
  if B[0] == 8
    puts "1 #{r}"
  else
    puts "1 1"
  end
else
  if B.max == 8
    puts "#{s-1} #{s-1+r}"
    # puts 3
  else 
    puts "#{s} #{s}"
    # puts 4
  end
end

Measured memory_bytes: 1788
while True:
	INPUT = [int(i) for i in input().split()]
	a = INPUT[0]
	b = INPUT[1]
	
	if a == 0 and b == 0:
		break
		
	else:
		for i in range(a):
			if i == 0 or i == a-1:
				print('#' * b)
			else:
				print('#' + '.'*(b-2) + '#')
				
		print()


Measured memory_bytes: 5616
is_alive = [0]*8#各ランク

N = int(input())
a = list(map(int,input().split()))

count_over=0

for i in range(0,N,1):
    if a[i]>=3200:
        count_over +=1
    else:
        is_alive[a[i]//400]=1

print(max(1,sum(is_alive)),sum(is_alive)+count_over)

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

using namespace std;

const int MAXN = 1e5 + 10, INF = 1e9;

int N, M, A[MAXN];
long long TGT;

template <typename T, int L, int R>
struct Arr {
    T arr[R - L + 1];
    inline T & operator [](int kth) { return arr[kth - L]; }
};

bool check(int m) {
    int ps = 0, cur = 0;
    long long cnt = 0;
    static Arr<int, -MAXN, MAXN> slot;
    for(int i = -N; i <= N; i++) slot[i] = 0;
    slot[0] = 1;
    for(int i = 1; i <= N; i++) {
        cur++;
        if(A[i] >= m) cur += slot[++ps];
        else cur -= slot[ps--];
        cnt += cur; slot[ps]++;
    }
    return cnt >= TGT;
}

int main() {
    scanf("%d", &N); TGT = (1LL * N * (N + 1) / 2 + 1) / 2;
    for(int i = 1; i <= N; i++) scanf("%d", &A[i]);
    int l = 1, r = INF;
    while(l != r) {
        int m = (l + r) / 2 + 1;
        if(check(m)) l = m;
        else r = m - 1;
    }
    printf("%d\n", l);
}


Measured memory_bytes: 1408
import numpy as np

if __name__ == '__main__':
    N, M, C = map(int, input().split())
    B = np.array(list(map(int, input().split())))
    A = np.array(list(map(lambda _: list(map(int, input().split())), range(N))))

    scores = A.dot(B)
    print(np.sum(scores > -C))


Measured memory_bytes: 12504
import math

A,B,H,M = map(int,input().split())

pi = math.pi

Hpi = (pi/6)*H + (pi/6)*(M/60)
Mpi = (2*pi)*(M/60)

Rpi = Hpi - Mpi

result = math.sqrt( A**2 + B**2 -2*A*B*math.cos(Rpi) )

print(result)

Measured memory_bytes: 9444
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;

int main() {
  int K;
  cin >> K;
  cout << (K / 2) * (K - K / 2) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
#define MAX 100100
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
vector<int> E[MAX],ans1,ans2;
bool vis[MAX];
int n,m,S,T;
void dfs(int u,vector<int> &A)
{
	vis[u]=true;A.push_back(u);
	for(int v:E[u])if(!vis[v]){dfs(v,A);break;}
}
int main()
{
	n=read(),m=read();
	for(int i=1;i<=m;++i)
	{
		S=read(),T=read();
		E[S].push_back(T);
		E[T].push_back(S);
	}
	vis[S]=vis[T]=true;
	dfs(S,ans1);dfs(T,ans2);
	printf("%d\n",ans1.size()+ans2.size());
	while(!ans1.empty())printf("%d ",ans1.back()),ans1.pop_back();
	for(int x:ans2)printf("%d ",x);puts("");
	return 0;
}


Measured memory_bytes: 9336
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, x, ans = 0; cin >> n >> x;
	vi v(n + 1);
	rep(i, n){
		cin >> v[i + 1];
		v[i + 1] += v[i];
	}
	for(int i : v) if(i <= x) ans++;
	cout << ans << endl;
	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<vector<int>>f(n,vector<int>(10)),p(n,vector<int>(11));
	for(auto&&i:f)for(auto&&j:i)cin>>j; for(auto&&i:p)for(auto&&j:i)cin>>j;
	int ans=INT_MIN;
	for(int i=1;i<(1<<10);++i){
		vector<int>c(n,0);
		for(int j=0;j<10;++j){
			if(i&(1<<j)){
				for(int k=0;k<n;++k){
					c.at(k)+=f.at(k).at(j);
				}
			}
		}
		int tans=0;
		for(int j=0;j<n;++j){
			tans+=p.at(j).at(c.at(j));
		}
		ans=max(ans,tans);
	}
	cout<<ans<<"\n"s;
}


Measured memory_bytes: 3632
N,M=map(int,input().split())
MOD=10**9+7
arr=[1]
for i in range(1,N+M+1):
    arr.append((arr[-1]*i)%MOD)
s=arr[N]*arr[M]
if N==M:
    print(2*s%MOD)
elif abs(N-M)==1:
    print(s%MOD)
else:
    print(0)

Measured memory_bytes: 11028
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[0] << c[0] << endl;
    return 0;
}


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl

typedef pair<int, int> P;
typedef long long ll;
int ans(int n,int m,vector<int> x){
    sort(all(x));
    vector<int> sa(m-1);
    int ans = 0;
    if(n>=m) return ans;
    REP(i,m-1){
        sa[i] = x[i+1] - x[i];
        ans += sa[i];
    }
    sort(all(sa), greater<int>()); 
    REP(i,n-1){
        ans-=sa[i];
    }
    return ans;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin>>n>>m;
    vector<int> x(m);
    REP(i,m) cin>>x[i];
    print(ans(n,m,x));
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000007
ll fact[50];
#define eps 1e-9
ll power(ll a,ll b,ll c){
  ll ans=1;
  while(b){
    if(b&1){
      ans=ans*a%c;
    }
    a=a*a%c;
    b=b/2;
  }
  return ans;
}
ll ncr(ll n,ll r){
    if(r>n)return 0;
    if(r==n)return 1;
    ll z=fact[n];
    z=z*power(fact[r],mod-2,mod)%mod;
    z=z*power(fact[n-r],mod-2,mod)%mod;
    return z;
}
ll min(ll a,ll b){return a<b?a:b;}
int main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        ll n,k; cin>>n>>k;
        if(n<=k){
            cout<<min(n,k-n);
        }
        else{
            ll bb=n-(n/k)*k;
            cout<<min(bb,k-bb);
        }
        return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
   	 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
   	 static int a_dist[];
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        long N = sc.nextLong();
	        if(N==2) {
	        	System.out.println(1);
	        	return;
	        }
	        long H = (long)Math.pow(N,0.5);
	        long[] d = new long[(int)H+5];
	        int k=0;
	        for(long i=2;i<=H;i++) {
	        	if(N%i==0) {
	        		d[k]=i;
	        		k++;
	        		if(i*i!=N) {
		        		d[k]=N/i;
		        		k++;
	        		}
	        	}
	        }
		    d[k]=N;	        	
	        long ans=0;
	        H = (long)Math.pow(N-1,0.5);
	        for(long i=2;i<=H;i++) {
	        	if((N-1)%i==0) {
	        		ans++;
	        		if(i*i!=(N-1)) {
	        			ans++;
	        		}
	        	}
	        }
	        ans++;
	        for(int i=0;d[i]!=0;i++) {
	        	long tmp=N;
	        	while(tmp>0) {
	        		if(tmp%d[i]==0) {
	        			tmp=tmp/d[i];
	        			if(tmp==1) {
	        				ans++;
	        				break;
	        			}
	        		} else {
	        			if((tmp-1)%d[i]==0) {
	        				ans++;
	        				break;
	        			} else {
	        				break;
	        			}
	        		}
	        	}
	        }
	        
	    	System.out.println(ans);
	        
	        	        	        
	 }
}

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

int main()
{
  int n;
  int ans = 0;
  vector<int> a;

  cin >> n;
  for (int k = 0; k < n; k++) {
    int t;
    cin >> t;
    a.push_back(t);
  }


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  int c;
  int d;
  int e;
  cin >> a >> b >> c;
  d = a * b;
  if(d != c){
    if(d < c){
      cout << d << endl;
    }
    else{
      cout << c << endl;
    }
  }
  else if(d == c){
    cout << d << endl;
  }
  //cout << d << endl;
  //cout << c << endl;
}


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

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

int main(){

    ll Q;
    cin >> Q;

    vector<P> q(Q+5);
    rep(i,Q){
        cin >> q[i].first >> q[i].second;
    }

    ll max = 100005;
    vector<ll> is_prime(max,1);
    is_prime[0] = 0; is_prime[1] = 0;
    for(ll i = 2; i < max; i++){
        if(is_prime[i]==0){
            continue;
        }
        for(ll j = 2; j*i < max; j++){
            is_prime[j*i] = 0;
        }
    }


    // 累積和を作っておく
    vector<ll> L(max+5,0);
    L[0] = 0;
    ll tmp;
    rep(i,max){
        if((i+1)%2==1&&is_prime[i+1]&&is_prime[(i+2)/2]){
            L[i+1] = L[i]+1;
        }else{
            L[i+1] = L[i];
        }
    }

    rep(i,Q){
        cout << L[q[i].second] - L[q[i].first-1] << endl;
    }

    return 0;
}

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

char c[4004];
int a[4004], p[2][2002], b[4004][2002] = { 0 }, w[4004][2002] = { 0 }, dp[2002][2002];

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < 2*N; ++i) {
		cin >> c[i] >> a[i];
		p[c[i] == 'B'][a[i]] = i;
	}
	for (int i = 0; i < 2*N; ++i) {
		memcpy(b[i + 1], b[i], sizeof(b[i]));
		memcpy(w[i + 1], w[i], sizeof(w[i]));
		for (int j = 0; j <= a[i]; ++j) c[i] == 'B' ? ++b[i + 1][j] : ++w[i + 1][j];
	}
	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= N; ++j) dp[i][j] = 1e9;
	}
	dp[0][0] = 0;
	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= N; ++j) {
			if (i < N) dp[i + 1][j] = min(dp[i][j] + b[p[1][i + 1]][i + 1] + w[p[1][i + 1]][j + 1], dp[i + 1][j]);
			if (j < N) dp[i][j + 1] = min(dp[i][j] + b[p[0][j + 1]][i + 1] + w[p[0][j + 1]][j + 1], dp[i][j + 1]);
		}
	}
	cout << dp[N][N] << '\n';
}

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

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

vector<int> num(3);

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

    REP(i, 3) {
        cin >> num[i];
    }

    sort(num.begin(), num.end());

    REP(i, 3) {
        if (i != 2) {
            cout << num[i] << ' ';
        } else {
            cout << num[i] << '\n';
        }
    }
    return 0;
}


Measured memory_bytes: 3164
using System;

namespace Fairness {
    class ConsoleInput {
        private string[] currentLine = null;
        private int currentCursor = 0;

        public string Get() {
            if (currentLine == null || currentCursor >= currentLine.Length) {
                currentLine = Console.ReadLine().Split(' ');
                currentCursor = 0;
            }
            var res = currentLine[currentCursor];
            currentCursor++;
            return res;
        }

        public long GetLong() {
            return long.Parse(Get());
        }


    }

    class Program {
        static ConsoleInput input = new ConsoleInput();

        static void Main(string[] args) {
            long A = input.GetLong();
            long B = input.GetLong();
            long C = input.GetLong();
            long K = input.GetLong();

            long answer = K % 2 == 0 ? A - B : B - A;

            if (Math.Abs(answer) > Math.Pow(10, 18)) Console.WriteLine("Unfair");
            else Console.WriteLine(answer);

            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 11220