akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 100000
#define ll long long
#define dmp make_pair
#define dpb push_back
#define P pair<int,int>
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);
const int INF = 2147483647;
#define B 100

int bucket[MAX/B][B];
int data[MAX/B];
void update(int a, int b, int x){
	int f1 = 1, f2 = 1;
	while(a <= b && a%B != 0){
		if(f1 && data[a/B] != -1){
			for(int i = 0;i < 100;i++)bucket[a/B][i] = data[a/B];
			f1 = 0;data[a/B] = -1;
		}
		bucket[a/B][a%B] = x;
		a++;
	}
	while(a <= b && b%B != 99){
		if(f2 && data[b/B] != -1){
			for(int i = 0;i < 100;i++)bucket[b/B][i] = data[b/B];
			f2 = 0;data[b/B] = -1;
		}
		bucket[b/B][b%B] = x;
		b--;
	}
	while(a < b){
		data[a/B] = x;
		a += B;
	}
}

int find(int x){
	if(data[x/B] != -1){
		for(int i = 0;i < 100;i++)bucket[x/B][i] = data[x/B];
		data[x/B] = -1;
	}
	return bucket[x/B][x%B];
}

int main(){
	int n, q, c, s, t, x, ans;
	scanf("%d%d", &n, &q);
	fill(data, data+MAX/B, -1);
	fill((int*)bucket, (int*)(bucket+MAX/B), INF);
	while(q--){
		scanf("%d", &c);
		if(!c){
			scanf("%d%d%d", &s, &t, &x);
			update(s, t, x);
		}else{
			scanf("%d", &x);
			ans = find(x);
			printf("%d\n", ans);
		}
	}
	//rep(i,n)printf("%d ", bucket[0][i]);
	return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a>b){
        cout << "a > b"<< endl;
    }
    else if(a==b){
        cout << "a == b" << endl;
    }
    else{
        cout << "a < b" << endl;
    }
}


Measured memory_bytes: 3100
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main() {
  int A, P;
  cin >> A >> P;
  P += A * 3;
  cout << P / 2 << endl;
  return 0;
}


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

int triangle(int a,int b,int c){
    //error check
	if(a<=0 || b<=0 || c<=0){
		cout << "ERROR" << endl;
		return 1;
	}
	if(a < b){
		swap(a,b);
	}
	if(a < c){
		swap(a,c);
	}
	
	if(a*a-b*b-c*c == 0){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
	return 0; 
}

int main(void){
    int num,x,y,z;
	cin >> num;
	for(int i=0;i<num;i++){
		cin >> x >> y >> z;
		triangle(x,y,z);
	}
}

Measured memory_bytes: 1152
import numpy as np

n = np.array(list(map(int, input().split())))
neven = len(np.where(n % 2 == 0)[0])

if neven == 3 or neven == 0:
    n = np.sort(n)
    print(int((n[2] - n[1]) / 2 + (n[2] - n[0]) / 2))
elif neven == 2:
    no = n[n % 2 != 0]
    ne = n[n % 2 == 0]
    ne = ne + 1
    n = np.sort(np.concatenate([no, ne]))
    print(1 + int((n[2] - n[1]) / 2 + (n[2] - n[0]) / 2))
elif neven == 1:
    no = n[n % 2 != 0]
    ne = n[n % 2 == 0]
    no = no + 1
    n = np.sort(np.concatenate([no, ne]))
    print(1 + int((n[2] - n[1]) / 2 + (n[2] - n[0]) / 2))

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
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;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

int n, q;
vi es[200000];
int c[200000];
int u[200000];

void dfs(int v, int p, int x){
  x += u[v];
  c[v] = x;

  for(int to : es[v]) if(to != p){
    dfs(to, v, x);
  }
}

signed main(){
  cin >> n >> q;

  rep(i, 0, n-1){
    int a, b;
    cin >> a >> b;
    a--; b--;
    es[a].emplace_back(b);
    es[b].emplace_back(a);
  }

  rep(i, 0, q){
    int p, x;
    cin >> p >> x;
    p--;
    u[p] += x;
  }

  dfs(0, -1, 0);

  rep(i, 0, n) cout << c[i] << " \n"[i==n-1];

  return 0;
}


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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[] a = new double[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
		}
		double[] c = new double[n];
		for (int i = 0; i < n; i++) {
			c[i] = sc.nextInt();
		}
		sc.close();

		Arrays.parallelSort(a);
		Arrays.parallelSort(c);

		long ans = 0L;
		for (int j = 0; j < n; j++) {
			long idxA = Arrays.binarySearch(a, b[j] - 0.1);
			idxA = ~idxA;
			long idxC = Arrays.binarySearch(c, b[j] + 0.1);
			idxC = ~idxC;
			ans += idxA * (n - idxC);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 94000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define sz(x) (ll)x.size()
int N = 2e5 + 5;

void solve_test_case(){
	string s,t,sub;
	cin>>s>>t;
	//ll ch = 0;
	ll ans = 1e9 + 5;
	for(auto i = 0;i < sz(s) - sz(t) + 1;++i){
		ll ch = 0;
		for(auto j = 0;j < sz(t);++j){
			if(s[i + j] != t[j]){
				ch++;
			}
		}
		ans = min(ans,ch);
	}
	cout<<ans<<'\n';
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	//cin>>t;
	for(int i = 1;i <= t;++i){
		solve_test_case();
	}
}


Measured memory_bytes: 3644
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int i = sc.nextInt();
        System.out.print(i*i);
    }
    
}

