akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;


ll solve(ll h) {
    if(h == 1) return 1;
    return 1 + 2 * solve(h / 2);
}

int main() {
    ll h; cin >> h;
    cout << solve(h) << endl;    
}

Measured memory_bytes: 256
k = str(input())
n = list(k)
l = []
s = ""
for i in n:
    if(i == '0'):l.append(i)
    if(i == '1'):l.append(i)
    if(i == 'B'):
        if(len(l)==0):
            continue
        else:
            l.pop()
print(s.join(l))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i] >> B[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    if (N % 2 != 0) {
        int mn = A[N / 2];
        int mx = B[N / 2];
        cout << mx - mn + 1 << endl;
    } else {
        int mn2 = A[N / 2 - 1] + A[N / 2];
        int mx2 = B[N / 2 - 1] + B[N / 2];
        cout << mx2 - mn2 + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4456
def s()
  gets().chomp
end
def i()
  gets.to_i
end
def li()
  gets.split.map(&:to_i)
end
def ili()
  n = gets.to_i
  as = gets.split.map(&:to_i)
  [n, as]
end
class Array
  def sum
    total = 0
    self.each do |item|
      total += item
    end
    total
  end
end
def bin_search(s,  x)
  len = s.length
  left = 0 
  right = len-1
  if s[right] <= x
    return right
  elsif s[0] >= x
    return 0
  end

  while left != right-1
    mid = (left+right)/2
    if s[mid] == x
      return  mid
    elsif s[mid] > x 
      right = mid
    else 
      left = mid
    end
  end
  return left
end

def min_len(a, b, x)
  if a > b
    ma = a
    mi = b
  else
    ma = b
    mi = a
  end
  return [x-mi+ma-mi, ma-x+ma-mi].min
end

def solve(a1, a2, b1, b2, x)
  sum = 0
  res = []
  [a1,a2].each{|a|
    sum = 0
    if (x > b1 && b1 > a) ||  (x > b2 && b2 > a)
      sum = (x-a).abs
    else
      sum = [(b1-a).abs, (b2-a).abs].min +  (x-a).abs
    end
    res << sum
  }
  [b1,b2].each{|b|
    sum = 0
    if (x > a1 && a1 > b) ||  (x > a2 && a2 > b)
      sum = (x-b).abs
    else
      sum = [(a1-b).abs, (a2-b).abs].min +  (x-b).abs
    end
    res << sum
  }
  return res.min
end

a, b, q = li()
s = []
t = []
xs = []
a.times{
  s << i()
}
b.times{
  t << i()
}


q.times{
  xs << i()
}

ans = []
xs.each { |x|
  s_i = bin_search(s, x)
  t_i =  bin_search(t, x)
  if s_i == a-1 && t_i == b-1
    ans << solve(s[s_i], s[s_i], t[t_i], t[t_i], x)
  elsif s_i == a-1
    ans  << solve(s[s_i], s[s_i], t[t_i], t[t_i+1], x)
  elsif t_i == b-1
    ans  << solve(s[s_i], s[s_i+1], t[t_i], t[t_i], x)
  else
    ans  << solve(s[s_i], s[s_i+1], t[t_i], t[t_i+1], x)
  end
}
ans.each{|an|
  puts an
}



Measured memory_bytes: 6200
#include <bits/stdc++.h>
using namespace std;
using lli=long long int;
#define rep(i, n) for (int i = 1; i <= (int)(n); i++)
using vi=vector<int>;  using vs=vector<string>; using gi=greater<int>;
#define soao(c) sort((c).begin(),(c).end()) //昇順
#define sodo(c) sort((c).begin(),(c).end(),gi()) //降順
#define rev(c) reverse((c).begin(), (c).end())

int main() {
  lli N,K; cin>>N>>K;
  lli a=N%K;
  cout<<min(a,K-a)<<endl;
}


  


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

dp = [0, abs(h[1]-h[0])]
if n >2:
    for i in range(2,n):
        dp.append(min(abs(h[i]-h[i-2])+dp[-2], abs(h[i]-h[i-1])+dp[-1]))
else:
    print(dp[-1])
    exit()

print(dp[-1])


Measured memory_bytes: 20616
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,ans=0; cin>>n; 
    int  a[n], p = -1, ne = -1 ; 
    for (int i=0;i<n;i++){ 
        cin >> a[i] ; 
        ans += abs(a[i]) ; 
    } 
    sort(a,a+n); 
    if (a[n-1] < 0) { 
        ans += a[n-1]*2; 
        cout << ans << endl ; 
        p = a[n-1]; 
        for (int i=n-2;i>=0;i--){
            cout << p << " " << a[i] << endl;
            p = p - a[i] ; 
        }
    }
    else if (a[0]>0) {
        ans -= a[0]*2; 
        cout << ans << endl ; 
        ne = a[0] ; 
        for (int i=1;i<n-1;i++){
            cout << ne << " " << a[i] << endl;
            ne = ne - a[i];
        }
        cout << a[n-1] << " " << ne << endl;
    }
    else {
        cout << ans << endl ; 
        p = a[0];
        for (int i=1;i<n-1;i++){
            if (a[i]>=0){ 
                cout << p << " " << a[i] << endl; 
                p = p-a[i]; 
            }
        }
        cout << a[n-1] << " " << p << endl;
        p = a[n-1]-p;
        for (int i=1;i<n-1;i++){
            if (a[i]<0){ 
                cout << p << " " << a[i] << endl; 
                p = p-a[i]; 
            }
        }
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 4388
#include <bits/stdc++.h>
#define inf (10000000000)
using namespace std;

const long long charbase = '0';
struct RollingHash {
  long long Mod[2], Base[2];
  long long ssize, maxssize;
  string s;
  vector<long long> pow[2];
  vector<long long> hash[2];
  RollingHash(string inis = "") {
    Mod[0] = 1000000007;
    Mod[1] = 1000000009;
    Base[0] = 1009;
    Base[1] = 1007;
    maxssize = 500005;
    for(int t = 0; t < 2; ++t) {
      pow[t].assign(maxssize, 0);
      pow[t][0] = 1;
      for(int i = 1; i < maxssize; ++i)
        pow[t][i] = pow[t][i - 1] * Base[t] % Mod[t];
    }
    init(inis);
  }
  void init(string inis = "") {
    s = inis;
    ssize = s.size();
    sethash();
  }
  void sethash() {
    ssize = s.size();
    for(int t = 0; t < 2; ++t) {
      hash[t].assign(ssize + 1, 0);
      for(int i = 0; i < ssize; ++i) {
        if(i != 0)
          hash[t][i + 1] = hash[t][i] * Base[t] % Mod[t];
        hash[t][i + 1] += (s[i] - charbase);
        hash[t][i + 1] %= Mod[t];
      }
    }
  }
  // [l,r),0-indexed
  pair<long long, long long> calchash(int l, int r) {
    long long ans[2];
    for(int t = 0; t < 2; ++t) {
      ans[t] = hash[t][r];
      ans[t] -= hash[t][l] * pow[t][r - l] % Mod[t];
      while(ans[t] < 0) ans[t] += Mod[t];
      ans[t] %= Mod[t];
    }
    return make_pair(ans[0], ans[1]);
  }
};

string s, t, ns;
RollingHash rh[2];
bool memo[500005] = {0};
long long used[500005] = {0};
long long tsize, ssize;

long long solve();

int main() {
  cin >> s >> t;
  tsize = t.size();
  ssize = s.size();
  while((long long)ns.size() <
        (long long)2 * (long long)max(t.size(), s.size()))
    ns += s;
  rh[0] = RollingHash(ns);
  rh[1] = RollingHash(t);
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  for(int i = 0; i < ssize; ++i)
    memo[i] = rh[0].calchash(i, i + tsize) ==
              rh[1].calchash(0, tsize);
  for(int i = 0; i < ssize; ++i) used[i] = -1;
  for(int i = 0; i < ssize; ++i)
    if(used[i] == -1) {
      long long cnt = 0, now = i;
      stack<long long> st;
      while(1) {
        st.push(now);
        if(used[now] != -1) break;
        used[now] = -2;
        if(memo[now])
          now = (now + tsize) % ssize;
        else {
          used[now] = 0;
          break;
        }
        if(used[now] == -2) return -1;
      }
      cnt = used[now] - 1;
      while(st.size() > 0) {
        used[st.top()] = ++cnt;
        st.pop();
      }
      ans = max(ans, cnt);
    }
  if(ans == inf) return -1;
  return ans;
}


Measured memory_bytes: 59960
import java.util.*;
/*ダイスゲーム：東西南北に転がした時の上の目は？
*/
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
       Scanner sc = new Scanner(System.in);
/*
        int upper = sc.nextInt();
        int front = sc.nextInt();
        int right = sc.nextInt();
        int left = sc.nextInt();
        int back = sc.nextInt();
        int downSide = sc.nextInt();
*/        
//リストにｃｕｂｅの数字を受取る
/*検証用
        int [] cubeNum = new int [6];     
        for(int i=0; i<6; i++){
            cubeNum[i] = i+1;
        }
*/        
        int [] cubeNum = new int [6];     
        for(int i=0; i<6; i++){
            cubeNum[i] = sc.nextInt();
        }
        
        String direction =sc.next();
        int compassNum = direction.length();
        String[] compass =direction.split("");   
    
        for(int i = 0; i < compassNum; i++){
             if(("S").equals(compass[i])){
                 int forNow = cubeNum[0];//１つ回避
                 cubeNum[0]= cubeNum[4];
                 cubeNum[4]= cubeNum[5];
                 cubeNum[5]= cubeNum[1];
                 cubeNum[1]= forNow;
             }else if(("N").equals(compass[i])){
                 int forNow = cubeNum[0];
                 cubeNum[0]= cubeNum[1];
                 cubeNum[1]= cubeNum[5];
                 cubeNum[5]= cubeNum[4];
                 cubeNum[4]= forNow;
             }else if(("E").equals(compass[i])){
                 int forNow = cubeNum[0];
                 cubeNum[0]= cubeNum[3];
                 cubeNum[3]= cubeNum[5];
                 cubeNum[5]= cubeNum[2];
                 cubeNum[2]= forNow;
             }else if(("W").equals(compass[i])){
                 int forNow = cubeNum[0];
                 cubeNum[0]= cubeNum[2];
                 cubeNum[2]= cubeNum[5];
                 cubeNum[5]= cubeNum[3];
                 cubeNum[3]= forNow;
             }

    } System.out.println(cubeNum[0]);
    /*
System.out.println(cubeNum[1]);
System.out.println(cubeNum[2]);
System.out.println(cubeNum[3]);
System.out.println(cubeNum[4]);
System.out.println(cubeNum[5]);
*/
}
}
/*
        [1]         
     [4][2][3][5]
        [6]          
upper / front  back / downSide
[0][1][2][3][4][5]
[1][2][3][4][5][6]
[u][f][r][l][b][d]
Ｓ：
[0][1][2][3][4][5]
[5][1][3][4][6][2]
　　↑
[b][u][r][l][d][f]
[4][0][2][3][5][1]
Ｎ：
[0][1][2][3][4][5]
[2][6][3][4][1][5]
　　↑
[f][d][r][l][u][b]
[1][5][2][3][0][4]
Ｅ：
[0][1][2][3][4][5]
[4][2][1][6][5][3]
　　↑
[l][f][u][d][b][r]
[3][1][0][5][4][2]
Ｗ：
[0][1][2][3][4][5]
[3][2][6][1][5][4]
　　↑
[r][f][d][u][b][l]
[2][1][5][0][4][3]

*/


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

#define ll long long int
#define vi vector<int>
#define vc vector<char>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define pb push_back
#define el '\n'
#define N 1000000007
#define re return
#define PI 3.14159265
#define take(a,n) for(int i=0;i<(n);i++) cin>>(a)[i]
#define out(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" ";
#define all(a) (a).begin(),(a).end()
#define forup(i,n) for(int (i)=0;i<(n);(i)++)
#define ford(i,n) for(int (i)=(n)-1;i>=0;(i)--)
using namespace std;


ll poww(ll a,ll b)
{
  ll ans=1;
  for(int i=1;i<=b;i++)
  {
    ans*=a;
  }
  return ans;
}


int max(int a,int b,int c)
{
  if(a>=b && a>=c) return a;
  if(b>=a && b>=c) return b;
  return c;
}


int main()
{
  string s;
  int a;
  cin>>a;
  cin>>s;
  if(a<3200)
  cout<<"red";
  else cout<<s;


}


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

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
void warshall_floyd(Matrix< T > &g, T INF) {
  for(int k = 0; k < g.size(); k++) {
    for(int i = 0; i < g.size(); i++) {
      for(int j = 0; j < g.size(); j++) {
	if(g[i][k] == INF || g[k][j] == INF) continue;
	g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
}


int main(){
  int n,m;
  cin >>n >> m;
  int a[m],b[m],c[m];
  Matrix< int > mat(n,vector<int>(n, INT_MAX));
  rep(i,m){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;b[i]--;
    mat[a[i]][b[i]]=c[i];
    mat[b[i]][a[i]]=c[i];
  }
  warshall_floyd(mat,INT_MAX);
  int ans=0;
  rep(i,m){
    if(mat[a[i]][b[i]]!=c[i]){
        ans++;
       // cout << a[i] << " " << b[i] << endl;
    } 
  }
  cout << ans << endl;
  
  return 0;

}


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

int n;
int x[30], y[30];

double dist(int a, int b){
    return sqrt((x[a]-x[b])*(x[a]-x[b]) + (y[a]-y[b])*(y[a]-y[b]));
}

bool solve(){
    for(int i=0;i<n;i++){
        if(dist(n, 0) + dist(0, i) >= dist(n+1, i)) return false;
    }
    return true;
}

int main(){
    while(1){
        cin >> n;
        if(n == 0) break;
        cin >> x[n] >> y[n] >> x[n+1] >> y[n+1];
        for(int i=0;i<n;i++){
            cin >> x[i] >> y[i];
        }

        if(solve()) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  int a=s.size();
  for(int i=0;i<a;i++)
  {
	  if(s.at(i)!=t.at(i))
	  {
		  cout << "No";
		  break;
	  }
	  if(i==a-1)
	  {
		  cout <<"Yes";
		  break;
	  }
  }
}


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

using namespace std;

long long n,m,k,row[300005],col[300005],x[300005],y[300005];
long long rowmax,colmax;
long long rowmaxsize,colmaxsize;
long long resset;
long long result;
int main(){
	cin >> n >> m >> k;
	for(int i = 0;i < k;i++){
		cin >> x[i] >> y[i];
		row[x[i]]++;
		col[y[i]]++;
	}
	
	for(int i = 1;i <= n;i++)
		rowmax = max(rowmax,row[i]);
	for(int i = 1;i <= m;i++)
		colmax = max(colmax,col[i]);
		
		
	for(int i = 1;i <= n;i++)
		if(row[i] == rowmax)
			rowmaxsize++;

	for(int i = 1;i <= m;i++)
		if(col[i] == colmax)
			colmaxsize++;
			
	for(int i = 0;i < k;i++){
		if(row[x[i]] == rowmax && col[y[i]] == colmax)
			resset++;
	}
	
	if(resset < rowmaxsize*colmaxsize)
		cout << rowmax+colmax << endl;
	else
		cout << rowmax+colmax - 1<< endl;
		
	
	return 0; 
} 

Measured memory_bytes: 13012
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int N = sc.nextInt();
		int aCheck = -1, ans = 0;
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			int a = sc.nextInt();
			if(a == aCheck+1) {
				list.add(aCheck);
			}
			aCheck = a;
		}
		for(int i = 0; i < N; i++) {
			ans += sc.nextInt();
		}
		
		Collections.sort(list);
		
		int[] cc = new int[N-1];
		for(int i = 0; i < N-1; i++) {
			cc[i] = sc.nextInt();
		}
		for(int i = 0; i < list.size();i++) {
			ans += cc[list.get(i)-1];
		}
		
		pw.print(ans);
		pw.close();
	}

	static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

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

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

            return tokenizer.nextToken("\n");
        }

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

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

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

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}

Measured memory_bytes: 21076
#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cstdio>
#include<math.h>
#include<stack>
#include<vector>
#include<map> 
#define maxn 100005
#define INF 1000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll n,k;


int main()
{
	scanf("%lld%lld",&n,&k);
	if(k==1)
	{
		printf("0\n");
	}else{
		n=n%k;
		if(n>k/2)
		{
			printf("%lld",k-n);
		}else{
			printf("%lld",n);
		}
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.append(0)
a.insert(0, 0)
inter = []

for i in range(n+1):
    inter.append(abs(a[i]-a[i+1]))

SUM = sum(inter)

for j in range(n):
    diff = inter[j]+inter[j+1]-abs(a[j]-a[j+2])
    ans = SUM-diff
    print(ans)


Measured memory_bytes: 13920
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    long long S;
    cin >> S;
    
    long long X1, X2, X3, Y1, Y2, Y3;
    X1 = 0;
    Y1 = 0;
    X2 = 1e9;
    Y3 = (S - 1) / X2 + 1;
    X3 = 1;
    Y2 = X2 * Y3 - S;
    printf("%lld %lld %lld %lld %lld %lld\n", X1, Y1, X2, Y2, X3, Y3);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
template<typename T>
void debug(vector<vector<T>> m){ REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;} }



signed main(){

    int N; cin >> N;
    vec a(N); readv(a);
    int M = -1, m = N;
    vec cnt(N, 0);
    REP(i, N){
        Max(M, a[i]);
        Min(m, a[i]);
        cnt[a[i]]++;
    }
    bool ans = false;
    if(m == (M + 1) / 2){
        ans = true;
        if(M % 2 == 0){
            if(cnt[m] != 1) ans = false;
            FOR(i, m + 1, M + 1) if(cnt[i] < 2) ans = false;
        }else{
            if(cnt[m] != 2) ans = false;
            FOR(i, m + 1, M + 1) if(cnt[i] < 2) ans = false;
        }
    }
    Ans(ans, "Possible", "Impossible");
    
    return 0;
}

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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int f(int y, int x){
  return 2 * y + y * (y + 1) / 2 + x;
}
int table[18000000];

int main(){
  int N, M;
  while(cin >> N >> M && N){
    REP(i, M){
      int Y, X, L; 
      scanf("%d %d %d", &Y, &X, &L);
      Y--; X--;
      table[f(Y, X)]++;
      table[f(Y, X + 1)]--;
      table[f(Y + L + 1, X)]--;
      table[f(Y + L + 1, X + L + 2)]++;
      table[f(Y + L + 2, X + 1)]++;
      table[f(Y + L + 2, X + L + 2)]--;
    }
    for(int y = 0; y < N + 2; y++){
      for(int x = 1; x <= y + 2; x++){
        table[f(y, x)] += table[f(y, x - 1)];
      }
    }
    for(int y = 1; y < N + 2; y++){
      for(int x = 0; x <= y + 1; x++){
        table[f(y, x)] += table[f(y - 1, x)];
      }
    }
    for(int y = 1; y < N + 2; y++){
      for(int x = 1; x <= y + 2; x++){
        table[f(y, x)] += table[f(y - 1, x - 1)];
      }
    }
    int ans = 0;
    for(int y = 0; y < N; y++){
      for(int x = 0; x <= y; x++){
        if(table[f(y, x)] > 0) ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 50392
#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
using namespace std;

#ifndef MDEBUG
#define NDEBUG
#endif

#define x first
#define y second
#define ll long long
#define d double
#define ld long double
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define pss pair<string,string>
#define psi pair<string,int>
#define pis pair<int,string>
#define psl pair<string,ll>
#define pls pair<ll,string>
#define wh(x) (x).begin(),(x).end()
#define ri(x) int x;cin>>x;
#define rii(x,y) int x,y;cin>>x>>y;
#define rl(x) ll x;cin>>x;
#define rv(v) for(auto&_cinv:v) cin>>_cinv;
#define wv(v) for(auto&_coutv:v) cout << _coutv << ' '; cout << endl;
#define ev(v) for(auto&_cerrv:v) cerr << _cerrv << ' '; cerr << endl;
#define MOD 1000000007

namespace std { 
template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}};
}
// auto fraclt = [](auto&a,auto&b) { return (ll)a.x * b.y < (ll)b.x * a.y; };
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }
template<typename T> void fracn(pair<T,T>&a) {auto g=gcd(a.x,a.y);a.x/=g;a.y/=g;}
template<typename T> struct Index { int operator[](const T&t){auto i=m.find(t);return i!=m.end()?i->y:m[t]=m.size();}int s(){return m.size();} unordered_map<T,int> m; };

#define MAX 100000000000LL
#define MAXSQRT 340000LL

ll convertToBase(ll N, ll b) {
    ll ans = 0;
    while (N > 0 && ans <= MAX) {
        ans += N % b;
        N /= b;
    }
    return ans;
}

int main(int,char**) {
    ios_base::sync_with_stdio(false);

    rl(N); rl(S);
    if (S > N) {
        cout << -1 << endl;
    } else if (S == N) {
        cout << N + 1 << endl;
    } else {
        for (int i = 2; i < MAXSQRT; i++) {
            if (convertToBase(N, i) == S) {
                cout << i << endl;
                return 0;
            }
        }

        ll ans = MAX;

        for (int q = MAXSQRT; q >= 1; q--) {
            ll rem = S - q;
            if (0 <= rem && rem <= N) {
                if ((N-rem)%q == 0) {
                    ll F = (N-rem)/q;
                    if (F>1 && convertToBase(N,F) == S) {
                        ans = min(ans, F);
                    }
                }
            }
        }
        
        if (ans != MAX) cout << ans << endl;
        else cout << -1 << endl;
        
    }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n)     for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n)    for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n)    for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n)   for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v)  for (auto &&V : v)
