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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n, a, b, c, d;
string s;

bool check_reach(int start, int end) {
  for (int i = start; i <= end - 1; ++i) {
    if (s[i] == '#' && s[i + 1] == '#') {
      return false;
    }
  }

  return true;
}

bool check_triple() {
  bool ret = false;
  for (int i = b; i <= d; ++i) {
    if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') ret = true;
  }

  return ret;
}

int main(void) {
  // Here your code !
  scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);

  cin >> s;

  s = '!' + s;

  if (!check_reach(a, c) || !check_reach(b, d)) {
    printf("No\n");
    return 0;
  }

  if (c < d) {
    printf("Yes\n");
    return 0;
  }

  if (check_triple()) {
    printf("Yes\n");
  }
  else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 772
k = gets.to_i

que = {}
(1..9).each {|e| que[e] = 0}
c = 0

loop do
    c += 1
    x, _ = que.shift
    if c == k
        puts x
        break
    end

    n = x % 10
    x *= 10
    que[x + n - 1] = 0 if n != 0
    que[x + n] = 0
    que[x + n + 1] = 0 if n != 9
end

Measured memory_bytes: 14204
#include "bits/stdc++.h"
using namespace std;

int r,g,b,num=0;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>r>>g>>b;
	num=r*100+g*10+b;
	if(num%4==0)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
N, S = map(int, input().split())
A = list(map(int, input().split()))
MOD = 998244353

dp = [0] * (S + 1)
ans = 0
for a in A:
    dp[0] += 1
    for s in range(S + 1)[::-1]:
        if a + s <= S:
            dp[a + s] = (dp[a + s] + dp[s]) % MOD
    ans += dp[S]
    ans %= MOD

print(ans)


Measured memory_bytes: 42412
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int s = sc.nextInt();
    int ans = 0;
    for (int i = 0; i <= k; i++) {
      for (int j = 0; j <= k; j++) {
        int tmp = s - i - j;
        if (0 <=tmp && tmp <= k)
          ans++;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21332
N, K = map(int, input().split())
line_input = input()

lower_input = line_input.lower()
K -= 1
if K == 0:
	line_output = lower_input[K] + line_input[K+1:]
elif K == N-1:
    line_output = line_input[:K] + lower_input[K]
else:
    line_output = line_input[:K] + lower_input[K] + line_input[K+1:]

print(line_output)


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int32 i=0;i<(n);++i)
#define FOR(i,a,b) for(int32 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int32 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)


int64 a[3],d;
int64 mul[3] = {2,3,5};

map<int64,int64> memo;

int64 dfs(int64 n){
    // cout << n << endl;
    if(memo.count(n))return memo[n];
    if(n == 0)return 0;
    if(n == 1)return d;
    int64 res = LLINF;
    if(n < LLINF / d){
        res = n * d;
    }
    REP(i,3){
        int64 down = n / mul[i] * mul[i];
        res = min(res, dfs(down / mul[i]) + a[i] + (n - down) * d);
        int64 up = (n + mul[i] - 1) / mul[i] * mul[i];
        res = min(res, dfs(up / mul[i]) + a[i] + (up - n) * d);
    }
    return memo[n] = res;
}

void solve(){
    memo.clear();
    int64 n;
    cin >> n >> a[0] >> a[1] >> a[2] >> d;
    cout << dfs(n) << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 t;
    cin >> t;
    REP(_,t)solve();
    return 0;
}

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

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

  	int n,k;
  	cin>>n>>k;
  	n+=n%2;
  	n/=2;
  	if(n>=k)cout<<"YES\n";
  	else cout<<"NO\n";
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



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

	int a[100] = {},b[100] = {};

	rep(i,0,m){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
	}

	int ans = 0;

	rep(i,0,m){
        
        int d[100][100] = {};
        rep(i,0,n)rep(j,0,n)if(i != j)d[i][j] = inf;
        
        rep(j,0,m)if(i != j){
            d[a[j]][b[j]] = 1;
            d[b[j]][a[j]] = 1;
        }

        rep(k,0,n){
            rep(ii,0,n){
                rep(jj,0,n){
                    d[ii][jj] = min(d[ii][jj],d[ii][k] + d[k][jj]);
                }
            }
        }

     /*   P(i);
        rep(ii,0,n){
            rep(jj,0,n){
                cout << d[ii][jj] << " " ;
            }
            cout << endl;
        }
           */ 
       
        
        if(d[a[i]][b[i]] == inf)ans++;
      
	}
	P(ans);
	return  0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<double, double> P;
int main() {
    int n;
    cin >> n;
    vector<P>pts(n);
  
    for (P &p:pts) 
        cin>>p.first>>p.second;

    sort(pts.begin(), pts.end(), [](P p1, P p2){
        
         return atan2(p1.first, p1.second) < atan2(p2.first, p2.second);
         
    });

    double ans = 0;
   
    for (int i=0;i<n;i++) {
        vector<int>v;
        double y=0,x=0;
        for (int j=i; j<i+n;j++) {
            v.push_back(j);
            auto p=pts[j%n];

            y += p.first;
            x += p.second;
            double cur = sqrt((x*x)+(y*y));

         ans=max(ans,cur);

        }
    }


    cout << setprecision(40) <<fixed<< ans << endl;

}


Measured memory_bytes: 4128
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    int x1, y1;
    int d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

bool find_any_solution(int a, int b, int c, int &x0, int &y0, int &g) {
    g = gcd(abs(a), abs(b), x0, y0);
    if (c % g) {
        return false;
    }

    x0 *= c / g;
    y0 *= c / g;
    if (a < 0) x0 = -x0;
    if (b < 0) y0 = -y0;
    return true;
}
int main(){
    int n, m;
    cin >> n >> m;
    m/=1000;
    int x, y, g;
    if(!find_any_solution(9,4,m-n,x,y,g)) {cout << "-1 -1 -1"; return 0;}
    //cout << x << " " << y <<endl;
    while(x<0){
        x += 4/g;
        y -= 9/g;
    }
    //cout << x << " " << y <<endl;
    while(y<0){
        x -= 4/g;
        y += 9/g;
    }
    //cout << x << " " << y <<endl;
    if(x<0 || y<0 || n-x-y<0) {cout <<  "-1 -1 -1"; return 0;}
    cout << x << " " << y << " " << n-x-y;

}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n ;
  cin >> n ;
  int D = 0 ;
  int N = n ;
  
  while(n > 0){
    D += n%10 ;
    n /= 10 ;
  }
  
  if( N%D == 0)
    cout <<"Yes" ;
  else 
    cout << "No";
}


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