Measured memory_bytes: 22996
#include <stdlib.h>
#include <stdio.h>



int main(){
    int n;
    int *p;
    int gb;
    int *num;
    int buff;
    int j;
    int counter=1;
    int cost[101][101];

    scanf("%d",&n);
    p=malloc(sizeof(int)*n+2);
    num=malloc(sizeof(int)*n);
    scanf("%d",&p[1]);
    scanf("%d",&p[2]);
    for(int i=3;i<=n+1;i++){
        scanf("%d%d",&gb,&p[i]);
    }
    /*for(int i=1;i<=n+1;i++){
        printf("%d ",p[i]);
    }*/

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

    for(int d=1;d<=n;d++){
        for(int i=1;i<=n-d;i++){
            j=i+d;
            buff=cost[i][i]+cost[i+1][j]+p[i]*p[i+1]*p[j+1];
            for(int k=i;k<j;k++){
                if(cost[i][k]+cost[k+1][j]+p[i]*p[k+1]*p[j+1]<buff){
                    buff=cost[i][k]+cost[k+1][j]+p[i]*p[k+1]*p[j+1];
                }
            }
            cost[i][j]=buff;
        }
    }
    printf("%d\n",cost[1][n]);


    //printf("%d\n",cost[1][n]);

    /*for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            printf("%d ",cost[i][j]);
        }
        printf("\n");
    }*/
    return 0;
}


Measured memory_bytes: 2052
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
const int mo=998244353;
struct point {
  int x,y;
  point operator-(const point &a){
   return (point){x-a.x,y-a.y};
  }
  bool operator==(const point &a){
    return x==a.x && y==a.y;
  }
};

int cross(point a,point b){
  return a.x*b.y-a.y*b.x;
}

void add(int &x,int y){
  x+=y;
  if (x>=mo) x-=mo;
  if (x<0) x+=mo;
}

int dot(point a,point b){
  return a.x*b.x+a.y*b.y;
}
bool cmp(point a,point b){
   if (a.x==0 && b.x==0) return a.y<b.y;
   if (a.x==0) return 0;
   if (b.x==0) return 1;
   if (cross(a,b)==0) {
	 if (a.x*b.x<0) return a.x<b.x;
	 else return dot(a,a)<dot(b,b);
   }
   if (a.x<0) {a.x*=-1;a.y*=-1;}
   if (b.x<0) {b.x*=-1;b.y*=-1;}
   return cross(a,b)>0;
}
point p[210],t[210];
int p2[210];
int main()
{
    int i,j;
    int n;
    cin>>n;
    for (i=1;i<=n;i++) scanf("%d %d",&p[i].x,&p[i].y);
    p2[0]=1;
    for(i=1;i<210;i++) p2[i]=1ll*p2[i-1]*2%mo;
    int ans=p2[n];
    add(ans,-1-n);
    int cnt;
    for (i=1;i<=n;i++){
      cnt=0;
      for (j=1;j<=n;j++){
        if (j==i) continue;
        t[cnt++]=p[j]-p[i];
      }
      sort(t,t+cnt,cmp);
      int last=0;
      for (j=1;j<cnt;j++){
		if (cross(t[j-1],t[j])){
			if (t[last].x<0 || (t[last].x==0 && t[last].y<0)) {last=j;continue;}
			add(ans,-(p2[j-last+1]-(j-last+1)-1));
			last=j;
		}
      }
      if (cnt && !(t[last].x<0 || (t[last].x==0 && t[last].y<0))){
		add(ans,-(p2[j-last+1]-(j-last+1)-1));
      }
    }
    printf("%d\n",ans);
    return 0;
}


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

int main()
{
    int n = 5;
    LL ans = 0;
    LL mn = 1e18;
    LL N;
    cin >> N;
    LL x[n];
    for(int i = 0; i < n; i++){
        cin >> x[i];
        mn = min(x[i], mn);
    }
    ans = (N+mn-1)/mn;
    cout << (ans + 4) << endl;
    return 0;
}




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

int main(){
  int A,B,C;cin>>A>>B>>C;
  int count1,count2;
  count1=A*C;
  if(count1<=B)
  {
    cout<<C<<endl;
  }
  else
  {
    cout<<B/A<<endl;
  }
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var str=arr.shift();
   if(str=="0 0")break;
   var ary=str.split(" ").map(Number);
   var h=[];
   var w=[];
   for(var i=0;i<ary[0];i++)h.push(arr.shift()-0);
   for(var i=0;i<ary[1];i++)w.push(arr.shift()-0);
   var H={};
   for(var i=0;i<h.length;i++){
      var sum=0;
      for(var j=i;j<h.length;j++){
         if(j!=i)sum+=h[j];
         (H.hasOwnProperty(h[i]+sum))?H[h[i]+sum]++:H[h[i]+sum]=1;
      }
   }
   var W={};
   for(var i=0;i<w.length;i++){
      var sum=0;
      for(var j=i;j<w.length;j++){
         if(j!=i)sum+=w[j];
         (W.hasOwnProperty(w[i]+sum))?W[w[i]+sum]++:W[w[i]+sum]=1;
      }
   }
   var cnt=0;
   for(var k in H){
      if(W.hasOwnProperty(k))cnt+=H[k]*W[k];
   }
   console.log(cnt);
}

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