#define all(x)        (x).begin(), (x).end()
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = 1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;

struct vector_2d {
  double x, y;
  vector_2d(void) : x(0), y(0) {}
  vector_2d(double x_value, double y_value) : x(x_value), y(y_value) {}
  const int  orthant(void) const { return (y >= 0) ? (x >= 0 ? 1 : 2) : (x >= 0 ? 4 : 3); }
  const bool operator<(const vector_2d &v) const {
    int a = orthant(), b = v.orthant();
    if (a != b) return a < b;
    return x * v.y - y * v.x > 0;
  }
};

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  int n;
  cin >> n;
  vector<vector_2d> vec(n);
  rep (i, n) cin >> vec[i].x >> vec[i].y;
  sort(all(vec));
  double maxi = 0;
  rep (i, n) {
    int ni = i;
    vector_2d now;
    rep (j, n) {
      now.x += vec[(ni + j) % n].x;
      now.y += vec[(ni + j) % n].y;
      maxi   = max(maxi, now.x * now.x + now.y * now.y);
    }
  }
  double ans = sqrt(maxi);
  cout << ans << endl;
  return 0;
}

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

int n;

int main() {
    int num = 0;
    double ans;

    cin >> n;
    num = n / 2;

    // cout << num << "\n";
    // cout << n << "\n";
    if (n % 2 == 1) {
        num++;
    }

    ans = (double) num / n;

    printf("%.7f\n", ans);
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<unordered_map>
#include<queue>
#define rep(i,n) for(i=0;i<n;++i)
#define cons 1000000007
typedef long long ll;
int mod = 1000000007;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    (x += a.x) %= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    (x += mod-a.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;
  }
};
using namespace std;
class CompareFirst
{
public:
  bool operator()(pair<int,int> n1,pair<int,int> n2) {
    return n1.first>n2.first; //>:desc <:asc
  }
};


