akhauriyash/Code-Regression huggingface dataset:
// ABC051A - Sum of Three Integers

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

int main() {
	int K, S;
	cin >> K >> S;

	int ans = 0;
	for (int x = 0; x <= K; x++) {
		for (int y = 0; y <= K; y++) {
			int temp = S - x - y;
			if ((0 <= temp)&&(temp <= K)) {
				ans++;
			}
		}
	}
	// 単純に3重ループで回すとTLEとなった。
	// https://atcoder.jp/contests/abc051/submissions/11396285

	cout << ans << endl;

	return 0;
}


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

signed main(){

  int n;
  cin>>n;
  using ll = int64_t;
  vector<ll> a(n);
  for(auto& ai:a)cin>>ai;

  vector<ll> b(n);
  for(int i=0;i<n;++i)b[i]=a[i]-i;

  auto solve = [&](ll b){
    ll res = 0;
    for(int i=0;i<n;++i)res+=abs(a[i]-(b+i+1));
    return res;
  };

  sort(begin(b),end(b));
  ll ans = 1LL<<50;
  for(int i=0;i<=2&&n/2+i<n;++i)for(int j=-2;j<=2;++j)ans = min(ans,solve(b[n/2+i]+j));
  for(int i=0;i<=2&&n/2-i>=0;++i)for(int j=-2;j<=2;++j)ans = min(ans,solve(b[n/2-i]+j));
  cout<<(ans)<<endl;

}

Measured memory_bytes: 3328
#include<stdio.h>

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


Measured memory_bytes: 2052
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    ans = 0
    storage = -1
    for i in range(N):
        ans = ans + B[A[i] - 1]
        if storage + 1 == A[i]:
            ans = ans + C[storage - 1] 
        storage = A[i]
    print(ans)
main()  

Measured memory_bytes: 9088
#include <cstdio>

using namespace std;

int parent[2500];

int Find(int x){
    if(parent[x] != x) parent[x] = Find(parent[x]);
    return parent[x];
}

void Union(int x, int y){
    x = Find(x); y = Find(y);
    parent[x] = y;
}

int main(){
    int n,m;
    int M[50][50];
    
    while(true){
        scanf("%d %d",&m,&n);
        
        if(n == 0) break;
        
        for(int i = 0;i < n;++i)
            for(int j = 0;j < m;++j)
                scanf("%d",&M[i][j]);
        
        for(int i = n*m - 1;i >= 0;--i)
            parent[i] = i;
        
        for(int i = 0;i < n;++i)
            for(int j = 0;j < m;++j)
                if(M[i][j] == 1)
                    for(int dr = -1;dr <= 1;++dr)
                        for(int dc = -1;dc <= 1;++dc)
                            if(i + dr >= 0 && i + dr < n && j + dc >= 0 && j + dc < m && M[i + dr][j + dc] == 1)
                                Union(m * i + j, m * (i + dr) + j + dc);
        
        int ans = 0;
        
        for(int i = 0;i < n;++i)
            for(int j = 0;j < m;++j)
                if(M[i][j] == 1 && Find(m * i + j) == m * i + j)
                    ++ans;
        
        printf("%d\n",ans);
    }
    
    return 0;
}

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

int main(){
  int n,r; cin >> n >> r;
  if(n>=10) cout << r << endl;
  else cout << r+(100*(10-n)) << endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int k; string s;
    cin >> k >> s;
    if(s.size() <= k) cout << s << endl;
    else
    {
        cout << s.substr(0, k) << "..." << endl;
    }
    
}