int N,M,X,Y;
int x[209],y[209];

int main(){
  cin >> N >> M >> X >> Y;
  for(int i=0;i<N;i++) cin >> x[i];
  for(int i=0;i<M;i++) cin >> y[i];

  sort(x,x+N);
  sort(y,y+M);

  bool ans=false;

  for(int z=-100;z<=100;z++){
    if(X<z && z<=Y && x[N-1]<z && z<=y[0]){
      ans = true;
    }
  }

  if(ans) cout << "No War" << endl;
  else cout << "War" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define INF 10000000
int main(){
	int n,m,ans,now;
	cin >> n; cin >> m;
	ans = m; now = m;
	for(int i=0;i<n;i++){
		int a,b; cin>> a >> b;
		now += a; now -= b;
		if(now < 0) ans = INF;
		else ans = max(ans,now);
	}
	if(ans == INF) cout << "0" << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 1160
using System;

class AOJ2197
{
    static void Main()
    {
        while (true)
        {
            int tgt = int.Parse(Console.ReadLine());
            if (tgt == 0) break;
            int to = tgt / 2+1;
            int c = 0;
            for (int i = 1; i < to; i++)
            {
                int cr = 0;
                for (int j = i; cr < tgt; j++)
                {
                    cr += j;
                    if (cr == tgt) c++;
                }
            }
            Console.WriteLine(c);
        }
    }
}

Measured memory_bytes: 5608
/*
 * 0298.cc: Bus Timetable
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;
const int MAX_M = 100;

/* typedef */

typedef vector<int> vi;

/* global variables */

int ams[MAX_N], bms[MAX_M];
vi ans;

/* subroutines */

/* main */

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int hi, mi;
    cin >> hi >> mi;
    ams[i] = hi * 60 + mi;
  }

  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int hi, mi;
    cin >> hi >> mi;
    bms[i] = hi * 60 + mi;
  }

  int ai = 0, bi = 0;
  while (ai < n && bi < m) {
    if (ams[ai] == bms[bi]) ans.push_back(ams[ai++]), bi++;
    else if (ams[ai] < bms[bi]) ans.push_back(ams[ai++]);
    else ans.push_back(bms[bi++]);
  }

  while (ai < n) ans.push_back(ams[ai++]);
  while (bi < m) ans.push_back(bms[bi++]);

  for (int i = 0; i < ans.size(); i++) {
    if (i) putchar(' ');
    printf("%d:%02d", ans[i] / 60, ans[i] % 60);
  }
  putchar('\n');
  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define int                 long long   
#define double              long double
#define endl                "\n"
#define pb                  push_back
#define PI                  3.1415926535897932384626433832795l
#define F                   first
#define S                   second
#define mp                  make_pair
#define f(i,n)              for(int i=0;i<n;++i)
#define loop(i,a,b)         for (int i=a ; i<b ;++i)
#define fastio              ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)              (v).begin(),(v).end()
#define rall(v)             (v).rbegin(),(v).rend()
#define gcd(a,b)            __gcd((a),(b))
#define fill(a,value)       memset(a,value,sizeof(a));
#define minn(v)             *min_element(v.begin(), v.end());
#define maxx(v)             *max_element(v.begin(), v.end());
#define print(x)            cout<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;
signed main() 
{
    fastio;
    string n;
    cin>>n;
    int a=0;
    for(auto p:n)
    {
        a+=p-'0';
        
    }
    if(a%9==0)print("Yes")
    else print("No")
    
    
    
    
    return 0;
    
    
}

Measured memory_bytes: 3708
#!/usr/bin/env python3


def main():
    m, k = list(map(int, input().split()))
    if k >= 2**m:
        print(-1)
        return
    if m == 0:
        if k == 0:
            print('0 0')
        else:
            print(-1)
        return
    if m == 1:
        if k == 0:
            print('1 0 0 1')
        else:
            print(-1)
        return
    result = [i for i in range(2**m) if i != k]
    b = list(map(str, result))
    c = reversed(b)
    print(' '.join(b), k, ' '.join(c), k)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21140
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int W = sc.nextInt();
		int H = sc.nextInt();
		int[] row = new int[H + 1];
		int[] col = new int[W + 1];
		for (int i = 0; i < N; ++i) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			int w = sc.nextInt();
			row[Math.max(0, y - w)]++;
			row[Math.min(H, y + w)]--;
			col[Math.max(0, x - w)]++;
			col[Math.min(W, x + w)]--;
		}
		boolean okRow = true;
		boolean okCol = true;
		int sum = 0;
		for (int i = 0; i < H; ++i) {
			sum += row[i];
			if (sum == 0) okRow = false;
		}
		sum = 0;
		for (int i = 0; i < W; ++i) {
			sum += col[i];
			if (sum == 0) okCol = false;
		}
		System.out.println(okRow || okCol ? "Yes" : "No");
	}

}