int main(){

  string s;
  long long i,j,n,k;
  long long tmp;
  long long ans;

  vector<string> vs;
  vector<int> vi;
  pair<int,int> pr;

  //unordered_map<string,int> mp;

  //priority_queue<int> pq; // default ‘å‚«‚¢‡
  //priority_queue<pair<int,int>,vector<pair<int,int>>,CompareFirst pq;

  cin >> n >> k;
  long long a[n];
  long long ai[2001]={0};
  long long kk = (long long)(k*(k-1)/2) % cons;
  ans = 0;
  rep(i,n){
    cin >> a[i];
    ++ai[a[i]];
  }
 // rep(i,n)cout << a[i] << endl;
  tmp = 0;
  for(i=1;i<=2000;++i){
    tmp += ai[i-1] % cons;
    tmp = tmp % cons;
    
    ans += (long long)(ai[i]*tmp*kk) % cons;
    ans = ans % cons;
  }
  for(i=0;i<(n-1);++i){
    for(j=(i+1);j<n;j++){
      if(a[i] > a[j]){
        ans += k;
        ans = ans % cons;
      }
    }
  }

  cout << ans  << endl;

  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(998244353)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    int D[n];
    int kazu[n] = {};
    REP(i,n){
        cin >> D[i];
        if(i == 0 and D[0] != 0){
            cout << 0 << endl;
            return 0;
        }
        kazu[D[i]] ++;
    }
    if(kazu[0] != 1){
        cout << 0 << endl;
        return 0;
    }
    int ans = 1;
    FOR(i,1,n){
        REP(j,kazu[i]){
            ans *= kazu[i-1];
            ans %= MOD;
        }
    }
    cout << ans << endl;

}

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