Measured memory_bytes: 3148
{-# LANGUAGE TypeApplications #-}

import           Control.Monad
import           Control.Applicative
import           Data.List
import           Data.Char
import           Control.Arrow
import           Data.Bits


main = do
  [a, b] <- map (read @Int . filter (/= '.')) . words <$> getLine
  print $ a * b `div` 100


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

int main() {
    int n, a[100], b[100], ans=0, res;
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> a[i];
    }
     for(int i=0; i<n; i++) {
        cin >> b[i];
    }

    for(int i=0; i<n; i++) {
        res=0;
        for(int j=0; j<i; j++) {
            res+=a[j];
        }
        for(int j=i+1; j<n; j++) {
            res+=b[j];
        }
        res+=a[i];
        res+=b[i];
        ans=max(ans, res);
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long  
#define PI 3.14159265358979323846
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb emplace_back
#define watch5(a,b,c,d,e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d << " | "<<#e<<": "<<e<<endl;
#define watch4(a,b,c,d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define watch3(a,b,c) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<endl;
#define watch2(a,b) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<< endl;
#define watch(a) cerr <<#a<<": "<<a<<endl;
#define F first
#define S second
#define mod 1073741824
using namespace std;

int32_t main(){
	IOS
	string n;
	cin >> n;
	int sum = 0;
	for(int i = 0; i < n.size(); i++){
		sum += (n[i] - '0');
	}
	if(sum % 9 == 0){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
}																				

Measured memory_bytes: 3724
pub struct Scanner {
	handle: std::io::Stdin,
	buffer: std::collections::VecDeque<String>
}

impl Scanner {
	pub fn new() -> Scanner {
		Scanner {
			handle: std::io::stdin(),
			buffer: std::collections::VecDeque::new()
		}
	}
	pub fn next<T: std::str::FromStr>(&mut self) -> Result<T, T::Err> {
		if self.buffer.len() == 0 {
			loop {
				let mut available = String::new();
				self.handle.read_line(&mut available).unwrap();
				self.buffer = available.split_whitespace().map(String::from).collect();
				if self.buffer.len() > 0 {
					break;
				}
			}
		}
		T::from_str(&self.buffer.pop_front().unwrap())
	}
}

fn gcd(m: i64, n: i64) -> i64 {
	if m == 0 {
		n
	} else {
		gcd(n % m, m)
	}
}

fn two_p(p: i64) -> i64 {
	if p == 0 {
		1
	} else {
		(2 * two_p(p - 1)) % 1000000007
	}
}

fn main() {
	let mut scanner = Scanner::new();
	let n: i64 = scanner.next().unwrap();
	let mut size = std::collections::HashMap::<(i64,i64,i64),i64>::new();
	let mut zero_total: i64 = 0;
	for _ in 0..n {
		let mut a: i64 = scanner.next().unwrap();
		let mut b: i64 = scanner.next().unwrap();
		if a == 0 && b == 0 {
			zero_total = (zero_total + 1) % 1000000007;
			continue;
		}
		let mut sign = 1;
		if a < 0 {
			sign *= -1;
			a *= -1;
		}
		if b < 0 {
			sign *= -1;
			b *= -1;
		}
		sign = if a == 0 {
			-1
		} else if b == 0 {
			1
		} else {
			sign
		};
		let g = gcd(a as i64,b as i64);
		let s = size.entry((sign,(a as i64)/g,(b as i64)/g)).or_insert(0);
		*s += 1;
	}
	let mut total: i64 = 1;
	for (k1,v1) in size.iter() {
		match size.get(&(-k1.0,k1.2,k1.1)) {
			Some(v2) => {
				if k1.0 > 0 {
					total = (total * ((two_p(*v1) + two_p(*v2) - 1) % 1000000007)) % 1000000007;
				}
			}
			None => total = (total * two_p(*v1)) % 1000000007
		}
	}
	total = ((total + zero_total - 1) % 1000000007 + 1000000007) % 1000000007;
	println!("{}", total);
}


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

int main()
{
    int H, W;
    cin >> H >> W;
    string line;
    vector<vector<char>> MAP(H, vector<char>(W));
    vector<int> tate(W), yoko(H);
    bool flag = true;
    for (int h = 0; h < H;h++){
        cin >> line;
        flag = true;
        for (int w = 0; w < W;w++){
            MAP.at(h).at(w) = line.at(w);
            if (line.at(w)=='#'){
                flag = false;
            }
        }
        if (flag){
            yoko.at(h) = 1;
        }
    }
    for (int w=0;w<W;w++){
        flag=true;
        for (int h=0;h<H;h++){
            if (MAP.at(h).at(w)=='#'){
                flag = false;
                break;
            }
        }
        if (flag){
            tate.at(w)=1;
        }
    }
    for (int h = 0; h < H;h++){
        for (int w = 0; w < W;w++){
            if (tate.at(w)==0 && yoko.at(h)==0){
                cout << MAP.at(h).at(w);
            }
        }
        if (yoko.at(h)==0){
            cout << endl;
        }
    }
}

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

d = {}

for i in range(N - 1):
    if A[i] in d:
        d[A[i]].append(i + 2)
    else:
        d[A[i]] = [i + 2]

for i in range(1, N + 1):
    if i in d:
        print(len(d[i]))
    else:
        print(0)

Measured memory_bytes: 52584
n,m,q = map(int,input().split())
abcd = [list(map(int,input().split())) for _ in range(q)]
ans = 0
for a in range(1,m+1):
  for b in range(a,m+1):
    for c in range(b,m+1):
      for d in range(c,m+1):
        for e in range(d,m+1):
          for f in range(e,m+1):
            for g in range(f,m+1):
              for h in range(g,m+1):
                for i in range(h,m+1):
                  for j in range(i,m+1):
                    lst = [0,a,b,c,d,e,f,g,h,i,j]
                    s = 0
                    for l in range(q):
                      s += abcd[l][3]*(lst[abcd[l][1]]-lst[abcd[l][0]]==abcd[l][2])
                    ans = max(ans, s)
print(ans)

Measured memory_bytes: 72640
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

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

int main(){
  int a,b;
  cin >> a >> b;
  if(13<=a) cout<< b <<endl;
  else if(6<=a && a<=12) cout<< b/2 <<endl;
  else cout<< 0 <<endl;
}


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	// debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, left, right)  (a).begin()+(left),(a).begin()+(right)	// left to (right-1)

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

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n + 1);
	FOR(i, 1, n) {
		cin >> a[i];
	}
	ll res = GCD(a[1], a[2]);
	FOR(i, 3, n) {
		res = GCD(res, a[i]);
	}
	pv(res)
	return 0;
}

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

const int INF = 1 << 30;

vector<vector<int> > bucket(50, vector<int>(26, 0));
vector<int> a(26, INF);

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		string s;
		cin >> s;
		for(auto c: s)
			bucket[i][c - 'a']++;
	}
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 26; j++) {
			a[j] = min(a[j], bucket[i][j]);
		}
	}
	for(int i = 0; i < 26; i++) {
		if(a[i] != INF) {
			for(int j = 0; j < a[i]; j++)
				printf("%c", i + 'a');
		}
	}
	printf("\n");
}


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