Measured memory_bytes: 98712
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

const int MAX=400010; //nCrのnのMAX+1
ll fac[MAX],finv[MAX],inv[MAX];

void cominit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll com(int n,int k){
  if (n<k) return 0;
  if (n<0||k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
//Add cominit(); in main function.

int main(){
  cominit();
  ll n,k; cin >> n >> k;
  if(k>=n-1){
    ll ans=com(n+n-1,n);
    cout << ans << endl;
    return 0;
  }
  ll ans=0;
  rep(i,k+1){
    if(i==0){ans+=1;continue;}
    ans+=com(n,i)*com(n-1,i)%mod;
    ans%=mod;
  }
  cout << ans << endl;
}

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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("C.in", "r", stdin);
	freopen ("C.out", "w", stdout);
#endif
}

const int N = 2e5 + 1e3;

int n, a[N];

long long ans, pre, sum;

int main () {

	File();

	n = read();
	For (i, 1, n)
		sum += (a[i] = read());
	ans = 1e18;

	For (i, 1, n - 1)
		pre += a[i], chkmin(ans, abs(sum - 2 * pre));
	printf ("%lld\n", ans);

	return 0;

}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define rep(i, n) for (int i = 0; i < n; ++i)
#define debug(s, param) std::cerr << s << param << std::endl;

using namespace std;
using ll = long long;

bool binarySearch(const std::vector<int>& s, int target) {
  int ok = (int)s.size();
  int ng = -1;

  while (ok - ng > 1) {
    int mid = (ok + ng) / 2;
    if (s[mid] == target) {
      return true;
    } else if (s[mid] > target) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  return false;
}

int main() {
  int n, q;
  cin >> n;
  vector<int> s(n, 0);
  rep (i, n) cin >> s[i];

  cin >> q;
  vector<int> t(q, 0);
  rep (i, q) cin >> t[i]; 

  int ans = 0;
  rep (i, q) {
    if (binarySearch(s, t[i])) ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3280
def divisor(x):
    i = 1
    d = []
    while i*i <= x:
        if x%i == 0:
            d.append(i)
            d.append(x//i)
        i += 1
    return d

n = int(input())
a = sorted(list(map(int,input().split())))

ans = 1
for i in range(2):
    for d in divisor(a[i]):
        ct = 0
        for j in a:
            if j%d == 0:
                ct += 1
        if ct >= n-1:
            ans = max(ans, d)

print(ans)


Measured memory_bytes: 63856
#include "bits/stdc++.h"
using ll = long long;
using namespace std;

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  int n;
  cin >> n;

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

  auto b = a;
  partial_sum(a.begin(), a.end(), b.begin(),
    [] (int x, int y) { return max(x, y);});

  ll ans = 0;
  for(int i = 0; i < n; ++i) {
    ans += b[i] - a[i];
  }

  cout << ans;
}


Measured memory_bytes: 4780
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  int n, f[100][10], p[100][11], ans = -(1e9 + 9);
  scanf("%d", &n);
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < 10; ++j)
      scanf("%d", &f[i][j]);
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < 11; ++j)
      scanf("%d", &p[i][j]);

  //cout << (1 << 11) << endl;
  for(int i = 1; i < (1 << 10); ++i) {
    int bit = i, cnt = 0, check = 0, profit[101] = {0};
    while(bit > 0) {
      if(bit % 2 == 1) {
        //if(i == 1024) cout << cnt << endl;
        for(int j = 0; j < n; ++j) profit[j] += f[j][cnt];
      }
      ++cnt;
      bit /= 2;
    }
    for(int j = 0; j < n; ++j) check += p[j][profit[j]];
    //if(check == 0) {      cout << i << endl;    }
    if(check > ans) ans = check;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
A, B, C, D, E, F = map(int, input().split())
answers = {}

for a in range(F//(100*A)+1):
    for b in range((F-a*100*A)//(100*B)+1):
        water = a * 100 * A + b * 100 * B
        if water == 0:
            continue

        for c in range((a*A+b*B)*E//C+1):
            for d in range(((a*A+b*B)*E-c*C)//D+1):
                sugar = c * C + d * D
                if sugar + water > F:
                    continue
                conc = 100 * sugar / (water + sugar)
                answers[conc] = [str(water+sugar), str(sugar)]

max_conc = max(answers)
print(' '.join(answers[max_conc]))


Measured memory_bytes: 4852
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define range_for(i, b, e) for(int i=(b), i##_len=(e); i<=i##_len; ++i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define pb push_back
# define len(x) ((int)(x).size())
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
# define LINT_MAX (LONG_LONG_MAX)
# define cauto const auto
using namespace std;
using lint = long long;
template <class Type> inline constexpr bool InRange(const Type& x, const Type& i, const Type& a) { return (i <= x) && (x <= a); }
template<class Integer>bool chmax(Integer &a, const Integer &b) { if (a<b) { a=b; return 1; } return 0; }
template<class Integer>bool chmin(Integer &a, const Integer &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Integer>bool IsOdd(Integer &n) { return n & 1; }
template<class Integer>bool IsEven(Integer &n) { return !(n & 1); }
int ctoi(const char c) { return ('0' <= c && c <= '9') ? (c - '0') : -1; }
string YesNo(bool b) { return b ? "Yes" : "No"; }
string YESNO(bool b) { return b ? "YES" : "NO"; }
string yesno(bool b) { return b ? "yes" : "no"; }
static const lint MOD9 = (lint)1e9+7;
int dy[4] = {0, 1, 0, -1};
int dx[4] = {1, 0, -1, 0};

// 整数の桁数を返す ( log(N) )
template <class Integer> Integer GetDigit(Integer n) {
    Integer d = 0;
    while (n) {
        n /= 10;
        d++;
    }
    return d;
}

// 素数かどうかを返す ( O(sqrt(N)) )
template <class Integer>
constexpr bool IsPrime(const Integer n) noexcept {
    if (n < 4) return n == 2 || n == 3;
    if (n % 2 == 0 || n % 3 == 0 || (n % 6 != 1 && n % 6 != 5)) return false;
    for (Integer i = 5; i * i <= n; i += 6) if (n % i == 0 || n % (i + 2) == 0) return false;
    return true;
}


int main()
{
    string N; cin >> N;
    cout << YesNo(count(ALL(N), '7')) << endl;

    return 0;
}



Measured memory_bytes: 3584
n = int(raw_input())

residence = []

for i in xrange(4):
  floor = []
  for j in xrange(3):
    room = []
    for k in xrange(10):
      room.append(0)
    floor.append(room)
  residence.append(floor)

i = 0
while i < n:
  line = map(int, raw_input().split(" "))
  residence[line[0] - 1][line[1] - 1][line[2] - 1] += line[3]
  # print "residence[%d][%d][%d] = %d" % (line[0] - 1, line[1] - 1, line[2] - 1, line[3])
  # print residence
  i += 1

secion_line = "####################"
for i in xrange(4):
  for j in xrange(3):
    output_line = ""
    for k in xrange(10):
      output_line += " " + str(residence[i][j][k])
    print output_line
  if i != 3:
   print secion_line

Measured memory_bytes: 6480
#include<iostream>
#include<vector> 
#include<map>
#include<algorithm> 
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>nums(n);
	map<int,int>rec;
	long long s=0;
	for(int i=0;i<n;++i){
		cin>>nums[i];
		s+=nums[i];
		++rec[nums[i]];
	}
	int q;
	cin>>q;
	for(int i=0;i<q;++i){
		int b,c;
		cin>>b>>c;
		s+=(c-b)*rec[b];
		rec[c]+=rec[b];
		rec[b]=0;
		cout<<s<<endl;
	}
	return 0;
}

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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(void){
  int x;
  cin >> x;
  int i=x;
  for(;;){
    if(IsPrime(i)) break;
    i++;
  }

  cout << i << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(x, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
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(){
  cout << fixed << setprecision(15);
  
  int l, h, x; cin >> l >> h >> x;
  int v = l * l * h - x;
  
  double ans;
  if (v <= x){
  	double a = l;
  	double s = (double)v / l;
  	double b = s * 2 / a;
  	ans = 180 * atan(b / a) / M_PI;
  }
  else{
    double b = h;
    double s = (double)x / l;
    double a = s * 2.0 / b;
    ans = 90 - 180 * atan(a / b) / M_PI;
  }
  cout << ans << endl;
}

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

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

    vector<int64_t> lr(n+1, 0);

    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        lr[l]++, lr[r+1]--;
    }

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

    cout << count(lr.begin(), lr.end(), m) << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#define INF 1000000000
#define MAX_N 300000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
bool used[MAX_N];
vector<int> G[MAX_N];
int tree_dfs(int v,int& last_v,int& leng_v,int cnt){
  used[v]=true;
  if(leng_v<cnt){
    leng_v = cnt;
    last_v = v;
  }
  int res=cnt,tmp;
  for(auto to:G[v]){
    if(!used[to]){
      tmp = tree_dfs(to,last_v,leng_v,cnt+1);
      res = max(tmp,res);
    }
  }
  return res;
}
ll tree_size(int n,vector<int> G[],bool used[]){
  int u,nu,lv;
  fill(used,used+n,false);
  u=lv=0;
  tree_dfs(0,u,lv,0); 
  lv=0;
  nu = u;
  fill(used,used+n,false);
  return tree_dfs(u,nu,lv,0); 
}
signed main(){
  int n;
  cin >> n;
  ll a[n],b[n];
  for(int i=0;i<n-1;i++){
    cin >> a[i]>>b[i];
    a[i]--;
    b[i]--;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }
  ll v=tree_size(n,G,used);
  if(v%3==1){
    cout <<"Second\n";
  }else{
    cout <<"First\n";
  }
}


Measured memory_bytes: 29312
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600
#define long long long // for codeforces

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

  int head = 0;
  int crnt=0;
  for(auto c : s){
    if(c=='('){
      crnt++;
    } else {
      if(crnt==0) head++;
      else crnt--;
    }
  }

  rep(i,head) cout<<"(";
  cout << s;
  rep(i,crnt) cout << ")";
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N;
double x;
string u;
double unit;

int main(){
  cin >> N;
  double sum = 0;
  
  for(int i = 0; i < N; i++){
    cin >> x >> u;
    if(u == "JPY"){
      unit = 1;
    }else{
      unit = 380000.0;
    }
    
    sum += x*unit;
  }
  
  cout << sum << '\n';
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	
	const int MB = 64;
	public void Solve(){
		
		int sum = A.Sum();
		Array.Sort(A);
		
		int NN = (sum + 1  + MB - 1) / MB;
		ulong[] dp = new ulong[NN + 1];
		dp[0] = 1;
		for(int i=0;i<N;i++){
			ulong[] ndp = new ulong[NN + 1];
			int nj = A[i] / MB;
			int nb = A[i] % MB;
			for(int j=0;j + nj + 1 <= NN;j++){
				ndp[j] |= dp[j];
				ndp[j + nj] |= dp[j] << nb;
				if(nb > 0) ndp[j + nj + 1] |= dp[j] >> (MB - nb);
			}
			dp = ndp;
//Console.WriteLine(String.Join(" ",dp.Select(v => String.Format("{0:X}",v))));
		}
		int trgt = sum %2 == 0 ? sum / 2: (sum / 2 + 1);
		for(int k = trgt ;k <= sum; k++){
			int ii = k / MB;
			int jj = k % MB;
			if(((dp[ii] >> jj) & 1 ) == 1){
				Console.WriteLine(k);
				return;
			}
		}
		
		
	}
	int N;
	int[] A;

	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

typedef long long ll;

const int Maxn = 1005;

int n;
ll a[Maxn];
vector <int> res;
int my;

void Apply(int ind)
{
	res.push_back(ind);
	if (ind == 1) {
		for (int i = 1; i <= n - 1; i++)
			a[i] = a[i + 1];
		n--;
		my = 1 - my;
	} else if (ind == n) n--;
	else {
		a[ind - 1] += a[ind + 1];
		for (int i = ind; i <= n - 2; i++)
			a[i] = a[i + 2];
		n -= 2;
	}
}

void Solve()
{
	while (n > 1) {
		bool was = false;
		for (int i = 1; i <= n; i++)
			if (a[i] < 0 && i % 2 == my) { Apply(i); was = true; break; }
		if (was) continue;
		if (my == 0) Apply(1);
		else Apply(2);
	}
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int num; scanf("%d", &num);
		a[i] = num;
	}
	bool spec = true;
	int mx = 1;
	for (int i = 1; i <= n && spec; i++) {
		spec = a[i] < 0;
		if (a[i] > a[mx]) mx = i;
	}
	if (spec) {
		cout << a[mx] << endl;
		for (int i = n; i > mx; i--)
			Apply(i);
		for (int i = 1; i < mx; i++)
			Apply(1);
		printf("%d\n", int(res.size()));
		for (int i = 0; i < res.size(); i++)
			printf("%d\n", res[i]);
		return 0;
	}
	ll res1 = 0;
	for (int i = 1; i <= n; i += 2) if (a[i] >= 0)
		res1 += a[i];
	ll res2 = 0;
	for (int i = 2; i <= n; i += 2) if (a[i] >= 0)
		res2 += a[i];
	if (res1 >= res2) my = 1;
	else my = 0;
	Solve();
	cout << a[1] << endl;
	printf("%d\n", int(res.size()));
	for (int i = 0; i < res.size(); i++)
		printf("%d\n", res[i]);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
	char str[101];
	int n, temp;
	while (1){
		scanf("%d", &n);
		if (n == 0) break;
		scanf("%s", str);
		int p[10] = {0}, ba = 0;
		for (int i = 0; i < 100; i++){
			if (str[i] == 'M'){
				p[i%n] += 1;
			}else if (str[i] == 'S'){
				ba = ba + p[i%n] + 1;
				p[i%n] = 0;
			}else if (str[i] == 'L'){
				p[i%n] = ba + p[i%n] + 1;
				ba = 0;
			}
		}
		sort(p, p + n);
		for (int i = 0; i < n; i++){
			printf("%d ", p[i]);
		}
		printf("%d\n", ba);
	}
	return 0;
}

Measured memory_bytes: 1208
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 k = sc.nextInt();
        for (int i = a; i <= Math.min(b, a + k - 1); i++) {
            System.out.println(i);
        }
        for (int i = Math.max(b - k + 1, a + k); i <= b; i++) {
            System.out.println(i);
        }
    }
}

Measured memory_bytes: 23764
#include<iostream>
using namespace std;
#include<stdio.h>

int *A;
int H;

void max_heapify(int i)
{
    int l = 2 * i, r = 2 * i + 1;
    if(l > H && r > H) return;
    int maxid = i, x;
    if(l <= H) maxid = (A[l] > A[maxid] ? l : maxid);
    if(r <= H) maxid = (A[r] > A[maxid] ? r : maxid);
    if(maxid == i) return;
    x = A[maxid]; A[maxid] = A[i]; A[i] = x;
    max_heapify(maxid);
}

void BuildMaxHeap()
{
    for(int i = H / 2; i > 0; i--) max_heapify(i);
    return;
}

int main()
{
    scanf("%d", &H);
    A = new int[H + 1];
    for(int i = 1; i <= H; i++) scanf("%d", &A[i]);
    BuildMaxHeap();
    for(int i = 1; i <= H; i++) printf(" %d", A[i]);
    printf("\n");
    delete [] A;
    return 0;
}

Measured memory_bytes: 3112
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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 P(ll n, ll r){
  if(n < r) return 0;
  ll res = 1, num = n;
  rep(i, r){
    res = (res * num) % MOD;
    num--;
  }
  return res % MOD;
}

int n, k;
vector<vector<int>> G;

void rec(int v, int p, ll &res, int depth) {
    int chs = 0;
    for (auto ch : G[v]) {
        if (ch == p) continue;
        ++chs;
        rec(ch, v, res, depth+1);
    }
    if (depth == 0) res = res * P(k-1, chs) % MOD;
    else res = res * P(k-2, chs) % MOD;
}

int main(){ 
    cin >> n >> k;
    G.resize(n);
    rep(i, n-1){
      int a, b; cin >> a >> b; a--; b--;
      G[a].push_back(b);
      G[b].push_back(a);
    }

  ll res = k;
  rec(0, -1, res, 0);
  cout << res << ln;
}


Measured memory_bytes: 11520
#include<stdio.h>
int main(){
  int a,y,n,t,T,money=100000;
  scanf("%d",&n);
  for(a=0;a<n;a++){
    money=money+money/100*5;
    y=money%1000;
    money=money/1000;
    if(y>=1){
      money=money+1;
    }
    money=money*1000;
  }
  printf("%d\n",money);
  return (0);
}

Measured memory_bytes: 592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	private static final int BIG_NUM  = 2000000000;
	private static final int MOD  = 1000000007;

	private static int N,K;
	private static int array[];

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {

			String tmp_str[] = br.readLine().split("\\s+");
			N = Integer.parseInt(tmp_str[0]);
			K = Integer.parseInt(tmp_str[1]);

			array = new int[N];

			for(int i = 0; i < N; i++){
				array[i] = Integer.parseInt(br.readLine());
			}

			int left = 0,right = 100000*10000,m = (left+right)/2;
			int ans = 100000*10000;

			while(left <= right){

				if(check(m)){
					ans = m;
					right = m-1;
				}else{
					left = m+1;
				}
				m = (left+right)/2;
			}

			System.out.println(ans);

		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static boolean check(int P){

		int item = 0,truck = 0,tmp_sum;

		while(item < N && truck < K){
			tmp_sum = 0;
			while(item < N && tmp_sum + array[item] <= P){
				tmp_sum += array[item];
				item++;
			}
			truck++;
		}

		if(item == N){
			return true;
		}else{
			return false;
		}
	}
}




Measured memory_bytes: 35280
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int main() {
    int N;
    cin >> N;
    long long bucket[100050];
    for(int i = 0; i < 100050; i++){
        bucket[i] = 0;
    }
    for(int i = 0; i < N; i++){
        long long tmp;
        cin >> tmp;
        bucket[tmp]++;
    }
    long long evenCount = 0;
    long long typeCount = 0;
    for(int i = 0; i < 100050; i++){
        if(bucket[i] % 2 == 0 && bucket[i] != 0){
            evenCount++;
        }
        if(bucket[i] != 0){
            typeCount++;
        }
    }
    if(evenCount % 2 == 0){
        cout << typeCount << endl;
    }else{
        cout << typeCount - 1 << endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
  #define pb push_back
#define f first
#define s second
  #define MAXN 100005
using namespace std;
int n;
int arr[MAXN],dp[MAXN];
int solve(int i){
	if(i>=n) {
		return 1e9;
	}
	if(i==n-1) {
		return 0;
	}
	int cost1=abs(arr[i+1]-arr[i]);

	int cost2=abs(arr[i+2]-arr[i]);
	if(dp[i]!=-1) return dp[i];
	return dp[i]=min(cost1+solve(i+1),cost2+solve(i+2));
}
int main()
{
	std::ios::sync_with_stdio(false);

	cin>>n;
	mem(dp,-1);
	for(int i=0; i<n; i++) cin>>arr[i];
	cout<<solve(0)<<endl;

	return 0;
}


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

#define rep_(v, f, l) for (int v = (f); v < (l); ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int draw_line(int c)
{
    if (c == 0) return puts("-");
    rep(i, c) printf("*");
    return puts("");
}

int main()
{
    int n;
    while (n = in()){
        int ice[10] = {};
        rep(i, n){
            ice[in()]++;
        }
        rep(i, 10) draw_line(ice[i]);
    }
    return (0);
}

Measured memory_bytes: 1172
x = str(input())
lx = len(x)
num = lx - 2
if int(x) >= 100:
    head = int(x[:num])
    body = int(x[num:])
    up = head * 5
    ans = int(0)
    if body <= up:
        ans = 1
    else:
        ans = 0
else:
    ans = 0
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

int cnt[100'000];

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    for (int i = 0; i < n; i++)
    {
        cnt[i] = 0;
    }

    int rnum = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'R')
        {
            rnum++;
        }
        else
        {
            cnt[i] += rnum / 2;
            cnt[i - 1] += rnum - (rnum / 2);
            rnum = 0;
        }
    }

    int lnum = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        if (s[i] == 'L')
        {
            lnum++;
        }
        else
        {
            cnt[i] += lnum / 2;
            cnt[i + 1] += lnum - (lnum / 2);
            lnum = 0;
        }
    }

    for (int i = 0; i < n; i++)
    {
        cout << cnt[i] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main() {
	for (;;) {
		int t, n;

		scanf("%d", &t);

		if (t == 0)
			return 0;

		scanf("%d", &n);

		for (int i = 0; i < n; i++) {
			int j, k;
			scanf("%d", &j);
			scanf("%d", &k);
			t -= k - j;
		}

		if (t <= 0)
			printf("OK\n");
		else
			printf("%d\n", t);
	}
	
	return 0;
}

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

using namespace std;

const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 2;

int n, cnt1[62], cnt0[62];
long long a[N];

long long add (long long a, long long b)
{
    long long c = a + b;
    while (c >= mod) c -= mod;
    return c;
}

long long binpow (long long a, long long n)
{
    if (n == 0) return 1;
    if (n % 2 == 0)
    {
        long long b = (binpow(a, n / 2)) % mod;
        return (b * b) % mod;
    }
    else
    {
        long long  b = (binpow(a, n - 1)) % mod;
        return (b * a) % mod;
    }
}

int main ()
{
    scanf ("%d", &n);
    for (int i = 1; i <= n; ++i) scanf ("%lld", a + i);
    long long sum = 0;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 0; j < 60; ++j)
        {
            if (cnt1[j] > 0 && !((a[i] >> j) & 1))
            {
                long long lg = binpow(2, j);
                long long cur = (lg * cnt1[j]) % mod;
                sum = add(sum, cur);
            }
            else if (cnt0[j] > 0 && ((a[i] >> j) & 1))
            {
                long long lg = binpow(2, j);
                long long cur = (lg * cnt0[j]) % mod;
                sum = add(sum, cur);
            }
        }
        for (int j = 0; j < 60; ++j)
        {
            if ((a[i] >> j) & 1) cnt1[j]++;
            else cnt0[j]++;
        }
    }
    printf ("%lld\n", sum);
    return 0;
}


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

struct qwq
{
	int a, b;
	
	inline bool operator < (const qwq &x) const
	{
		return a < x.a;
	}
}x[100005];

priority_queue<int> q;

int main()
{
	int n, m, i, j = 1, s = 0;
	scanf("%d%d", &n, &m);
	
	for(int i = 1; i <= n; i++)
		scanf("%d%d", &x[i].a, &x[i].b);
	
	sort(x + 1, x + n + 1);
	
	for(int i = 1; i <= m; i++)
	{
		for(;x[j].a == i && j <= n; j++)
			q.push(x[j].b);
		
		if(!q.empty())
		{
			s += q.top();
			q.pop();
		}
	}
	
	printf("%d", s);
	return 0;
}

Measured memory_bytes: 1660
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		
		// 入出力高速化 java.io.* とthrows IOExceptionを忘れずに
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int N = Integer.parseInt(br.readLine());
		String[] S =br.readLine().split(" ") ;
		
		//灰=0、茶=1、緑=2、水=3、青=4、黄=5、橙=6、赤=7
		int[]Rate = new int[8];
		int top = 0;
		
		for(int i=0; i<N; i++) {
			int a = Integer.parseInt(S[i]);
			if(a<=399) {Rate[0]++;}
			if(400<=a && a<=799) {Rate[1]++;}
			if(800<=a && a<=1199) {Rate[2]++;}
			if(1200<=a && a<=1599) {Rate[3]++;}
			if(1600<=a && a<=1999) {Rate[4]++;}
			if(2000<=a && a<=2399) {Rate[5]++;}
			if(2400<=a && a<=2799) {Rate[6]++;}
			if(2800<=a && a<=3199) {Rate[7]++;}
			if(3200<=a) {top++;}
		}
		
		int min = 0;
		int Max = 0;
		
		for(int m=0; m<8; m++) {
			if(Rate[m] != 0) {
				min++;
				Max++;
			}
		}

		Max = min+top;
		if(min == 0) {//全て3200以上
			min++;
		}
		
		System.out.println(min + " " + Max);	
	}
}

Measured memory_bytes: 36700
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
	int n;
	cin>>n;
	for(int i=1;i<=9;i++)
	{
		if(n%i==0)
		{
			int d=n/i;
			if(d>=1&&d<=9)
            {cout<<"Yes";
            return ;}
		}
	}
	cout<<"No";
}
int main()
{
//code
int t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 3628
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int h,w;
  cin >> h >> w;

  vector<string> s(h);
  REP(i,h) cin >> s[i];

  int ans = 0;
  
  REP(i,h){
    REP(j,w){
      REP(x,h){
        REP(y,w){
          if(s[i][j] != 'B' || s[x][y] != 'B') continue;
          ans = max(ans,abs(i-x)+abs(j-y));
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3256