using namespace std;


typedef long long ll;

const int MAX = 1e5+5;
ll memo[105][MAX] , s[105] , v[105];

int n , w;

ll dp( int pos , int sm ) {

    if( pos==n ) {
        return 0;
    }

    ll &ans = memo[pos][sm];


    if( ans!=-1 )
        return ans;
    if( s[pos] + sm <= w ) {
        ans = v[pos] + dp(pos+1, sm+s[pos] );
    }

    return ans = max( ans , dp( pos+1 , sm ) );
}



int main()
{

    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>w;
    memset(memo , -1 , sizeof(memo));

    for( int i = 0 ; i < n ; i++ )
        cin>>s[i]>>v[i];
    cout<<dp(0,0)<<"\n";
}


Measured memory_bytes: 82304
#include <stdio.h>
#include<string.h>

int main(void) {
  int n,count=0;
  scanf("%d",&n);
  int a[n],b[n];
  for(int i=0;i<n;i++)
  {
    scanf("%d %d",&a[i],&b[i]);

  }
  int flag=0;
  for(int i=0;i<n-2;i++)
  {
    if((a[i]==b[i])&&(a[i+1]==b[i+1])&&(a[i+2]==b[i+2]))
    {
      flag=1;
      break;
    }

  }
  if(flag==1)
  printf("Yes\n");
  else
  printf("No\n");
  return 0;
}