int main() {
  char a[10];
  rep(i,9){
    cin >> a[i];
  }
  cout << a[0] << a[4] << a[8];
}

Measured memory_bytes: 3600
n = int(input())
x = []
l = []
c = []
d = {}
 
for i in range(n):
    xx,ll = map(int, input().split())
    x.append(xx)
    l.append(ll)
    d[xx] = ll
 
 
dct = sorted(d.items())
 
f = 0
ans = 0
f = dct[0][0] + dct[0][1]
for i in range(1,len(dct)):
    if f > dct[i][0] - dct[i][1]:
        ans += 1
        f = min(f,dct[i][0]+dct[i][1])
    else:
        f = dct[i][0]+dct[i][1]
 
 
print(n-ans)


Measured memory_bytes: 25120
#include<stdio.h>
int main(void)
{
	int a,b,c;

	scanf("%d %d %d",&a,&b,&c);
	if(a==b && a==c && b==c ){
		printf("No");
	}
	else if(a!=b && b!=c && c!=a){
		printf("No");
	}
	else
		printf("Yes");
	return 0;
}

Measured memory_bytes: 128
N = int(input())
list_A = list(map(int, input().split()))

hight = 0
ans = 0

for i in range(len(list_A)):
    if i == 0:
        hight = list_A[i]
    elif list_A[i] > hight:
        hight = list_A[i]
    elif list_A[i] < hight:
        ans += hight - list_A[i]

print(ans)

Measured memory_bytes: 32248
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;

 
const int MAX_N = int(1e6) + 10;
long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 
 
inline ll mul(ll a,ll b){
 
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}
 
  
 
 
#define all(x) (x).begin(),(x).end()




//s.reserve(32768); //updated !
//s.max_load_factor(0.25);





int main(){
   
   ll a;
   string b;
   cin>>a>>b;
   ll bb=0;
   int indx=(int)b.size();
   ll ans=1;
   for(int i=0;i<b.size();i++){
    if(b[i]=='.')indx=i;
   }

   for(int i=0;i<indx;i++){
    bb=bb*10+(b[i]-'0');
   }

   for(int i=indx+1;i<b.size();i++){
    bb=bb*10+(b[i]-'0');
    ans=ans*10LL;
   }

   ans=(a*bb)/ans;

   cout<<ans<<endl;
   
    
}


 
    



    



    
    
    




    


    

    






    
    

    
 
    
 

 
 
    
 
 