int main()
{
	int i, j, k;

	int n, a, b;
	cin >> n >> a >> b;

	int temp = a > b ? b : a;
	int c;
	if (a + b > n)
	{
		c = a + b - n;
	}
	else
	{
		c = 0;
	}
	printf("%d %d", temp, c);

	return 0;
}


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

int main() {
  int n,ans;
  ans=0;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n-1);
  for(int i=0;i<n;i++) cin >> a.at(i);
  for(int i=0;i<n;i++) {
    cin >> b.at(i);
    ans+=b.at(i);
  };
  for(int i=0;i<n-1;i++) cin >> c.at(i);
  for(int i=0;i<n;i++) {
    if(i!=0){
      if(a.at(i)-1==a.at(i-1)) ans+=c.at(a.at(i)-2);
    };
  };
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
x = n
divisor = []
for i in range(2,int(x**(1/2))+1):
         if n % i == 0:
                  while n % i == 0:
                           n = n // i
                           divisor.append(i)
if n != 1:
         divisor.append(n)
print(str(x)+":",*divisor)






Measured memory_bytes: 5624
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    D = sorted(LIST())
    print(D[N//2] - D[N//2-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 52584
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
typedef pair<int, int> P;

int dp[100001][3] = {};

int main(){
    int n, i, a, b, c;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> a >> b >> c;
        if(i == 0){
            dp[i][0] = a;
            dp[i][1] = b;
            dp[i][2] = c;
        }else{
            dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a;
            dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b;
            dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c;
        }
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << "\n";
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
struct Dice{
  int a[6];
  void D(char c){
    int b;
    if(c=='E')
      b=a[0], a[0]=a[3], a[3]=a[5], a[5]=a[2], a[2]=b;
    else if(c=='W')
      b=a[0], a[0]=a[2], a[2]=a[5], a[5]=a[3], a[3]=b;
    else if(c=='S')
      b=a[0], a[0]=a[4], a[4]=a[5], a[5]=a[1], a[1]=b;
    else
      b=a[1], a[1]=a[2], a[2]=a[4], a[4]=a[3], a[3]=b;
  }
};
int main(){
  Dice d;
  for(int i=0;i<6;++i) cin>>d.a[i];
  int n; cin>>n;
  while(n--){
    int a,b; cin>>a>>b;
    if(d.a[3]==a) d.D('E');
    if(d.a[2]==a) d.D('W');
    while(d.a[0]!=a) d.D('S');
    while(d.a[1]!=b) d.D('X');
    cout<<d.a[2]<<endl;
  }
  return 0;
}

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

 int main() {
  string S;
  cin >> S;
  //cout << S << endl; 
  
  bool ans = false;
/*  for(int i = 0;i < S.size();i++){
     if (S.at(i) == S.at(i + 1)) {
      ans = true;
     }
  } */
  
   if(S.at(0) == S.at(1) || S.at(1) == S.at(2) || S.at(2) == S.at(3)){
    ans = true;
  }
  if(ans){
    cout << "Bad" << endl;
  }else{
    cout << "Good" << endl;
  }  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

signed main(){

	lli n,k;
	cin>>n>>k;

	if(k==1)cout<<0<<endl;
	else cout<<n-k<<endl;

	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;

const int V = 21;
int cost[V][V]; // cost[from][to]

void main(){
	int n ,m, a, b, c, d;
	for (int i = 0; i < V; i++) {
		cost[i] = 999999999;
		cost[i][i] = 0;
	}
	readf("%d\n", &n);
	readf("%d\n", &m);
	for (int i = 0; i < m; i++) {
		readf("%d,%d,%d,%d\n", &a, &b, &c, &d);
		cost[a][b] = c;
		cost[b][a] = d;
	}
	warshall_floyd();
	readf("%d,%d,%d,%d\n", &a, &b, &c, &d);
	writeln(c - d - cost[a][b] - cost[b][a]);
}

void warshall_floyd(){
	for (int k = 0; k < V; k++)
		for (int i = 0; i < V; i++)
			for (int j = 0; j < V; j++)
				cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
}

Measured memory_bytes: 988
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 1000000
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
ll s[N];
int main()
{	int n,c; long double ans=1e100; cin>>n>>c;
	for(rint i=1;i<=n;i++) scanf("%lld",&s[i]),s[i]+=s[i-1];
	for(rint i=1;i<=n;i++)
	{	long double sum=ll(n+i)*c;
		for(rint t=1,j=n;j>=1;t++,j-=i)
		sum+=(long double)(t==1?5:2*t+1)*(s[j]-s[max(0,j-i)]);
		ans=min(ans,sum);
	}
	cout<<(ll)ans;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
typedef long long ll;
using namespace std;

class ab{
public:
  int a, b;
  bool operator<(const ab &another){
    if(b == another.b){
      return a < another.a;
    }
    return b < another.b;
  }
};

void solve(){
  int n, m; cin >> n >> m;
  vector<int> a(n), b(n);
  vector<vector<int> > v(m);
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
    if(m - a[i] < 0) continue;
    v[m - a[i]].push_back(b[i]);
  }
  priority_queue<int> q;
  ll ans = 0;
  for(int i = m - 1; i >= 0; i--){
    for(int j = 0; j < v[i].size(); j++){
      q.push(v[i][j]);
    }
    if(!q.empty()){
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;

  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 6400
#include "bits/stdc++.h" // 提出時こちらで問題なし
//#include <iostream>
//#include <string>
//#include <typeinfo>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define REP2(i, s, n) for (int i=(int)(s); i<(int)(n); i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
#define SORT(c) sort((c).begin(),(c).end())
#define R_SORT(c) sort((c).begin(),(c).end(),greater<>())
using G = vector<vector<int>>;
using M = map<int, int>;
using P = pair<int, int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

// A - Air Conditioner
int main() {
	int x;
	cin >> x;
	if (x >= 30) {
		cout << "Yes" endl;
	}
	else {
		cout << "No" endl;
	}


	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<map>
#include<string>
using namespace std;
map<string,int>mp;
string a;
int maxn = 0;
int main(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a;
		mp[a]++;
	}
	auto it = mp.begin();
	while(it != mp.end()){
		if(it -> second > maxn)
			maxn = it -> second;
		it++;
	}
	it = mp.begin();
	while(it != mp.end()){
		if(it -> second == maxn)
			cout << it -> first << endl;
		it++;
	}
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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


int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    ll N, N_sub;
    cin >> N;
    N_sub = N;

    ll dig_sum = 0;
    while(N_sub > 0 ){
        dig_sum += (N_sub % 10);
        N_sub = (N_sub - N_sub % 10) / 10;
    }

    if(N % dig_sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,c,i,j,k,l,m,n,ans,tmp,hoge,fuga,piyo;
ll x[10010],y[10010];
string s,str;
char ch;
int main(){
  int aa[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin>>k;
  cout<<aa[k-1];
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

ll gcd(ll a, ll b) {
  if (a > b) {
    auto tmp = b;
    b = a;
    a = tmp;
  }
  while (a > 0){
    auto tmp = b % a;
    b = a;
    a = tmp;
  }
  return b;
}

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

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

  if (N > M) {
    auto tmp = N;
    auto tmps = s;
    N = M;
    s = t;
    M = tmp;
    t = tmps;
  }
  auto dn = N / gcd(N, M);
  auto dm = M / gcd(N, M);
  bool match = true;
  for (auto i = 0; i * dn < N; i++) {
    if (s[i * dn] != t[i * dm]) {
      match = false;
      break;
    }
  }
  if (match) {
    cout << lcm(N, M) << endl;
  } else {
    cout << "-1" << endl;
  }

  return 0;
}


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

const int INF = (int) 1e9 + 7;

int C[12], done[12], A[12][12];

int main() {
    
    int n, m, x;
    cin >> n >> m >> x;

    for (int i=0; i<n; i++)
    {
        cin >> C[i];

        for (int j=0; j<m; j++)
            cin >> A[i][j];
    }

    int ans = INF;

    for (int i=0; i<(1<<n); i++)
    {
        int sum = 0;
        memset(done, 0, sizeof(done));

        for (int j=0; j<n; j++)
        {
            if (!(i & (1 << j)))
                continue;
            
            sum += C[j];
            
            for (int k=0; k<m; k++)
                done[k] += A[j][k];
        }

        int flag = 0;

        for (int j=0; j<m; j++)
            if (done[j] < x)
                flag = 1;
        
        if (flag == 0)
            ans = min(ans, sum);
    }

    if (ans == INF)
        ans = -1;

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
using namespace std;
#define mod 1000000007
int main() {
	/*int N;
	cin >> N;
	vector<int>h(N);
	int i;
	for (i = 0; i < N; i++) {
		cin >> h[i];
	}
	vector<int>c(N);
	c[0] = 0;
	c[1] = abs(h[1]-h[0]);
	for (i = 1; i < N - 1; i++) {
		c[i + 1] = min(c[i] + abs(h[i + 1] - h[i]), c[i - 1] + abs(h[i + 1] - h[i - 1]));
	}
	cout << c[N - 1] << endl;*/



	/*int N, K;
	cin >> N >> K;
	vector<int>h(N);
	int i, j;

	for (i = 0; i < N; i++) {
		cin >> h[i];
	}
	vector<int>c(N);
	c[0] = 0;
	c[1] = abs(h[1] - h[0]);
	for (i = 1; i < N - 1; i++) {
		c[i + 1] = c[i] + abs(h[i + 1] - h[i]);
		for (j = 1; j <= K && i + 1 - j >= 0; j++) {
			c[i + 1] = min(c[i + 1], c[i + 1 - j] + abs(h[i + 1] - h[i + 1 - j]));
		}
	}
	cout << c[N - 1] << endl;*/


	/*int N;
	cin >> N;
	vector<int>a(N), b(N), c(N);
	int i;
	for (i = 0; i < N; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	vector<int>A(N), B(N), C(N);
	A[0] = a[0];
	B[0] = b[0];
	C[0] = c[0];
	for (i = 0; i < N - 1; i++) {
		A[i + 1] = a[i + 1] + max(B[i], C[i]);
		B[i + 1] = b[i + 1] + max(A[i], C[i]);
		C[i + 1] = c[i + 1] + max(A[i], B[i]);
	}
	cout << max({ A[N - 1], B[N - 1],C[N - 1] }) << endl;*/


	/*int N, W;
	cin >> N >> W;
	int i, j;
	vector<int>w(N + 1), v(N + 1);
	for (i = 0; i < N; i++) {
		cin >> w[i + 1] >> v[i + 1];
	}
	vector<vector<long long>>dp(N + 1, vector<long long>(W + 1));
	for (i = 0; i < N; i++) {
		for (j = 0; j <= W; j++) {
			if (j - w[i + 1] >= 0)dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i + 1]] + v[i + 1]);
			else dp[i + 1][j] = dp[i][j];
		}
	}
	cout << dp[N][W] << endl;*/


	/*long long N, W;
	cin >> N >> W;
	vector<long long>dp(100005);
	int w, v, i, j;
	for (i = 0; i <= 100004; i++)dp[i] = 1e10;
	dp[0] = 0;
	for (i = 0; i < N; i++) {
		cin >> w >> v;
		for (j = 100004; j >= v; j--) {
			dp[j] = min(dp[j], dp[j - v] + w);
		}
	}
	long long ans = 0;
	for (i = 0; i <= 100004; i++) {
		if (W >= dp[i]) {
			ans = i;
		}
	}
	cout << ans;*/


	/*string s, t;
	cin >> s >> t;
	vector<vector<int>>dp(3005, vector<int>(3005));
	int i, j;
	for (i = 0; i < s.size() - 1; i++) {
		for (j = 0; j < t.size() - 1; j++) {
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]);
			if (s[i] == t[j])dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
		}
	}
	string ans;

	cout << dp[s.size()][t.size()] << endl;*/                   //F


	//int N, M;
	//cin >> N >> M;                   //G

	int H, W;
	cin >> H >> W;
	vector<vector<char>>a(H + 1, vector<char>(W + 1));
	vector<vector<int>>dp(H + 1, vector<int>(W + 1));
	int i, j;
	dp[1][1] = 1;
	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) {
			cin >> a[i][j];
			if (a[i][j] == '.') {
				dp[i][j] += (dp[i - 1][j] + dp[i][j - 1]) % mod;
			}
			else {
				dp[i][j] = 0;
			}
		}
	}
	cout << dp[H][W];
	return 0;

}

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

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

int main(){
    ll a, b;
    cin >> a >> b;
    if ( a > 0 && b > 0 ) {
        cout << "Positive" << endl;
    }
    else if ( a < 0 && b < 0 ) {
        if ( abs(b-a+1) % 2 == 1 ) {
            cout << "Negative" << endl;
        }
        else {
            cout << "Positive" << endl;
        }
    }
    else {
        cout << "Zero" << endl;
    }
    return 0;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> x(n + 1),y(n + 1);
	for (int i = 0;i < n;i++) cin >> x[i] >> y[i];
	sort(x.rbegin(),x.rend());
	sort(y.begin(),y.end());
	long long ans = 0;
	for (int i = 0;i <= n;i++) {
		ans += 2 * max(0,x[i] - y[i]);
	}
	cout << ans;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    string s, t;
    cin >> s >> t;
    set<string> S;
    queue<int> Q;
    if (s.size() >= t.size()) {
        int m = 0, ml = 0, p = -1;
        for (int j=0;j<s.size();j++) {
            if (s[j] == '?') m++;
            else {
                if (ml < m) {
                    ml = m;
                    p = j-m;
                }
                m = 0;
            }
        }
        if (m) {
            if (ml < m) {
                ml = m;
                p = s.size()-m;
            }
        }
        for (int i=0;i<t.size();i++) {
            for (int j=0;j<s.size();j++) if (s[j] == t[i] || s[j] == '?') Q.push(j);
            bool f = true;
            while (!Q.empty()) {
                string s1(s);
                int p = Q.front();
                for (int j=0;j<t.size();j++) {
                    if (s1[p+j] != t[j] && s1[p+j] != '?') {
                        f = false;
                        break;
                    } else s1[p+j] = t[j];
                }
                if (f) {
                    for (int j=0;j<s1.size();j++) if (s1[j] == '?') s1[j] = 'a';
                    S.insert(s1);
                }
                Q.pop();
                f = true;
            }
        }
    }
    if (S.size() == 0) cout << "UNRESTORABLE" << endl;
    else {
        for (auto itr: S) {
            cout << itr << endl; break;
        }
    }

    return 0;
}


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

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

using namespace std;

typedef vector<int> vi;

int main(){
	int n;
	while(cin >> n, n){
		vi v(n);
		rep(i, n){
			cin >> v[i];
		}
		sort(all(v));
		int sum = 0;
		for(int i = 1; i < n-1; i++){
			sum += v[i];
		}
		cout << sum/(n-2) << endl;
	}

	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;


void solve(long long N, long long R){
    if(N >=10){
        cout<<R<<endl;
    }else{
        cout<<R+100*(10-N)<<endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long R;
    scanf("%lld",&R);
    solve(N, R);
    return 0;
}


Measured memory_bytes: 256
import heapq

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


L = a[:N]
R = a[(N*2):]
L_sum_list = [sum(L)]
R_sum_list = [sum(R)]

R = [-elem for elem in R]

heapq.heapify(L)
heapq.heapify(R)

for k in range(N):
    #L側
    rem = a[N+k] - heapq.heappushpop(L, a[N+k])
    L_sum_list.append(L_sum_list[-1]+rem)

    #R側
    rem = -(a[N*2-k-1]) - heapq.heappushpop(R, -(a[N*2-k-1]))
    R_sum_list.append(R_sum_list[-1]-rem)

res = []
for k in range(N+1):
    res.append(L_sum_list[k] - R_sum_list[-k-1])

print(max(res))
    



Measured memory_bytes: 38288
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 1e5 + 120;
 


int n;
vector <pii> adj[maxn];
bool  col[maxn];


void dfs(int v ,int par = -1){
    for(pii p : adj[v])
        if(p.first != par){
            col[p.first] = col[v] ^ p.second;
            dfs(p.first ,v);
        }
}

int main(){FAST;
    cin >> n;
    for(int i = 0,w ,u ,v; i < n - 1; i++){
        cin >> u >> v >> w;
        adj[--u].push_back({--v ,w & 1});
        adj[v].push_back  ({ u , w & 1});
    }
    dfs(0);
    forp(i ,0 ,n)
        out(col[i]);


   return 0;
}
 












Measured memory_bytes: 8064
import sys
from io import StringIO
import unittest


def resolve():
    s = input()
    # n = int(input())
    # a, b = map(int, input().split())
    # l = [list(map(int, input().split())) for _ in range(n)]

    if 'RRR' in s:
        print(3)
    elif 'RR' in s:
        print(2)
    elif 'R' in s:
        print(1)
    else:
        print(0)

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """RRS"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """SSS"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """RSR"""
        output = """1"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16336
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
using namespace std;

int main(){
  
  int n; cin >> n;
  int ans=0;

  for (int i=1; i<=n; i++){
    if ((int)log10(i)%2==0) ans++;
  }

  cout << ans;
 
  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: i32 = read();
    assert!(n >= 3 && n <= 100);
    println!("{}", 180 * (n -2));
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 4352
/**
 *    author:  tourist
 *    created: 11.05.2020 14:08:15       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  cout << string(s.size(), 'x') << '\n';
  return 0;
}


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

using namespace std;

int a, b, v, w, t;

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d\n%d %d\n%d", &a, &v, &b, &w, &t);
int d = a - b;
if (d < 0) d = -d;
int rv = v - w;
if (1LL * rv * t >= d) printf ("YES\n");
else printf ("NO\n");

return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll dp[105][10005];
pll V[105];

int main() {
    ll N, W;
    cin >> N >> W;
    REP(i, N) {
        cin >> V[i].first >> V[i].second;
    }

    std::fill(dp[0], dp[105], INF);
    dp[0][0] = 0;
    ll max = 0;
    REP(i, N) {
        REP(j, max + 1) {
            dp[i + 1][j] = std::min(dp[i][j], dp[i + 1][j]);
            ll w = dp[i][j] + V[i].second;
            if (w <= W) {
                dp[i + 1][j + V[i].first] = std::min(dp[i + 1][j + V[i].first], w);
                max = std::max(max, V[i].first + j);
            }
        }
    }

    cout << max << endl;
    return 0;
}


Measured memory_bytes: 11316
#include <iostream>
#include <string>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

int main(){
	int n,point=0;
	cin>>n;
	int a[n];
	int b[n];
	int c[n-1];

	rep(i,n) cin>>a[i];
	rep(i,n) cin>>b[i];
	rep(i,n-1) cin>>c[i];

	int before = -1;
	rep(i,n){
		if(before+1==a[i]){
			point+=c[before-1];
		}
		point += b[a[i]-1];
		before = a[i];
	}
	cout << point;
}

Measured memory_bytes: 256
import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
#sys.setrecursionlimit(10 ** 9)
import math
import heapq


N, Q = list(map(int, input().split()))
eda = [[] for i in range(N)]
ope = [0]*N
score = [0]*N
parent = [-1]*N


for i in range(N - 1):
	a, b = list(map(int, input().split()))
	eda[a - 1].append(b - 1)
	eda[b - 1].append(a - 1)

for i in range(Q):
	p, x = list(map(int, input().split()))
	ope[p - 1] += x


que = []
que.append(0)
score[0] = ope[0]
for ss in range(N - 1):
	loc = que.pop()
	for edge in eda[loc]:
		if parent[loc] != edge:
			score[edge] += score[loc] + ope[edge]
			que.append(edge)
			parent[edge] = loc

for i in range(N - 1):
	print(score[i], end = "")
	print(" ", end = "")
print(score[N - 1])









Measured memory_bytes: 109132
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
ll n,m,x,y,cnt=0;
vector<ll> flag(9);
vector<vector<ll>> a(9),b(9);

bool judge(vector<ll> flag){
	ll ans=1;
	FOR(i,1,n+1)ans *=flag[i];		
	return ans?true:false;
}

void dfs(int i){
	flag[i]=1;
	if(judge(flag)){
		cnt++;
		flag[i]=0;
		return;
	}
	rep(j,a[i].size())
	if(flag[a[i][j]]==0)dfs(a[i][j]);
	rep(j,b[i].size())
	if(flag[b[i][j]]==0)dfs(b[i][j]);
	flag[i]=0;
	return;
}

int main(){
	cin>>n>>m;
	rep(i,m){
		cin>>x>>y;
		a[x].pb(y);b[y].pb(x);
	}
	dfs(1);
	cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	a := readInt()
	b := readInt()
	if a == b {
		fmt.Println(a + b)
	} else if a > b {
		fmt.Println(a + (a - 1))
	} else {
		fmt.Println(b + (b - 1))
	}
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	i, e := strconv.Atoi(read())
	if e != nil {
		panic(e)
	}
	return i
}


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

using namespace std;

#define ll long long

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

    return true;
}
int binarySearch(int arr[], int l, int r, int x)
{
    if (r >= l) {
        int mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
long long lcm(long long a,long long b)
{
    long long p,r;
    p = a*b;
    r = __gcd(a, b);
    return p/r;
}
void solve()
{
   int n,l,sum=0;
   cin>>n>>l;
   vector<int>temp;
   for(int i=1;i<=n;i++)
   {
       temp.push_back(l+i-1);
       sum += (l+i-1);
   }
   int d=10000;
   sort(temp.begin(),temp.end());
   for(int i=0;i<temp.size();i++)
   {
       if(temp[i]>=0)
       {
           d = temp[i];
           break;
       }
   }
   if(d==10000)
   {
       d = temp[temp.size()-1];
   }
   cout<<sum-d<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}


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

	int a,b;
	scanf("%d",&a);	
	scanf("%d",&b);
	if(a<b){
		printf("a < b\n");
	}
	if(a>b){
		printf("a > b\n");
	}
	if(a==b){
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <stdio.h>
#include <stdlib.h>
int main(void){
	int n, m, x;
	int *c;
	int *a;
	int *sum;
	int c_sum_min = -1;
	scanf("%d", &n);
	scanf("%d", &m);
	scanf("%d", &x);
	c = (int *)malloc(sizeof(int) * n);
	a = (int *)malloc(sizeof(int) * n * m);
	sum = (int *)malloc(sizeof(int) * m);
	for(int i=0; i<n; i++){
		scanf("%d", &c[i]);
		for(int j=0; j<m; j++){
			scanf("%d", &a[i*m+j]);
		}
	}
	for(int k=0; k<4096; k++){
		int flg = 1;
		int c_sum = 0;
		for(int l=0; l<m; l++){
			sum[l] = 0;
		}
		for(int p=0; p<n; p++){
			if(k & (1<<p)){
				c_sum += c[p];
				for(int q=0; q<m; q++){
					sum[q] += a[p*m+q];
				}
			}
		}
		for(int r=0; r<m; r++){
			if(sum[r] < x){
				flg = 0;
			}
		}
		if(flg == 1 && (c_sum_min < 0 || c_sum < c_sum_min)){
			c_sum_min = c_sum;
		}
	}
	printf("%d\n", c_sum_min);
	return 0;
}

Measured memory_bytes: 1736
import numpy as np
def main():
    ABK = [np.int64(i) for i in input().split(" ")]
    A = ABK[0]
    B = ABK[1]
    K = ABK[2]

    ans = 0

    if A <= K:
        K -= A
        A = 0
        if B <= K:
            B = 0
        else:
            B -= K
    else:
        A -= K

    ans = "{0} {1}".format(A, B)

    print(ans)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 21604
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= b) {
        if (b <= c){
            cout << 10 * c + b + a << endl;
        } else if (a <= c){
            cout << a + c + 10 * b << endl;
        } else {
            cout << 10 * b + a + c << endl;
        }
    } else {
        if (a <= c){
            cout << 10 * c + b + a << endl;
        } else if (b <= c){
            cout << 10 * a + b + c << endl;
        } else {
            cout << 10 * a + b + c << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include<math.h>
using namespace std;
 
int y[1001];
int main(){
  int n;
  long long ans=1;
  cin >> n;
  for(int i=2; i<=n; ++i){
      int t = i;
      for(int k=2; k<=t; ++k){
          if(t%k == 0){
              t/=k;
              ++y[k];
              --k;
          }
      }
  }
 
  for(int i=2; i<1001; ++i){
    if(y[i] > 0){
      ans *= (y[i] + 1);
      ans %= 1000000007;
    }
  }
  
  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 rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll A[200001],B[200001];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,x[200001],y[200001];
    cin>>n;
    rep(i,n) cin>>x[i]>>y[i];
    ll ans=0;
    rep(i,n) A[i]=x[i]+y[i],B[i]=x[i]-y[i];
    sort(A,A+n),sort(B,B+n);
    cout<<max(A[n-1]-A[0],B[n-1]-B[0]);
}

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

int main()
{
 bool prime[1000000];

 prime[0]=prime[1]=false;
 for(int i=2;i<1000000;i++){
	prime[i]=true;
 }
 for(int i=2;i*i<1000000;i++){
	if(prime[i]){
		for(int j=i*i;j<1000000;j+=i){
			prime[j]=false;
		}
	}
 }

//???????????§?´???°??¨
 int n,x,pea;
 
 
 while(1){
	pea=0;
	cin>>n;
  if(n==0)break;
	for(int i=0;i<n/2+1;i++){
		if(prime[i]){
			x=n-i;
			if(prime[x]){
				pea++;
			}
		}
 	 }
 //	cout<<"??????????????????"<<pea<<"???????????????"<<endl;
	cout<<pea<<endl;
 }

 return 0;
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-5;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
ll n,m;
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	ll ans = n * m;
	if(n == 1 || m == 1) cout << 1 << endl;
	else{
		if(ans & 1) cout << (ans + 1) / 2 << endl;
		else cout << ans / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("trapv")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<bits/extc++.h>
using namespace __gnu_pbds;
//using namespace __gnu_cxx;
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
const int maxn = 3e5 + 33, mlg = 18, mod = 1e9 + 7;
vector<vpi> t;
int n;
bool check(int msk) {
	for(int i = 0; i < n; i++) {
		if(!((msk>>i)&1)) continue;
		for(auto j : t[i]) {
			if(j.second != ((msk>>j.first)&1)) return false;
		}
	}
	return true;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	t.resize(n);
	for(int a, i = 0; i < n; i++) {
		cin >> a;
		t[i].resize(a);
		for(auto &j : t[i])
			cin >> j.first >> j.second, j.first--;
	}
	int ans = 0;
	for(int msk = 0; msk < 1<<n; msk++) {
		if(check(msk)) ans = max(ans, __builtin_popcount(msk));
	}
	cout << ans;
}


Measured memory_bytes: 256
H, W, M = map(int, input().split())
hb, wb = [0]*H, [0]*W
bomb = set()
for _ in range(M):
    y, x = map(int, input().split())
    y -= 1
    x -= 1
    hb[y] += 1
    wb[x] += 1
    bomb.add((y,x))

hindices = [*range(H)]
windices = [*range(W)]
sorted_hindices = sorted(hindices, key=lambda i: -hb[i])
sorted_hb = [hb[i] for i in sorted_hindices]
sorted_windices = sorted(windices, key=lambda i: -wb[i])
sorted_wb = [wb[i] for i in sorted_windices]

mh, mw = sorted_hb[0], sorted_wb[0]
for i in range(1, H):
    if sorted_hb[i] < mh:
        sorted_hb = sorted_hb[:i]
        sorted_hindices = sorted_hindices[:i]
        break
for i in range(1, W):
    if sorted_wb[i] < mw:
        sorted_wb = sorted_wb[:i]
        sorted_windices = sorted_windices[:i]
        break

for y in sorted_hindices:
    for x in sorted_windices:
        if (y,x) not in bomb:
            print(mh+mw)
            exit()

print(mh+mw-1)

Measured memory_bytes: 195684
a, b, h, m = map(int, input().split())

from math import sin, cos, sqrt, pi

jishin_rad = ((h*60+m) / 720 * 360) * pi / 180
funshin_rad = (m / 60 * 360) * pi / 180

jishin = (sin(jishin_rad)*a, cos(-jishin_rad)*a)
funshin = (sin(funshin_rad)*b, cos(-funshin_rad)*b)

x_diff = jishin[0] - funshin[0]
y_diff = jishin[1] - funshin[1]
print(sqrt(x_diff**2 + y_diff**2))


Measured memory_bytes: 9460
#include <stdio.h>

int gcd(int a, int b);

int main() {

	int a;
	int b;

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

	printf("%d\n", gcd(a, b));

	return 0;
}

int gcd(int a, int b) {

	int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	if (a % b == 0) {
		return b;
	}

	return gcd(b, a % b);

}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  string ans = "Yes";
  ll i = 0;
  while (a > 0 && c > 0) {
    if(i % 2 == 0) {
      c -= b;
    } else {
      a -= d;
    }

    if(a <= 0) {
      ans = "No";
      break;
    }

    if(c <= 0) {
      ans = "Yes";
      break;
    }

    i++;
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main(){
  char S[16];
  cin >> S;
  int cnt = 0;
  for (int i = 0; i < 16; ++i) {
    if (S[i] == 'x') cnt++;
  }
  if (cnt >= 8) cout << "NO" << endl;
  else cout << "YES" << endl;
}

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    s = list(input()[:-1].decode())
    n = len(s)
    for i in reversed(range(n - 1)):
        if (i + 1) % 2 == 0:
            l = ''.join(s[:(i + 1) // 2])
            r = ''.join(s[(i + 1) // 2:i + 1])
            if l == r:
                print(i + 1)
                exit()


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38384
n,m =[int(i) for i in input().split()]
s=[int(i) for i in input().split()]
t=[int(i) for i in input().split()]
a=[1]*(m+1)
for b in s:
  d=a[:]
  k=0
  for j,c in enumerate(t):
    d[j]=(k+d[j])%1000000007
    if b==c:
      k=(k+a[j])%1000000007
  d[-1]=(k+d[-1])%1000000007
  a=d[:]
print(a[-1])
    


Measured memory_bytes: 3316
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    char before = S.charAt(0);
    int ans = 0;
    for (int i = 1; i < S.length(); i++) {
      if (before != S.charAt(i)) {
        ans++;
        before = S.charAt(i);
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 24148
'''dp = [ [ -1 for i in range( 200 ) ] for j in range( 200 ) ]

def dfs( x, y ):
    global dp
    if dp[ x ][ y ] != -1:
        return dp[ x ][ y ]
    if x <= 1 and y <= 1:
        dp[ x ][ y ] = 0
        return dp[ x ][ y ]
    bag = set()
    for i in range( 2, x + 1, 2 ):
        bag.add( dfs( x - i, y + i // 2 ) )
    for i in range( 2, y + 1, 2 ):
        bag.add( dfs( x + i // 2, y - i ) )
    for i in range( 1000000 ):
        if not ( i in bag ):
            dp[ x ][ y ] = i
            return dp[ x ][ y ]

for i in range( 0, 100 ):
    for j in range( i, 100 ):
        if dfs( i, j ) == 0:
            print( i, j )'''

X, Y = map( int, input().split() )
if X > Y:
    X, Y = Y, X
if X == Y or X + 1 == Y:
    print( "Brown" )
else:
    print( "Alice" )


Measured memory_bytes: 38384
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	string s; cin >> s;
	if (s[0] == s[s.length() - 1]) {
		if (s.length() % 2 == 1) puts("Second");
		else puts("First");
	}
	else {
		if (s.length() % 2 == 0) puts("Second");
		else puts("First");
	}
	return 0;
	return 0;
}

Measured memory_bytes: 512