Measured memory_bytes: 1660
#include<cstdio>

using namespace std;

int n,s;
int answer=0;

void roop(int T,int N,int S)
{
	if(N==n)//最後の処理ならば
	{
		if(s-S>T&&s-S<10)answer++;
	}
	else//それ以外
	{
		for(int i=T+1;i<10;i++)
		{
			roop(i,N+1,S+i);
		}
	}
}


int main()
{
	while(true)
	{
		scanf("%d%d",&n,&s);
		if(n==0&&s==0)break;
		answer=0;
		roop(-1,1,0);
		printf("%d\n",answer);
	}

	return 0;
}

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

using namespace std;

using int64 = long long;

constexpr int64 P = 1000000007;

// Verified: ABC133E, ABC132D, ABC130E
struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 input_x) : x(input_x) {}
  FiniteField() : x(0) {}
  int64 Value() { return x; }
  inline FiniteField operator+(FiniteField o) {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

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

  int h, w;
  cin >> h >> w;
  vector<string> rows(h);
  for (int i = 0; i < h; i++) {
    cin >> rows[i];
  }

  vector<vector<FiniteField>> dp(h, vector<FiniteField>(w));
  dp[0][0] = 1;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (i + 1 < h && rows[i + 1][j] == '.') {
        dp[i + 1][j] += dp[i][j];
      }
      if (j + 1 < w && rows[i][j + 1] == '.') {
        dp[i][j + 1] += dp[i][j];
      }
    }
  }
  cout << dp[h - 1][w - 1].Value() << endl;
}