Measured memory_bytes: 3556
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k;
  int a[102],m,n;
  string s;
  for(;;){
    cin>>m>>n;
    if(m+n==0)
      break;
    memset(a,0,sizeof(a));
    for(i=0;i<n;i++){
      cin>>s;
      if(s[0]=='A'){
	for(j=1;a[j];j++);
	a[j]=1;
      }else if(s[0]=='B'){
	for(j=m;j>0;j--){
	  if(a[j-1]!=1&&a[j]==0&&a[j+1]!=1){
	    a[j]=2;
	    break;
	  }
	}
	if(j==0){
	  for(j=1;a[j];j++);
	  a[j]=2;
	}
      }else if(s[0]=='C'){
	for(j=1;j<m+1&&a[j]==0;j++);
	if(j==m+1)
	  a[m/2+1]=3;
	else{
	  for(j=1;;j++){
	    	for(;a[j]==0;j++);
		if(j!=m&&a[j+1]==0){
		  a[j+1]=3;
		  break;
		}else if(j!=1&&a[j-1]==0){
		  a[j-1]=3;
		  break;
		}
	  }
	}
      }else if(s[0]=='D'){
	for(j=1;j<m+1&&a[j]==0;j++);
	if(j==m+1)
	  a[1]=4;
	else{
	  int p=0,d;
	  for(j=1;a[j]==0;j++);
	  if(j>2){
	    d=j-2;
	    p=1;
	  }
	  for(;;){
	    for(k=j+1;k<m+1&&a[k]==0;k++);
	    if(k==m+1){
	      if(k-j>2){
		if(p==0||d<k-j-2){
		  d=k-j-2;
		  p=m;
		}
	      }
	      break;
	    }else{
	      if(k-j>3){
		if(p==0||d<(k-j)/2-1){
		  d=(k-j)/2-1;
		  p=j+(k-j)/2;
		}
	      }
	    }
	    j=k;
	  }
	  if(p)
	    a[p]=4;
	  else{
	    for(j=1;a[j];j++);
	    a[j]=4;
	  }
	}	    
      }
    }
    for(i=1;i<m+1;i++){
      if(a[i])
	cout<<(char)(a[i]-1+'A');
      else
	cout<<"#";
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
int fibonacci(int n,int *x){
  int i;
  x[0]=1;
  x[1]=1;
  for(i=2;i<=n;i++){
    x[i]=x[i-2]+x[i-1];
  }
  return x[n];
}
int main(){
  int n,i,j;
  int *f;
  scanf("%d",&n);
  f=(int *)malloc(n *sizeof(int));
  j=fibonacci(n,f);
  printf("%d\n",j);
  return 0;
}



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

// using mint = modint1000000007;
// using mint = modint998244353;

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
// const Int mod = 1e9+7;
const Int mod = 998244353;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

Int dp[200002];

void solve() {
    Int n, k;
    cin >> n >> k;
    vector<Int> l(n), r(n);
    for (Int i = 0; i < k; i++) {
        cin >> l[i] >> r[i];
        r[i]++;
    }
    dp[0] = 1;
    for (Int i = 0; i < n; i++) {
        for (Int j = 0; j < k; j++) {
            if (l[j] > i) continue;
            Int add = dp[i - l[j]];
            if (r[j] <= i) {
                add = (add - dp[i - r[j]] + mod) % mod;
            }
            //print(i, j, add);
            dp[i] = (dp[i] + add) % mod;
        }
        dp[i] = (dp[i] + dp[i - 1]) % mod;
    }
    print((dp[n - 1] - dp[n - 2] + mod) % mod);
}

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


Measured memory_bytes: 8052
#include <iostream>
#include<vector>
#include<string>

using namespace std;


int main() {
	int A, B;
	string S;
	cin >> A >> B;
	cin >> S;
	for (int i = 0; i < A + B + 1; i++) {
		if (i == A && S[i] != '-') {
			cout << "No";
			return 0;
		}
		if (S[i] == '-' && i != A) {
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll bin(ll n, ll i) {
	if (i == 0) { return n % 2; }
	return bin(n / 2, i - 1);
}

ll beki(ll n) {
	if (n == 0) { return 1; }
	else { return 2 * beki(n - 1); }
}




int main() {

	
	ll N;
	ll K;
	cin >> N >> K;

	ll A[MAX];
	repn(i, N) cin >> A[i];

	ll ans = 0;

	int free = 0;

	for (ll t = 40; t >= 0; t--) {

		ll zero = 0;
		ll one = 0;

		repn(i, N) {
			if (bin(A[i], t) == 1) { one++; }
			else { zero++; }
		}

		if (free == 0 && bin(K, t) == 0) {
			ans += one * beki(t);
		}

		else {
			ll m = max(zero, one);
			ans += m * beki(t);
			if (m == one && bin(K, t) == 1) { free = 1; }
		}

	}

	cout << ans;

	system("PAUSE");
}

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

typedef struct{
 int x;
 int y;
}P;//表示坐标

char graph[1000][1000];
P aim[10];
P s,g;//s起点，g终点
int N,W,H;
int vis[1000][1000]; //用来存储距离
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

int bfs(P s,P g);

int main(){
    int i,j,t,step=0;
    cin>>H>>W>>N;
    
    for(i=0;i<H;i++)
    for(j=0;j<W;j++){
        cin>>graph[i][j];
      if(graph[i][j]<='9'&&graph[i][j]>='1'){ 
         t=graph[i][j]-'0';
         aim[t].x=i;
         aim[t].y=j;
      } //把1-N的坐标保存在 aim数组中 
      else if(graph[i][j]=='S'){
          s.x=i;
          s.y=j;
          graph[i][j]='.';
      }//得到最初的起点 
    }
    
    for(i=1;i<=N;i++){
       g.x=aim[i].x;
       g.y=aim[i].y;//1-N ，从小到大，每次把一个 作为终点 
       step+=bfs(s,g);
       s.x=g.x;
       s.y=g.y;//到达这个终点后变终点为起点 
       graph[g.x][g.y]='.';
    }
   
    cout<<step<<endl;
}

int bfs(P s,P g){
    queue<P> que;
      P n;
    
    for(int i=0;i<H;i++)
    for(int j=0;j<W;j++)
     vis[i][j]=-1;
     
     que.push(s);
     vis[s.x][s.y]=0;
     
     while(que.size()){
         
       P p=que.front();
         que.pop();
       if(p.x==g.x&&p.y==g.y)
       break;
       
       for(int i=0;i<4;i++){
           n.x=p.x+dx[i];
           n.y=p.y+dy[i];//向四方漫射 
        if(0<=n.x&&n.x<H&&0<=n.y&&n.y<W&&graph[n.x][n.y]!='X'&&vis[n.x][n.y]==-1){
               que.push(n);
               vis[n.x][n.y]=vis[p.x][p.y]+1;
           }
       }
   }
     return vis[g.x][g.y];
}


Measured memory_bytes: 7912
namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length == 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }

  async function slove() {
    const sc = new Scanner();
    const N = +(await sc.getLine());
    const ratio = 380000;
    let ans = 0;
    for (let i = 0; i < N; i++) {
      const [x, u] = (await sc.getLine()).split(' ');
      if (u === 'JPY') {
        ans += Number(x);
      } else {
        ans += Number(x) * ratio;
      }
    }
    console.log(ans);
    sc.close();
  }

  slove();
}


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

static const int MAX_NUM    = 100000;
static const int MAX_WEIGHT =  10000;
static const long long MAX_POWER = MAX_NUM * MAX_WEIGHT;

int main(void)
{
    int i;
    int car;
    int num_cabin;
    int num_car;
    int cabin[MAX_NUM];
    long long remain;
    int right, left, mid;

    scanf("%d", &num_cabin);
    scanf("%d", &num_car);

    for (i = 0; i < num_cabin; i++) {
        scanf("%d", &cabin[i]);
    }

    left  = 0;
    right = MAX_POWER;
    while (left <= right) {
        mid = (right + left) / 2;
        car    = 1;
        remain = mid;

        for (i = 0; i < num_cabin; i++) {
            if (remain >= cabin[i]) {
                remain -= cabin[i];
            }
            else {
                ++car;
                remain = mid - cabin[i];
                if (remain < 0) {
                    car = MAX_NUM + 1;
                    break;
                }
            }
        }
        if (left == right) {
            break;
        }
        if (car <= num_car) {
            right = mid;
        }
        else {
            left = mid + 1;
        }
    }

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

    return 0;
}

Measured memory_bytes: 1580
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	rep(i, n) cin >> p[i];
	double sum = 0.0;
	rep(i, k) sum += (p[i]+1.0) / 2.0;
	double mx = sum;
	for(int i = 1; i < n-k+1; i++){
		sum -= (p[i-1]+1.0) / 2.0;
		sum += (p[i+k-1]+1.0) / 2.0;
		if(mx < sum) mx = sum;
	}
	printf("%.10f\n", mx);
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;


int main(){
  ll n,k;cin>>n>>k;

  ll result = 0;
  ll fk = 0;
  ll lk=0;
  rep(i, k-1)fk += i;
  for(int i=n; i>n-k+1; i--)lk+=i;

  for(int i=k; i<=n+1; i++){
    fk += i-1;
    lk += n-i+1;
    ll c = lk-fk+1;
    result+=c;
    result %= MOD;
//    cout<<i<<' '<<fk<<' '<<lk<<endl;
  }

  cout<<result<<endl;

  return 0;
}


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


template <typename T>
struct BIT{
    int n;
    vector<T> d;

    BIT(int sz){
        n = sz+10;
        d.resize(n);
    }

    void add(int i, T x){

        while(i<=n){
            d[i] += x;
            i += i&-i;
        }
    }

    T getSum(int i){
        T ret = 0;

        while(i>0){
            ret += d[i];
            i -= i&-i;
        }
        return ret;
    }
};


int main(){
    int N,K; cin >> N >> K;
    vector<ll> a(N);
    rep(i,N){
        cin >> a[i];
        a[i] -= K;
    }

    vector<ll> sum(N+1);
    ll s = 0;
    rep(i,N){
        s += a[i];
        sum[i+1] = s;
    }

    vector<ll> sorted = sum;
    sort(sorted.begin(), sorted.end());
    sorted.erase(unique(sorted.begin(), sorted.end()), sorted.end());
    BIT<ll> bit(N);
    ll res = 0;
    rep(i,N+1){
        int idx = lower_bound(sorted.begin(), sorted.end(), sum[i]) - sorted.begin();
        res += bit.getSum(idx+1);
        bit.add(idx+1,1);
    }
    cout << res << endl;
}

Measured memory_bytes: 9568
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,a,b;
  cin >> n>>a >> b;
  if(n==1){
    if( a!=b){
      cout << 0<<endl;
      return 0;
    }
    else{
      cout << 1 <<endl;
      return 0;
    }
  }
  long ma =0;
  long mi =0;
  ma = (n-1)*b +a;
  mi = b +(n-1)*a;
  cout << (ma-mi+1>=0 ? ma-mi+1:0);
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
ll x,y,i;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>x>>y;
	for(i=1;i<=1e7;i++)if((i*x)%y!=0)rc(i*x);
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <deque>
using namespace std;
int main(){
    string s,t,u;
    int a,b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if(s==u){
        cout << a-1 << " " << b << endl;
    }else{
        cout << a << " " << b-1 << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int h,w;
		
		h=in.nextInt();
		w=in.nextInt();
		
		while(h!=0 || w!=0){
			for(int i=0; i<h; i++){
				for(int j=0; j<w; j++){
					if(i%2 == 0){
						if(j%2 == 0){
							System.out.print('#');
						}else{
							System.out.print('.');
						}
					}else{
						if(j%2 == 0){
							System.out.print('.');
						}else{
							System.out.print('#');
						}
					}
				}
				System.out.println();
			}
			
			System.out.println();
			h = in.nextInt();
			w = in.nextInt();
		}
	}
}

Measured memory_bytes: 27200
package main

import "fmt"

func main() {
	var H int
	fmt.Scan(&H)
	A := make([]int, H+1)
	for i := 1; i <= H; i++ {
		fmt.Scan(&A[i])
	}
	for i := 1; i <= H; i++ {
		fmt.Printf("node %d: key = %d, ", i, A[i])
		if i > 1 {
			fmt.Printf("parent key = %d, ", A[i/2])
		}
		if i*2 <= H {
			fmt.Printf("left key = %d, ", A[i*2])
		}
		if i*2+1 <= H {
			fmt.Printf("right key = %d, ", A[i*2+1])
		}
		fmt.Println()
	}
}



Measured memory_bytes: 1112
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;

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

	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N;
	LL max=0,ans=0;

	cin >> N;

	vector<LL> H(N);

	REP(i,N){
		cin >> H[i];
		if (max <= H[i]) {
			max = H[i];
			ans++;
		}

	}

	cout << ans <<endl;

	return 0;

}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int main(){
	int n, x;
	cin>>n>>x;
	if(x == 1 || x == 2*n-1){
		cout<<"No"<<endl;
		return 0;
	}
	deque<int> d;
	d.push_back(x);
	deque<int> q;
	rep(i, 2*n-1) if(i+1!=x) q.push_back(i+1);
	//cout<<"OK"<<endl;
	while(!q.empty()){
		int a = q.front(); q.pop_front();
		int b = q.back(); q.pop_back();
		d.push_front(a);
		d.push_back(b);
	}
	cout<<"Yes"<<endl;
	while(!d.empty()){
		cout<<d.front()<<endl;
		d.pop_front();
	}
}

Measured memory_bytes: 2304
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////
int main(){
    int a,b;
    cin>>a>>b;
    if(b%a==0)cout<<(a+b)<<endl;
    else{
        cout<<(b-a)<<endl;
    }
    

    return 0;
}

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

private static Scanner scanner;

public static void main(String args[])
{
	scanner = new Scanner(System.in);
	int a = scanner.nextInt();
	int[] b = new int[a];
	int count = 0,pre = 0;

	for(int i = 0;i < a;i++) {
		b[i] = scanner.nextInt();
		for(int j = 2;j <= Math.sqrt(b[i]);j++) {
			if(b[i]%j == 0) {
				count++;
				break;
			}
		}
		if(count == 0) {
			pre++;
		}
		count = 0;
	}
	System.out.println(pre);
}
}


Measured memory_bytes: 43092
#include <iostream>
using namespace std;
int main(){
	int n;
	int m;
	int a = 0, b = 0, c = 0, d = 0;
	for (int i = 0; i < 3; ++i){
		cin >> n;
		cin >> m;
		if(n==1){
			a++;
		}else if(n==2){
			b++;
		}else if(n==3){
			c++;
		}else if(n==4){
			d++;
		}
		if(m==1){
			a++;
		}else if(m==2){
			b++;
		}else if(m==3){
			c++;
		}else if(m==4){
			d++;
		}
	}
	
	if(a > 2 || b > 2 || c > 2 || d > 2){
		cout << "NO";
	}else{
		cout << "YES";
	}
	return 0;
}

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

using namespace std;

int main(void){
    int T,P,R;
    cin >> T >> P >> R;
    while(T){
        int tid, pid, tim;
        string mes;
        int wa[T+1][P+1];
        fill(wa[0], wa[T+1], 0);
        vector< pair< pair<int, int>, int> > result(T+1);
        for(int i=0;i<T+1;i++){
            result[i].first.first = 0;
            result[i].first.second = 0;
            result[i].second = i;
        }
        for(int i=0;i<R;i++){
            cin >> tid >> pid >> tim >> mes;
            if(mes[0] == 'C'){
                result[tid].first.second += wa[tid][pid] * 1200 + tim;
                result[tid].first.first--;
            }else{
                wa[tid][pid]++;
            }
        }

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

        for(int i=0;i<=T;i++){
            if(result[i].second == 0) continue;
            printf("%d %d %d\n", result[i].second, -result[i].first.first, result[i].first.second);
        }
        cin >> T >> P >> R;
    }
}


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

int main(){
  long long N;
  cin >> N;
  if (N == 0){
    cout << 0 << endl;
    return 0;
  }
  long long num = 0;
  string ans;
  long long check = 1;
  int count = 0;
  while(num != N) {
    check *= 2;
    int md = N%check;
    if (md < 0) md += check;
    if (md == (num%check+check)%check) ans += "0";
    else {
      ans += "1";
      num += pow(-1,count)*check/2;
    }
  // cout << num << endl;
  count++;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}


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

int main(){
 
  while(1){
    int i,j,n,m,taro[101]={0},hanako[101]={0},taro_total=0,hanako_total=0,min=1000;
    int taro_change,hanako_change;
    cin >> n >> m;
    if(n==0 && m==0)break;

    for( i  = 1; i <=n; i++){
      cin >> taro[i];
      taro_total+=taro[i];
    }

    for( i = 1; i <=m; i++){
      cin >> hanako[i];
      hanako_total+=hanako[i];
    }

  


    for( i = 1; i <=n; i++){
      for( j = 1; j <=m; j++){
	if(taro_total-taro[i]+hanako[j]==hanako_total-hanako[j]+taro[i]){
	  if(min > taro[i]+hanako[j]){
	    min = taro[i]+hanako[j];
	    taro_change = taro[i];
	    hanako_change = hanako[j];
	  }
	}
      }
    }
  
    if(min==1000){
      cout << -1 << endl;
    }else{
      cout << taro_change << " " << hanako_change << endl;;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

ll K,A,B;

int main()
{
  cin >> K >> A >> B;
  if (A >= B) {
    cout << K+1 << endl;
  } else { // A < B
    // A-1回たたく (ビスケットA枚)
    // 残りは2ターンでB-Aずつ増やす
    ll ans = A + (K-A+1)/2 * (B-A);
    //奇数回だと1回余るので，叩く
    if ((K-A+1) % 2 == 1) ++ans;

    // K+1は確実にできる
    ans = max(ans, K+1);
    cout << ans << endl;
  }

  return 0;
}


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

#define endl '\n'
#define int ll
typedef long long ll;

const int MAX_N = 100 + 87;
const int MAX_W = 1e5 + 87;

int w[MAX_N] = {}, v[MAX_N] = {};
int dp[MAX_W] = {}, dp_new[MAX_W] = {};

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

    int N, W;
    cin >> N >> W;
    for (int i = 1; i <= N; i++) {
        cin >> w[i] >> v[i];
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= W; j++) {
            if (j >= w[i]) {
                dp_new[j] = max(dp[j], dp[j - w[i]] + v[i]);
            } else {
                dp_new[j] = dp[j];
            }
        }
        for (int j = 0; j <= W; j++) {
            dp[j] = dp_new[j];
        }
    }

    cout << dp[W];

    return 0;
}

Measured memory_bytes: 1792
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
6 9
3 4
6 1
2 4
5 3
4 6
1 5
6 2
4 5
5 6
'''

def solve(adj):
	n = len(adj)
	dis = [maxsize]*n
	ans = [0]*n
	q = [0]
	dis[0] = 0
	while(q):
		src = q.pop(0)
		for nn in adj[src]:
			if(dis[nn] == maxsize):
				ans[nn] = src
				dis[nn] = dis[src] + 1
				q.append(nn)
	for i in range(n):
		ans[i] += 1
	if(maxsize in dis[1:]):
		print('No')
	else:
		print('Yes')
		for i in range(1,n):
			print(ans[i])

N,M = list(map(int, stdin.readline().rstrip().split()))
adj = [[] for i in range(N)]
for _ in range(M):
	a,b = list(map(int, stdin.readline().rstrip().split()))
	a -= 1
	b -= 1
	adj[a].append(b)
	adj[b].append(a)
solve(adj)



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

int main() {

  int A, B;
  cin >> A >> B;
  
  int a, b, c, d;
  int n = 0;
  
  for (int i = A; i < B + 1; i++) {
    a = i % 10;
    d = i / 10000;
    if (a == d) {
      b = (i / 10) % 10;
      c = (i / 1000) % 10;
      if (b == c) {
        n += 1;
      }
    }
  }
  
  cout << n << endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
      int H = Integer.parseInt(sc.next());
      int W = Integer.parseInt(sc.next());
      if(H == 0 && W == 0){
        break;
      }
      else{
        for(int i = 0; i < H; i++){
          for(int j = 0; j < W; j++){
            if(i == 0 || i == (H - 1) || j == 0 || j == (W - 1)){
              System.out.printf("#");
            }
            else{
              System.out.printf(".");
            }
          }
          System.out.printf("\n");
        }
        System.out.printf("\n");
      }
    }
  }
}


Measured memory_bytes: 62076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
static const int MAX = 50;
int h, w;
char G[MAX][MAX];

void change(int x, int y){
    int res = 0;
    for (int i = -1; i <= 1; i++){
        for (int j = -1; j <= 1; j++){
            if (x+i<0 || x+i>=h || y+j<0 || y+j>=w) continue;
            if (G[x + i][y + j] == '#') res += 1;
        }
    }
    G[x][y] = '0' + res;
}

int main(){
    sc(h) sc(w)
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++) cin >> G[i][j];
    }
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            if (G[i][j] == '.') change(i, j);
        }
    }
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++) cout << G[i][j];
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 int a,b,c,d;
	 cin>>a>>b>>c>>d;
	 int turn = 1;
	 while(true)
	 {
	 	if(turn==1)
	 	{
	 		c-=b;
	 		if(c<=0)
	 		break;
	 		turn=2;
	 	}
	 	else
	 	{
	 		a-=d;
	 		if(a<=0)
	 		break;
	 		turn=1;
	 	}
	 }
	 if(turn==1)
	 cout<<"Yes";
	 else
	 cout<<"No";
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;

/***************/
 #define amin main
/***************/

ll exp(ll x, ll n)
{if(n==0) return 1;if(n==1) return x%INF;if(n%2==0) return exp((x*x)%INF,n/2); else return(x*exp((x*x)%INF,n/2))%INF;}


int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t,i,j;

ll n;
cin>>n;
ll arr[n];
for(i=0;i<n;i++)
	cin>>arr[i];
sort(arr,arr+n);
ll sum =0;
sum += arr[n-1];
ll x = 2;
ll k = n-2;
while(x<n)
{
	if(x<n-1)
	{
		sum += arr[k]*2;
		k--;
		
		x = x+2;
	}
	else
		{
			sum += arr[k]*1;
			k--;
			x++;
		}
	
}
cout<<sum<<endl;


	


	
	

	
	


	
	return 0;
}

Measured memory_bytes: 5172
while True:
    n=int(input())
    if n==0:
        break
    s=[-1]*4001
    id=[]
    for i in range(n):
        e,p,q=map(int,input().split())
        if s[e]<0:
            id.append(e)
            s[e]=p*q
        else:
            s[e]+=p*q
    ch=True
    for i in id:
        if s[i]>=1000000:
            print(i)
            ch=False
    if ch:
        print("NA")


Measured memory_bytes: 5832
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

ll modPow(ll a, ll n,ll p) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1,p)) % p;
  ll t = modPow(a, n / 2,p);
  return (t * t) % MOD;
}

int main(){
  string S;
  cin >> S;
  vector<vector<ll>> dp((ll)S.size(),vector<ll>(13,0));
  rep(i,(ll)S.size()){
    if(i==0){
      if(S.at(i)=='?'){
        rep(j,10){
          dp.at(i).at(j)=1;
        }
      }else{
        dp.at(i).at(S.at(i)-'0')=1;
      }
    }else{
      rep(j,13){
        if(S.at(i)=='?'){
          rep(k,10){
            dp.at(i).at((k+10*j)%13)+=dp.at(i-1).at(j);
            dp.at(i).at((k+10*j)%13)%=MOD;
          }
        }else{
          dp.at(i).at((S.at(i)-'0'+10*j)%13)+=dp.at(i-1).at(j);
          dp.at(i).at((S.at(i)-'0'+10*j)%13)%=MOD;
        }
      }
    }
  }
  cout << dp.at((ll)S.size()-1).at(5) << endl;
  
}

Measured memory_bytes: 16720
n = gets.to_i
s = n.times.map{gets.chomp.split("")}
t = Array.new(n).map{Hash.new(0)}
n.times do |i|
  s[i].each do |str|
    t[i][str] += 1
  end
end
ans = Hash.new(0)
ans = t[-1]
for i in 0..n-1
  ans.each do |k,v|
    ans[k] = [t[i][k],v].min
  end
end
ans.sort.each do |k,v|
  v.times do
    print k
  end
end
print "\n"

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

#define ff              first
#define fo(i,n)         for(i=0;i<n;i++)
#define Fo(i,k,n)       for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x, y)      cout << #x << "=" << x << "," << #y << "=" << y << endl
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


const int N = 3e5, M = N;
//=======================


void solve() {
  int i, j, n, m;
  cin>>n;
  if(n==1){
    cout<<0;
  }
  else{
    cout<<1;
  }
}

int32_t main()
{
  FIO;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  
  solve();
  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >>S;
    int N=S.size();
    vector<int>vec(N,0);
    int count=0;
for(int i=0;i<N;i++){
    if(S.at(i)=='A'||S.at(i)=='C'||S.at(i)=='G'||S.at(i)=='T'){
      count ++;
      vec.at(i)=count;
    }
    else{
        count=0;
        vec.at(i)=count;
    }

    }
        sort(vec.begin(),vec.end());
    cout << vec.at(N-1)<<endl;
}

Measured memory_bytes: 3556
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)] 

bingo = [[0]*3 for i in range(3)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if b[i] == A[j][k]:
                bingo[j][k] = 1
                
import sys

if bingo[0][0] == bingo[0][1] and bingo[0][1] == bingo[0][2] and bingo[0][0] == 1:
    print('Yes')
    sys.exit()
if bingo[1][0] == bingo[1][1] and bingo[1][1] == bingo[1][2] and bingo[1][0] == 1:
    print('Yes')
    sys.exit()
if bingo[2][0] == bingo[2][1] and bingo[2][1] == bingo[2][2] and bingo[2][0] == 1:
    print('Yes')
    sys.exit()
if bingo[0][0] == bingo[1][0] and bingo[1][0] == bingo[2][0] and bingo[0][0] == 1:
    print('Yes')
    sys.exit()
if bingo[0][1] == bingo[1][1] and bingo[1][1] == bingo[2][1] and bingo[0][1] == 1:
    print('Yes')
    sys.exit()
if bingo[0][2] == bingo[1][2] and bingo[1][2] == bingo[2][2] and bingo[0][2] == 1:
    print('Yes')
    sys.exit()
if bingo[0][0] == bingo[1][1] and bingo[1][1] == bingo[2][2] and bingo[0][0] == 1:
    print('Yes')
    sys.exit()
if bingo[0][2] == bingo[1][1] and bingo[1][1] == bingo[2][0] and bingo[0][2] == 1:
    print('Yes')
    sys.exit()
    
print('No')

Measured memory_bytes: 3192