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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}


int nextInt() { int x; scanf("%d", &x); return x;}

int memo[100000 + 10];

int main2() {
  int N = nextInt();
  
  int ans = 0;
  const int INF = 1001001001;
  REP(i, N+1) memo[i] = INF;
  deque<int> q;
  q.push_back(1);
  memo[1] = 0;
  while (!q.empty()) {
    int n = q.front(); q.pop_front();
    if (n == 0) {
      ans = memo[n];
      break;
    }

    {
      int nn = (n + 1) % N;
      if (memo[nn] > memo[n] + 1) {
        memo[nn] = memo[n] + 1;
        q.push_back(nn);
      }
    }
    {
      int nn = (n * 10) % N;
      if (memo[nn] > memo[n]) {
        memo[nn] = memo[n];
        q.push_front(nn);
      }
    }
  }
  cout << (ans+1) << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 896
#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;
constexpr long long LINF = 1001001001001001001;
#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; }


int main(){
    int n; cin >> n;
    vector<int> B(n-1); rep(i, n-1) cin >> B[i];

    vector<int> A(n, INF);
    rep(i, n-1){
        chmin(A[i], B[i]);
        chmin(A[i+1], B[i]);
    }
    ll sum = 0;
    rep(i, n) sum += A[i];
    cout << sum << ln;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

//組み合わせの数nCrを計算
ll calcNumOfCombination(ll n, ll r){
  mint num = 1;
  for(ll i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num.x;
}

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

  ll x, y;
  cin >> x >> y;
  if ((x + y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }
  if (max(x, y) > 2 * min(x, y)) {
    cout << 0 << endl;
    return 0;
  }

  ll num_move = (x + y) / 3;
  ll beta = (2 * x - y) / 3;

  cerr << num_move << " " << beta << endl;
  cout << calcNumOfCombination(num_move, beta) << endl;

  return 0;
}


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


int main(int argc, char *argv[])
{
	string s,t;

	int l;
	cin>>l>>s>>t;

	string ret="";
	for (int i=0;i<l;i++)
	{
		ret+=s.substr(i,1);
		ret+=t.substr(i,1);
	}
	cout << ret << endl;
	return 0;
}



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

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

int main()
{
    ll i,j;
    ll n,m,k;
    cin >> n >> m >> k;
    int max_number = n-1;
    int MOD = 998244353;
    
    vector<ll> fac(max_number+1,1);
    vector<ll> inv(max_number+1,1);
    vector<ll> finv(max_number+1,1);
    vector<ll> nCk(max_number+1,1);
    for(i = 2;i <= max_number;++i){
        inv.at(i) = MOD - inv.at(MOD%i)*(MOD/i)%MOD;
    }
    for(i = 1;i <= max_number;++i){
        fac.at(i) = fac.at(i-1)*i%MOD;
        finv.at(i) = finv.at(i-1)*inv.at(i)%MOD;
    }
    for(i = 1;i <= max_number;++i){
        nCk.at(i) = fac.at(max_number)*finv.at(i)%MOD*finv.at(max_number-i)%MOD;
    }
    vector<ll> v(n+1,0);
    v.at(0) = m;
    for(i = 0;i < n;++i){
        v.at(i+1) = v.at(i)*(m-1)%MOD;
    }

    ll ans = 0;
    for(i = 0;i <= k;++i){
        ll tmp = nCk.at(n-1-i)*v.at(n-i-1);
        ans += tmp;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11152
/* - - - - - - - - - - - - - - -
	User : 		VanishD
	problem :
	Points : 	
- - - - - - - - - - - - - - - */
# include <bits/stdc++.h>
# define 	ll 		long long
using namespace std;
const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
int read(){
	int tmp = 0, fh = 1; char ch = getchar();
	while (ch < '0' || ch > '9'){ if (ch == '-') fh = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9'){ tmp = tmp * 10 + ch - '0'; ch = getchar(); }
	return tmp * fh;
}
const int N = 110;
int n, sum, num[N], ans;
int main(){
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read(), sum = read();
	for (int i = 1; i <= n; i++) num[i] = read();
	sort(num + 1, num + n + 1);
	ans = 0;
	while (ans < n){
		if (sum >= num[ans + 1]){
			sum -= num[++ans]; 
		}
		else break;
	}
	if (ans == n && sum != 0) ans--;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
import java.util.InputMismatchException;
import java.util.Scanner;

public class Main {
	@SuppressWarnings("unlikely-arg-type")
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		String str1=scan.next().toUpperCase();
		int count=0;
		try{
			while(true) {
				String str=scan.next();
				if(str.toUpperCase().equals(str1)) {
					count++;
				}
				if(str.equals("END_OF_TEXT")){
					break;
				}
			}
			System.out.println(count);
			scan.close();
		}catch(InputMismatchException e){
			System.out.println("入力しなおしてください");
		}
		}
}


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

struct Card {char suit, value;};

void bubble(struct Card A[], int N) {
    for ( int i = 0; i < N; i++) {
        for ( int j = N - 1; j >= i + 1; j--) {
            if (A[j].value < A[j - 1].value) {
                Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N) {
    for ( int i = 0; i < N; i++) {
        int minj = i;
        for (int j = i; j < N; j++) {
            if (A[j].value < A[minj].value) minj = j;
        }
        Card t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}

void print(struct Card A[], int N) {
    for (int i = 0; i < N; i++) {
        if (i > 0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
    for ( int i = 0; i < N; i++) {
        if (C1[i].suit != C2[i].suit ) return false;
    }
    return true;
}

int main() {
    Card C1[100], C2[100];
    int N;
    char ch;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> C1[i].suit >> C1[i].value;
    }

    for (int i = 0; i < N; i++) C2[i] = C1[i];

    bubble(C1, N);
    selection(C2,N);

    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if (isStable(C1, C2, N)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    return 0;
}


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

int main() {
  int l1, l2, r1, r2;
  cin >> l1 >> l2 >> r1 >> r2;
  
  int l = l1 + l2;
  int r = r1 + r2;

  if (l > r) {
    cout << "Left" << endl;
  }
  else if (l == r) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll a,b,k;
  cin >> a >> b >> k;
  
  ll c = a;
  a = a<k ? 0 : a-k;
  k = k<c ? 0 : k-c;
  b = b<k ? 0 : b-k;
  cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X;
  cin >> X;
  if (X == 2) {
    cout << 2 << endl;
  } else {
    for (int i = 0; true; i++) {
      int j;
      for (j = 2; X+i >= j*j; j++) {
        if ((X+i)/j*j == X+i) {
          break;
        };
      };
      if ((X+i)/j*j != X+i) {
        cout << X+i << endl;
        break;
      };
    };
  }
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      n: u32,
      m: u32,
    }
    println!("{}", 2u32.pow(m) * (1900 * m + 100 * (n - m)));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int h[n+1],arr[n+1];
    arr[0]=0;
    for(int i=1;i<=n;i++){
    cin>>h[i];
    arr[i]=1;
    }
    while(m--){
        int a,b;
        cin>>a>>b;
        if(h[a]>h[b])
        arr[b]=0;
        if(h[a]<h[b])
        arr[a]=0;
        if(h[a]==h[b])
        {
            arr[a]=0;
            arr[b]=0;
        }
    }

    int c=0;
    for(int i=1;i<=n;i++)
    {
        if(arr[i]==1)
        c++;
    }
    cout<<c;
    return 0;
}

Measured memory_bytes: 4404
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;
//use ac_library_rs::*;

#[fastout]
fn main() {
    input! {
        n: usize, k: usize,
        mut lr: [(usize, usize); k]
    }
    let M = 998244353i64;

    lr.sort();
    let mut dp = vec![0i64; 2 * n + 10];
    dp[1] = 1;
    dp[2] = -1;
    for pos in 1..=n {
        dp[pos] += dp[pos-1];
        dp[pos] %= M;
        for &(l, r) in &lr {
            dp[pos + l] += dp[pos];
            dp[pos + r + 1] += M - dp[pos];
        }
    }
    println!("{}", dp[n] % M);
    dbg!(&dp[1..=n]);
}


Measured memory_bytes: 6492
import math
a,b,h,m = list(map(int, input().split()))

def pos(h, m):
  t = h*60 + m
  ang_h = t/(12*60) * 2*math.pi
  ang_m = m/(60) * 2*math.pi
  
  ang = min(abs(ang_h - ang_m), 360 - abs(ang_h - ang_m))
  print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(ang)))

  

pos(h,m)

Measured memory_bytes: 9392
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
int dist[60000];
vector<int> x[60000];
string S; queue<int>Q;
int power[12], p2[12];
int main() {
	power[0] = 1; p2[0] = 1;
	for (int i = 1; i < 12; i++)power[i] = power[i - 1] * 3;
	for (int i = 1; i < 12; i++)p2[i] = p2[i - 1] + power[i];
	while (true) {
		cin >> S; if (S == "0") break;
		int bit[12], c[12], D = 0;
		for (int i = 0; i < S.size(); i++) {
			if (S[i] == 'r')D += 0 * power[i];
			if (S[i] == 'g')D += 1 * power[i];
			if (S[i] == 'b')D += 2 * power[i];
		}
		for (int i = 0; i < 60000; i++) {
			dist[i] = 99999; x[i].clear();
		}
		for (int i = 0; i < power[S.size()]; i++) {
			for (int j = 0; j < S.size(); j++)bit[j] = (i / power[j]) % 3;
			for (int j = 0; j < S.size() - 1; j++) {
				for (int k = 0; k < S.size(); k++)c[k] = bit[k];
				if (bit[j] != bit[j + 1]) {
					int V = bit[j] + bit[j + 1];
					V = 3 - V; c[j] = V; c[j + 1] = V;
					int T = 0;
					for (int k = 0; k < S.size(); k++) {
						T += c[k] * power[k];
					}
					x[i].push_back(T);
				}
			}
		}
		Q.push(D); dist[D] = 0;
		while (!Q.empty()) {
			int a = Q.front(); Q.pop();
			for (int i = 0; i < x[a].size(); i++) {
				if (dist[x[a][i]] == 99999) {
					dist[x[a][i]] = dist[a] + 1;
					Q.push(x[a][i]);
				}
			}
		}
		int minx = min(dist[0], min(dist[p2[S.size() - 1]], dist[2 * p2[S.size() - 1]]));
		if (minx == 99999)cout << "NA" << endl;
		else cout << minx << endl;
	}
	return 0;
}

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

int main()
{
    string s;
    int array[26] = {};
    while(getline(cin, s))
    {
        for(int i = 0; i < s.size(); i++)
        {
            if(s[i] >= 'a' && s[i] <= 'z')
                array[s[i] - 'a'] += 1;
            else if(s[i] >= 'A' && s[i] <= 'Z')
                array[s[i] - 'A'] += 1;
        }
    }
    for(int i = 0; i < 26; i++)
        printf("%c : %d\n", i + 'a', array[i]);  
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<char>> c(h, vector<char>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> c.at(i).at(j);
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << c.at(i).at(j);
		}
		cout << endl;
		for (int j = 0; j < w; j++) {
			cout << c.at(i).at(j);
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int n;
char s[max_n];
int cnt[4][max_n];;
int main(){
    scanf("%d",&n);
    scanf(" %s",s+1);
    for(int i=1;i<=n;i++){
        if(s[i]=='R')s[i]=1;
        else if(s[i]=='G')s[i]=2;
        else s[i]=3;
    }
    for(int j=1;j<=3;j++){
        for(int i=n;i>=1;i--)cnt[j][i]=cnt[j][i+1]+(s[i]==j);
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(s[i]==s[j])continue;
            int x;
            for(int k=1;k<=3;k++){
                if(k!=s[i]&&k!=s[j])x=k;
            }
            ans+=cnt[x][j+1];
            if(j*2-i<=n&&s[j*2-i]==x)ans--;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3796
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
using ll = long long;
using db = long double;
const int N = 1 << 17, MOD = 1e9 + 7;
int main(){
#ifdef ONLINE_JUDGE
  ios_base::sync_with_stdio(0);cin.tie(0);
#endif // ONLINE_JUDGE


string str;	cin >> str;
	for(int i = 1; i < str.size(); i++){
    	if(str[i] == str[i-1]){
        	cout << "Bad\n";
          return 0;
        }
    }  
  cout << "Good\n";

  return 0;
}


Measured memory_bytes: 256
#undef HOGE
#include <iostream>

bool ask(uint64_t n) {
  std::cout << "? " << n << std::endl;
#ifdef HOGE
  std::string sq = std::to_string(n);
  std::string sa = std::to_string(N);
  return sq <= sa == n <= N;
#else
  std::string s;
  std::cin >> s;
  return s == "Y";
#endif
}

int main() {
  unsigned long long ans = 0;
  unsigned long long d = 10;
  std::string s;
  while (true) {
    if (ask((ans * 10 + 6) * 1000000000 - 1)) {
      if (ask((ans * 10 + 4) * 1000000000 - 1)) {
        if (ask((ans * 10 + 2) * 1000000000 - 1)) {
          if (ans == 0) {
            ans = 1;
            if (ask(2)) { break; }
          } else {
            if (ask((ans * 10 + 1) * 1000000000 - 1)) {
              ans *= 10;
              if (ans == d / 10 && ask(d - 1)) { break; }
            } else {
              ans *= 10;
              ans += 1;
            }
          }
        } else {
          if (ask((ans * 10 + 3) * 1000000000 - 1)) {
            ans *= 10;
            ans += 2;
          } else {
            ans *= 10;
            ans += 3;
          }
        }
      } else {
        if (ask((ans * 10 + 5) * 1000000000 - 1)) {
          ans *= 10;
          ans += 4;
        } else {
          ans *= 10;
          ans += 5;
        }
      }
    } else {
      if (ask((ans * 10 + 8) * 1000000000 - 1)) {
        if (ask((ans * 10 + 7) * 1000000000 - 1)) {
          ans *= 10;
          ans += 6;
        } else {
          ans *= 10;
          ans += 7;
        }
      } else {
        if (ask((ans * 10 + 9) * 1000000000 - 1)) {
          ans *= 10;
          ans += 8;
        } else {
          ans *= 10;
          ans += 9;
        }
      }
    }
    if (!ask(d)) { break; }
    d *= 10;
    if (ans * 10 >= 1000000000) { break; }
  }
  if (ans == 100000000) {
    if (!ask(999999999)) { ans *= 10; }
  }
  std::cout << "! " << ans << std::endl;
  std::cout << std::flush;
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main(){
    int L;
    scanf("%d",&L);
    int vtx = 0,cp=L,edg;
    vector<int> V; //pos of zeros
    for(int it,i=0;(it=1<<i)<=L;i++){
        if(it&L)
            V.push_back(i); //10000 -> 0(0000~1111), the place of 1->0.
        vtx = i+1;
        edg = 2*(vtx-1) + V.size()-1;
    }
    printf("%d %d\n",vtx,edg);
    for(int i=1;i<vtx;i++){
        printf("%d %d %d\n",i,i+1,1<<(vtx-1-i));
        printf("%d %d %d\n",i,i+1,0);
    }
    for(int x:V){
        //x : the place of i
        int it = 1<<x;
        int from =1,to = vtx - x;
        int val = L - (L&(2*it-1));
        //printf("%d\n",L&(2*it-1));
        if(val!=0) printf("%d %d %d\n",from,to,val);
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
C = {1:0,2:0,3:0}
for i in range(N):
    C[A[i]] += 1
dp = [[[0 for _ in range(N+1)] for _ in range(N+1)] for _ in range(N+1)]
for k in range(1,N+1):
    dp[0][0][k] = N/k+dp[0][0][k-1]
for j in range(1,N+1):
    for k in range(N+1-j):
        if k+1<=N and k>=1:
            dp[0][j][k] = N/(j+k)+j/(j+k)*dp[0][j-1][k+1]+k/(j+k)*dp[0][j][k-1]
        elif k==0:
            dp[0][j][0] = N/j+dp[0][j-1][1]
for i in range(1,N+1):
    for j in range(N+1-i):
        for k in range(N+1-i-j):
            if j-1>=0 and k-1>=0:
                dp[i][j][k] = N/(i+j+k)+i/(i+j+k)*dp[i-1][j+1][k]+j/(i+j+k)*dp[i][j-1][k+1]+k/(i+j+k)*dp[i][j][k-1]
            elif j==0 and k-1>=0:
                dp[i][0][k] = N/(i+k)+i/(i+k)*dp[i-1][1][k]+k/(i+k)*dp[i][0][k-1]
            elif j-1>=0 and k==0:
                dp[i][j][0] = N/(i+j)+i/(i+j)*dp[i-1][j+1][0]+j/(i+j)*dp[i][j-1][1]
            elif j==0 and k==0:
                dp[i][j][0] = N/i+dp[i-1][1][0]
print(dp[C[3]][C[2]][C[1]])


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

int main(){
  int n;
  cin >> n;
  vector<int> A(n);
  rep(i,n){
    cin >> A[i];
  }
  rep(i,n){
    if(A[i]%2==0){
      if(A[i]%3==0||A[i]%5==0)continue;
      else{
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED"<<endl;
  return 0;
}


Measured memory_bytes: 3616
def check(m, f, r)
  return 'F' if '-1' =~ /^(#{m}|#{f})/
  return m + f >= 80 ? 'A' :
         m + f >= 65 ? 'B' :
         m + f >= 50 || m + f >= 30 && r >= 50 ? 'C' :
         m + f >= 30 ? 'D' : 'F'
end

while (n = gets.split(' ').map(&:to_i)) != [-1, -1, -1]
  m, f, r = n
  puts check(m, f, r)
end

Measured memory_bytes: 8672
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = n / 1000;
		int b = (n % 1000) / 100;
		int c = ((n % 1000) % 100) / 10;
		int d = (((n % 1000) % 100) % 10);
		
		if(a + b + c + d == 7){
			System.out.println(a + "+" + b + "+" + c + "+" + d + "=7");
		}else if(a + b + c - d == 7){
			System.out.println(a + "+" + b + "+" + c + "-" + d + "=7");
		}else if(a + b - c + d == 7){
			System.out.println(a + "+" + b + "-" + c + "+" + d + "=7");
		}else if(a + b - c - d == 7){
			System.out.println(a + "+" + b + "-" + c + "-" + d + "=7");
		}else if(a - b + c + d == 7){
			System.out.println(a + "-" + b + "+" + c + "+" + d + "=7");
		}else if(a - b + c - d == 7){
			System.out.println(a + "-" + b + "+" + c + "-" + d + "=7");
		}else if(a - b - c + d == 7){
			System.out.println(a + "-" + b + "-" + c + "+" + d + "=7");
		}else if(a - b - c - d == 7){
			System.out.println(a + "-" + b + "-" + c + "-" + d + "=7");
		}
	}
}


Measured memory_bytes: 22996
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

  // a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
  // テーブルを作る前処理
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;
    }
}
  // 二項係数計算
long long 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;
}

int main() {
  ll N,A,B,C;cin>>N>>A>>B>>C;
  ll i,j,k,l;
  ll ans=0;
  // 前処理
  COMinit();
  for(i=N;i<=2*N-1;i++){
    ans += i * COM(i-1,N-1) %MOD * modpow(A,N,MOD) %MOD * modpow(B,i-N,MOD) %MOD
    * modpow(inv[A+B],i,MOD) %MOD * 100 % MOD * inv[100-C] %MOD;
  }
  for(i=N;i<=2*N-1;i++){
    ans += i * COM(i-1,N-1) %MOD * modpow(B,N,MOD) %MOD * modpow(A,i-N,MOD) %MOD
    * modpow(inv[A+B],i,MOD) %MOD * 100 % MOD * inv[100-C] %MOD;
  }
  ans%=MOD;
  cout<<ans<<endl;
}


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

int main(void) {

	int n; 
	///入力

	while (cin >> n,n) {
	/// カンマ区切りの書き方だと0が入力された際に終了

		int top = 1, south = 2, east = 3,
			sum = 1;

		for (int i = 0;i < n;++i) {

			string s;
			cin >> s;

			if (s == "North") {
				int a = top;
				top = south;
				south = 7 - a;
			}

			else if (s == "East") {
				int a = east;
				east = top;
				top = 7 - a;
			}

			else if (s == "West") {
				int a = top;
				top = east;
				east = 7 - a;
			}

			else if (s == "South") {
				int a = south;
				south = top;
				top = 7 - a;
			}

			else if (s == "Right") {
				int a = south;
				south = east;
				east = 7 - a;
			}

			else if (s == "Left") {
				int a = east;
				east = south;
				south = 7 - a;
			}

			sum += top;

		}
		cout << sum << endl;
	}
}



Measured memory_bytes: 2988
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
  int m,n;
  char s[1000][1001];
  char monsyo[2][3];
  scanf("%d %d",&m,&n);
  for(int i=0;i<m;i++) scanf("%s",s[i]);
  for(int i=0;i<2;i++) scanf("%s",monsyo[i]);
  int cnt = 0, ans = 0;
  for(int i=0;i+1<m;i++){
    for(int j=0;j+1<n;j++){
      if(s[i][j]==monsyo[0][0]&&s[i+1][j+1]==monsyo[1][1]&&s[i+1][j]==monsyo[1][0]&&s[i][j+1]==monsyo[0][1]) cnt++;
    }
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      char c[] = "JOI";
      int x;
      int tmp[3] = {0, 0, 0};
      char d = s[i][j];
      for(int k=0;k<3;k++){
        s[i][j] = c[k];
        int dx[] = {-1, 0, -1, 0};
        int dy[] = {-1, -1, 0, 0};
        for(int l=0;l<4;l++){
          int ni = i + dx[l], nj = j + dy[l];
          if(ni<0||ni>=m-1||nj<0||nj>=n-1) continue;
          if(s[ni][nj]==monsyo[0][0]&&s[ni+1][nj+1]==monsyo[1][1]&&s[ni+1][nj]==monsyo[1][0]&&s[ni][nj+1]==monsyo[0][1]) tmp[k]++;
        }
        if(c[k]==d) x = tmp[k];
      }
      for(int k=0;k<3;k++) ans = max(ans,tmp[k]-x);
      s[i][j] = d;
    }
  }
  ans += cnt;
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 3724
import java.util.*;
public class Main {
	public static void main(String args[] ){
		Scanner sc =new Scanner(System.in);
	long n = sc.nextLong();
	long m =sc.nextLong();
	long min  = 2018;
	
	
	if(m*m<2019) {
		long data =(n*(n+1))%2019;
		min =data;
	}else{
		for(long i=n;i<m;i++) {
			for(long j=i+1;j<=m;j++) {
				long data =(i*j)%2019;
				if(min > data) {
					//System.out.println(i+" "+j);
					min =data;
				}
				if(min==0) break;
				
				
			}
			if(min==0) break;
		}
		}
	
	
	System.out.println(min);
	
	
	}
}


Measured memory_bytes: 21844
S = input()
T = input()

P = set()
Q = set()

def conv(S):
    MS = {}
    idx = 0
    res = []
    for s in S:
        if s in MS:
            res.append(MS[s])
            continue
        MS[s] = idx
        res.append(idx)
        idx += 1
    return res

MS = conv(S)
MT = conv(T)

if MS == MT:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 6832
K, N = map(int, input().split())
A = list(map(int, input().split()))
# A = [i for i in map(int, input().split())]

A2 = [A[i+1] - A[i] for i in range(N-1)]
AN = A[0]+(K-A[N-1])
A2.append(AN)

print(K-max(A2))


Measured memory_bytes: 26548
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1000000007LL;

int main() {
	string S;
	ll K;
	cin >> S;
	cin >> K;
	int k = 0;
	while (S[k] == '1') k++;
	if (k >= K) cout << 1 << endl;
	else cout << S[k] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< int > vi;
typedef vector< ll > lvi;
typedef vector< vi > vvi;
typedef vector< lvi > lvvi;
typedef pair< int,int > ii;
typedef pair< ll,ll > lii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
	ll n;
	cin>>n;
	set<ll> st;
	st.insert(n);
	if(n>2) st.insert(n-1);
	for(ll i=2;i*i<=n-1;i++)
	{
		ll tmp=n-1;
		if(tmp%i==0)
		{
			st.insert(i);
			st.insert(n/i);
		}
	}	
	for(ll i=2;i*i<=n;i++)
	{
		ll tmp=n;
		while(tmp%i==0) tmp/=i;
		if(tmp==1)
		{
			st.insert(i);
			continue;
		}
		tmp--;
		if(tmp%i==0) st.insert(i);
	}
	cout<<st.size()<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
 
using namespace std;

/**************************************************************************/
const ll days = 5e15;
int main()
{
	fastIO;
	ll i,j,k,n;
	string s;
	cin>>s;
	n = s.length();
	cin>>k;
	i = 0;
	while(i+1<k and i<n and s[i]=='1')i++;
	cout<<s[i];
}/*************************************************************************/ 

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	int N,M;
	cin >> N >> M;
	priority_queue<ll> q;
	for(int i=0; i<N; i++){
		ll A;
		cin >> A;
		q.push(A);
	}

	for(int i=0; i<M; i++){
		ll a;
		a=q.top();
		q.pop();
		q.push(a/2);
	}

	ll ans=0;
	for(int i=0; i<N; i++){
		ll a;
		a=q.top();
		q.pop();
		ans+=a;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace AtCoder_Project_CSharp
{
    class Program
    {

        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            var ss = s;
            for (int i = 0; i < s.Length; i++)
            {
                if (ss==t)
                {
                    Console.WriteLine("Yes");
                    return;
                }
                ss=ss.Insert(0,ss.Last().ToString()).Remove(ss.Length);
            }
            Console.WriteLine( "No");

        }
    }
}


Measured memory_bytes: 13268
n, k = map(int, input().split())
v = list(map(int, input().split()))

ans = 0

for left in range(k+1):
    for right in range(k - left + 1):
        if left + right > n:
            continue
        rock = v[:left] + v[::-1][:right]
        rock.sort()
        rem = k - left - right
        while rem > 0 and len(rock) > 0 and rock[0] < 0:
            rock = rock[1:]
            rem -= 1
        ans = max(ans, sum(rock))

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(void)
{
  int n,i,tmp,sur;
  tmp=100000;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    tmp=tmp*1.05;
    sur=tmp%1000;
    if(sur!=0)
      tmp+=1000-sur;
  }
  printf("%d\n",tmp);

  return 0;
}

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

#define ll long long
#define vi vector<int>
#define pi pair<int, int>
#define pb push_back
#define ppb pop_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()


using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int MAXN = 1e5 + 667;

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

    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if(u == s) a--;
    else b--;
    cout << a << " " << b;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix


if __name__ == "__main__":

    S = input()
    Q = int(input())
    rev = False
    head = []
    tail = []
    for _ in range(Q):
        task = input()
        if task == "1":
            rev = not rev
        else:
            _, f, c = task.split()
            if f == "1":
                if rev:
                    tail.append(c)
                else:
                    head.append(c)
            else:
                if rev:
                    head.append(c)
                else:
                    tail.append(c)

        # print(task, head, tail, rev)

    ans = ''.join(reversed(head)) + S + ''.join(tail)
    if rev:
        ans = ''.join(reversed(ans))

    print(ans)


Measured memory_bytes: 7288
#include<stdio.h>
int main(){
  long int x, y, j, c;
    
  scanf("%ld %ld",&x,&y);
  c=0;
  for(j=x;j<=y;j*=2){
    if(j <= y){
      c++;
    }else{
      break;
    } 
  }
  printf("%d\n",c);
  
  return 0;
}

Measured memory_bytes: 128
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def stern_brocot(p, n):
    la = 0; lb = 1
    ra = 1; rb = 0
    lu = ru = 1
    lx = 0; ly = 1
    rx = 1; ry = 0
    while lu or ru:
        ma = la + ra; mb = lb + rb
        if p * mb**2 < ma**2:
            ra = ma; rb = mb
            if ma <= n and mb <= n:
                rx = ma; ry = mb
            else:
                lu = 0
        else:
            la = ma; lb = mb
            if ma <= n and mb <= n:
                lx = ma; ly = mb
            else:
                ru = 0
    return lx, ly, rx, ry

while 1:
    p, n = map(int, readline().split())
    if p == 0:
        break
    lx, ly, rx, ry = stern_brocot(p, n)
    write("%d/%d %d/%d\n" % (rx, ry, lx, ly))


Measured memory_bytes: 5636
package main

import "fmt"

func main() {
	var D, G int
	fmt.Scan(&D, &G)

	p := make([]int, D)
	c := make([]int, D)
	for i := range p {
		fmt.Scan(&p[i], &c[i])
	}

	minCnt := 0
	for bit := 0; bit <= 1<<uint(D); bit++ {
		ans := 0
		cnt := 0
		for i := 0; i < D; i++ {
			if bit&(1<<uint(i)) == (1 << uint(i)) {
				cnt += p[i]
				ans += p[i]*100*(i+1) + c[i]
			}
		}
		// fmt.Println(cnt, ans)
		if ans >= G && (minCnt == 0 || cnt < minCnt) {
			minCnt = cnt
		} else {
			for i := D - 1; i >= 0; i-- {
				if bit&(1<<uint(i)) == (1 << uint(i)) {
					continue
				}
				for j := 0; j < p[i]; j++ {
					if ans >= G {
						break
					}
					ans += 100 * (i + 1)
					cnt++
				}
				// TODO: check complete point
			}
			if minCnt == 0 || cnt < minCnt {
				minCnt = cnt
			}
		}
	}
	fmt.Println(minCnt)
}


Measured memory_bytes: 512
import sys
import bisect
input = sys.stdin.readline

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

if n == 2:
    am = a[-1]
    amm = a[0]
else:
    am = max(a)
    ind = bisect.bisect_left(a,am//2)
    am1 = a[ind]
    am2 = a[ind-1]

    am1abs = abs(am/2-am1)
    am2abs = abs(am/2-am2)

    if am1abs <= am2abs:
        amm = am1
    else:
        amm = am2
    
print(am,amm)


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

int main(){
  int i;
  char T[200001];
  scanf("%s",T);
  
  for(i=0;T[i]!='\0';i++){
    if(T[i]=='\?'){
        T[i]='D';
    }
  }
  printf("%s",T);
  
  return 0;
}

Measured memory_bytes: 1924
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
int dy8[] = {0,1,1,1,0,-1,-1,-1};
int dx8[] = {1,1,0,-1,-1,-1,0,1};

/*==================================================*/
/*variable*/
ll N;
ll A[200010];

int d[25];  //ここまで立っているビットは何個あったか？（偶奇をチェック）
/*==================================================*/
/*function*/
bool ok(ll num){
    bool ret = true;
    REP(i,0,20){
        if(d[i] > 0 && ((1<<i)&num)){
            ret = false;
        }
    }
    return ret;
}

/*==================================================*/

int main() {
    cin>>N;
    REP(i,0,N) cin >> A[i];

    ll ans = 0LL;

    int l=0, r=0;
    while(true) {
        while(r < N){
            if(!ok(A[r])) break;
            REP(i,0,20){
                if((1<<i)&A[r])d[i]++;
            }
            r++;
        }
        ans += r - l;

        if(l==N-1 && r==N) break;

        while(true){
            REP(i,0,20){
                if((1<<i)&A[l])d[i]--;
            }
            l++;
            if(ok(A[l-1])) break;
        }
    }

    cout<<ans<<endl;

    return 0;
}




Measured memory_bytes: 1792
import sys
readline=sys.stdin.readline
read=sys.stdin.read

def main():
    n,k=map(int,readline().split())
    ab=[list(map(int,l.split())) for l in read().splitlines()]
    
    ek=0
    while k>>ek:
        ek+=1
    ans=0
    for i in range(ek):
        if k>>i&1:
            m=(k>>(i+1))<<(i+1)|((1<<i)-1)
            ans=max(ans,sum(e[1] for e in ab if e[0]|m==m))
    ans=max(ans,sum(e[1] for e in ab if e[0]|k==k))
    print(ans)

if __name__=='__main__':
    main()


Measured memory_bytes: 35832
s=list(input())
x=0
if s[0]=='A':
  del s[0]
  if 'C' in s[1:-1]:
    x=s.index('C')
    del s[x]
    s=''.join(s)
    #print(s)
    if s.islower():
      print('AC')
    else:
      print('WA')
  else:
    print('WA')
else:
  print('WA')

Measured memory_bytes: 3060
#include <iostream>
#include <set>
#include <cmath>
using namespace std;
const int N=100000+10;
int n,a[N];
int main(){
    scanf("%d",&n);
    long long ans=0;
    multiset<long long> st1,st2;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        ans=ans+abs(a[i]);
        if(a[i]<0)st1.insert(a[i]);
        if(a[i]>=0)st2.insert(a[i]);
    }
    if(st1.size()%2==0){
        cout<<ans<<endl;
    }else{
        long long d=1e18;
        if(st1.size()) d=min(d,-(*st1.rbegin()));
        if(st2.size()) d=min(d,*st2.begin());
        ans-=2*d;
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
int power(int x,int y)
{ int temp;
    if(y==0)
        return 1;
    temp=power(x,y/2)%mod;
    if(y%2==0)
        return (temp%mod*temp%mod)%mod;
    else
        return ((x%mod)*((temp%mod*temp%mod)%mod))%mod;
}

void solve()
{ int n;
  cin>>n;
  vector<vector<int>>dp(n,vector<int>(3));
  int a,b,c;
  cin>>a>>b>>c;
  dp[0][0]=a;
  dp[0][1]=b;
  dp[0][2]=c;
  for(int i=1;i<n;i++)
  { int a,b,c;
    cin>>a>>b>>c;
    dp[i][0]=a+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=b+max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=c+max(dp[i-1][1],dp[i-1][0]);

  }
  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;

}
signed main()
{   ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
            #ifndef ONLINE_JUDGE
        freopen("input1.txt","r",stdin);
        freopen("output1.txt","w",stdout);
         #endif

    int t;
    //cin>>t;
    t=1;
    for(int i=1;i<=t;i++)
        {solve();
        }



        return 0;     

    }

Measured memory_bytes: 8740
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include<vector>

using namespace std;
typedef long long ll;

bool check(ll n){ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true;
    if (n % 2 == 0 || n % 3 == 0) 
        return false;  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
} 

ll ans,mx,sum,mn=1e18,cnt;
ll flag;

int main(){
	ll n,m;
	cin>>n>>m;
	if(n==1 ){ 
		cout<<m;
		return 0;
	}
	for(ll i=1; i<=m/n; i++){
		ll flag=i*n;
		if(flag <=m){
			ll temp=m-flag;
			if(temp%i==0) {
				mx=max(mx,i);
			}
		}
	}
	 if(check(m)==1) cout<<1<<endl;
	else cout<<mx<<endl;
}



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

int main(){
    string s;
    cin >> s;
    int cnt=0;
    for(int i=0; i<3; i++){
        if(s[i]=='R'){
            cnt++;
        }
    }
    if(cnt==0 || cnt ==3){
        cout << cnt << endl;
    } else if(cnt==1){
        cout << 1 << endl; 
    } else if(cnt==2){
        if(s[0]=='R' & s[1]=='R'){
            cout << 2 << endl;
        } else if(s[2]=='R' & s[1]=='R'){
            cout << 2 << endl;
        } else {
            cout << 1 << endl;
        }
    }
}

Measured memory_bytes: 3584
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <functional>
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------



int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N,K;
  cin >> N >> K;
  vector<ll> A(N);
  for(int i=0; i<N; i++) cin >> A[i];
  ll ng=0,ok=INF;
  while(ok-ng>1){
    ll mid = (ng+ok)/2;
    ll cnt = 0;
    for(int i=0; i<N; i++){
      cnt += (A[i]-1)/mid;
    }
    if(cnt <= K){
      ok = mid;
    }else{
      ng = mid;
    }
  }
  cout << ok << "\n";
  return 0;
}

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

int main()
{
	long long N;
	cin >> N;

	long long ans = 0;
	for( long long i = 1; i <= N; i++ ) {
		long long n = N / i;
		ans += n * ( i + i + (n - 1) * i ) / 2;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
 
#define  rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i>=0; i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int M, D; std::cin >> M >> D;

  int ans = 0;
  for(int m=1; m<=M; m++) {
    for(int k=2; k<=std::sqrt(m); k++) {
      if ( m % k == 0 ) {
        int d1 = k;
        int d2  = m/k;
        if ( d1 >= 2 && d2 >= 2 && d1 >=0 && d1 <= 9 && d2 >= 0 && d2 <= 9) {
          if ( d1*10 + d2 <= D ) ans++;
          if ( d1 != d2 && d2*10 + d1 <= D ) ans++;
        }
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


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

int main(void){
    
   int A,B,X;
   cin >> A >> B >> X;
   
   if(A+B < X) cout << "NO" <<endl;
   else if(A > X) cout << "NO" <<endl;
   else cout << "YES" << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long n;
unordered_map<long long, int> f;
int dp(long long n) {
	if (f.count(n)) return f[n];
	return f[n] = ((dp(n / 2) + dp((n - 1) / 2)) % mod + dp((n - 2) / 2)) % mod;
}
int main() {
	scanf("%lld", &n);
	f[0] = 1; f[1] = 2;
	printf("%d", dp(n));
	return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        w: String
    };

    let mut chars: Vec<char> = w.chars().collect();
    let mut is_btfl = true;
    chars.sort();

    for pair in chars.chunks(2) {
        if chars.len() % 2 != 0 {
            is_btfl = false;
            break
        }
        if pair[0] != pair[1] {
            is_btfl = false;
            break
        }
    }
    println!("{}", if is_btfl {"Yes"} else {"No"})
}


Measured memory_bytes: 2188
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

//	1 用于抵消 0，0 可以自消
const int N=300005,mod=1e9+7;
int f[N][4][3],n,ans;
char s[N];

void add(int &x,int y){
	x=(x+y>=mod?x+y-mod:x+y);
}

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	f[0][0][0]=1;
	rep(i,1,n)rep(a,0,3)rep(b,0,2){
		if(s[i]!='1')
			add(f[i][a][b==2?1:b+1],f[i-1][a][b]);
		if(s[i]!='0')
			if(b)add(f[i][a][b-1],f[i-1][a][b]);
			else add(f[i][min(a+1,3)][0],f[i-1][a][b]);
	}
	rep(i,1,3)rep(j,0,i-1)add(ans,f[n][i][j]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14592