Measured memory_bytes: 9216
#047_B
w,h,n=map(int,input().split())
W=set(range(w))
H=set(range(h))

for _ in range(n):
    x,y,a=map(int,input().split())
    if a==1:W&=set(range(x,w))
    if a==2:W&=set(range(0,x))
    if a==3:H&=set(range(y,h))
    if a==4:H&=set(range(0,y))

print(len(W)*len(H))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cmath>
#include<cstring>
using namespace std;

int main(){
  int a,ans=0;
  for(int i=0;i<10;i++){
    scanf("%d",&a);
    ans+=a;
  }
  printf("%d\n",ans);
    
  return 0;
}



Measured memory_bytes: 3228
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		sc.close();

		int sum = A + B + C;
		int count = 0;

		while (true) {
			if (sum % 3 == 0 && sum / 3 >= Math.max(A, Math.max(B, C)))
				break;
			sum += 2;
			count++;
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 23124
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner scanner = new Scanner(System.in);
 
        Point p1 = new Point();
        Point p2 = new Point();
 
        p1.setX(scanner.nextDouble());
        p1.setY(scanner.nextDouble());
        p2.setX(scanner.nextDouble());
        p2.setY(scanner.nextDouble());
 
        System.out.printf("%.10f\n", calcDistance(p1,p2));
    }
 
    public static double calcDistance(Point p1,Point p2){
        return Math.sqrt((p1.getX()-p2.getX())*(p1.getX()-p2.getX())+(p1.getY()-p2.getY())*(p1.getY()-p2.getY()));
    }
}
 
class Point{
 
    private double x;
    private double y;
 
    Point(){
        x = 0;
        y = 0;
    }
 
    public double getX() {
        return x;
    }
    public void setX(double x) {
        this.x = x;
    }
    public double getY() {
        return y;
    }
    public void setY(double y) {
        this.y = y;
    }
}


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

int main() 
{
   int N, K, X, Y;
   cin >> N >> K >> X >> Y;

   int cost;
   if (N > K)
      cost = X * K + Y * (N - K);
   else 
      cost = X * N;

   cout << cost << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mp make_pair
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
const int N = 2e6 + 5;
int k , bars , ans , fact[N] , inv[N];
string s;
ll mult(ll a, ll b){
	return (a*b)%M;
}
int fp(int a , int b){
	int res = 1;
	while(b > 0){
		if(b&1)res =mult(res , a);
		b /= 2;
		a = mult(a , a);
	}
	return res;
}
int nck(int a , int b){
	if(b > a)return 0;
	return mult(mult(fact[a],inv[b]),inv[a-b]);
}
int main(){
	fact[0] = inv[0] = 1;
	for (int i = 1; i < N; ++i){;
		fact[i] = mult(fact[i-1],i);
		inv[i] = fp(fact[i],M-2);
	}
	cin >> k >> s;
	bars = (int) s.size() - 1;
	//cout << fp(2 , 0) <<endl;;
	//ans = fp(26 , k); /
	for (int i = 0; i <= k; ++i){
		int stars = k - i;
		int ways = nck( stars+bars , bars );
		ans = (ans + mult( mult(fp(25,stars) , ways), fp(26,i) ))%M;
		//cout << ways <<endl;
		//cout << i <<" " << stars <<endl;
	}
	cout << ans << endl;

}	

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

typedef long long LL;
const int inf = 0x3f3f3f3f, N = 200005;
int n;
LL ans = (LL) inf * inf;

std::vector<std::pair<int, int>> v;

void solve0() {
	static bool vis[N];
	int l = v.begin()->first, r = v.rbegin()->first;
	int L = -inf, R = inf;
	for (auto p : v) {
		if (vis[p.second])
			R = std::min(R, p.first);
		else
			L = std::max(L, p.first);
		vis[p.second] = 1;
	}
	ans = std::min(ans, (LL) (L - l) * (r - R));
}
void solve1() {
	static int cnt[N], now = 0;
	int a = v.rbegin()->first - v.begin()->first, b = inf;
	int l = 1;
	for (int r = 1; r < v.size() - 1; ++r) {
		now += !cnt[v[r].second]++;
		while (now == n) {
			b = std::min(b, v[r].first - v[l].first);
			now -= !--cnt[v[l++].second];
		}
	}
	ans = std::min(ans, (LL) a * b);
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n;
	for (int i = 0, l, r; i < n; ++i)
		std::cin >> l >> r, v.emplace_back(l, i), v.emplace_back(r, i);
	std::sort(v.begin(), v.end());
	solve0(); if (v.begin()->second != v.rbegin()->second) solve1();
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 6384
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)
 
int main() {
  ll X;
  cin >> X;
  
  ll u1 = X/500;
  ll u2 = (X-u1*500)/5;

  if(X!=0) cout << 1000*u1 + 5*u2 << endl;
  else cout << 0 << endl;
  
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        long ans = 0;
        for (int i = 0; i < n - 1; i++) {
            ans += Math.min(array[i+1] - array[i],t);
        }
        System.out.println(ans+t);
    }
}


Measured memory_bytes: 64064
#include<stdio.h>

int main(){
	int N,ans=-1000000000;
	scanf("%d",&N);
	int F[N][10];
	for(int i=0;i<N;i++){
		for(int j=0;j<10;j++)scanf("%d",&F[i][j]);
	}
	int P[N][11];
	for(int i=0;i<N;i++){
		for(int j=0;j<11;j++)scanf("%d",&P[i][j]);
	}
	
	for(int k=1;k<=1023;k++){
		int bit=k;
		int c[N];
		int tmp=0;
		for(int i=0;i<N;i++)c[i]=0;
		
		for(int t=0;t<10;t++){
			int op=bit%2;
			bit/=2;
			if(op==0)continue;
			for(int i=0;i<N;i++){
				if(F[i][t]==1)c[i]++;
			}
		}
		for(int i=0;i<N;i++)tmp+=P[i][c[i]];
		if(tmp>ans)ans=tmp;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#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;++i)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;

  
int main(){
  int a, b;
  cin >> a >> b;
  
  cout << ((a < 10)&&(b < 10)? a*b : -1) << endl;
  
}





Measured memory_bytes: 256
L, R = map(int,input().split())
l , r = L//2019, R//2019
if R - L >= 2019:
    print(0)
elif R-L == 1:
    print(R*L%2019)
else:
    Amari=[]
    for i in range(L,R-1):
        for j in range(i+1,R+1):
            k = i*j
            Amari.append(k%2019)
    print(min(Amari))


Measured memory_bytes: 75408
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main()
{
	int r,d,x2000;
	cin >> r >> d >> x2000;
	for (int i = 0; i < 10; i++) {
		cout << x2000 * r - d << endl;
		x2000 = x2000 * r - d;
	}
}

Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String args[]){
    	Scanner sc=new Scanner(System.in);
      	int s=sc.nextInt();
      	int w=sc.nextInt();
      	if(w>=s){
        	System.out.println("unsafe");
        }else{
        	System.out.println("safe");
        }
    }
}

Measured memory_bytes: 35764
#include <stdio.h>
static int n, p, i, sum;
int main(void) {
    scanf("%d", &n);
    for (i = 1; i <= n; ++i) {
        scanf("%d", &p);
        if (p == i) {
            ++sum;
            ++i;
            scanf("%*d");
        }
    }
    printf("%d\n", sum);
    return 0;
}


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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  ll n;
  cin >> n;
  ld e=0, o=0;
  FOR(i, 1, n) {
    if (i % 2 == 0) {
      e++;
    }
    else {
      o++;
    }
  }
  COUT(o/(e+o));
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*

3 2
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(void)
{
    int n;
    cin >> n;
    vector<string> s(n);

    REP(i,n){
        cin >> s[i];
    }

    int acnt = 0;
    int bcnt = 0;
    int abcnt = 0;
    int bacnt = 0;

    REP(i,n){
        for(int j = 1;j<s[i].size();j++){
            if(s[i][j -1] == 'A' && s[i][j] == 'B'){
                abcnt++;
            }
        }

        if(s[i][0] == 'B'){
            bcnt++;
        }
        if(s[i][s[i].size()-1] == 'A'){
            acnt++;
        }
        if(s[i][0] == 'B' && s[i][s[i].size()-1] == 'A'){
            bacnt++;
        }
    }

    int oacnt = acnt - bacnt;
    int obcnt = bcnt - bacnt;

    if(min(oacnt,obcnt) >= 1){
        cout << abcnt + min(acnt,bcnt) << endl;
    }
    else if(max(oacnt,obcnt) >= 1){
        cout << abcnt + bacnt << endl;
    }
    else{
        cout << abcnt + max(0,bacnt-1) << endl;
    }

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
#define MOD 1000000007
#define PAI 3.14159265358979
// ver1.6
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int n,m;
  cin >> n >> m;
  if(abs(n-m)>=2) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 1;
  rep(i,0,n) {
    ans *= i+1;
    ans %= MOD;
  }
  rep(i,0,m) {
    ans *= i+1;
    ans %= MOD;
  }
  if(n==m) ans *= 2;
  
  cout << ans%MOD << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000;

using ll = long long;
using namespace std;


int main(){
    int n, l; cin >> n >> l;
    string s[100];
    rep(i, n) cin >> s[i];
    sort(s, s+n);
    rep(i, n) cout << s[i];
    cout << endl;
}

Measured memory_bytes: 256