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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

int N;
ll A[200100], B[200100];

tuple<ll, ll, ll, ll> f(int n, ll (&A)[200100]){
    int64_t lb = -1, ub = n;

    while(std::abs(ub - lb) > 1){
        int64_t mid = (lb + ub) / 2;

        if(A[mid] <= A[n - 1] - A[mid]){
            lb = mid;
        }else{
            ub = mid;
        }
    }

    ll mn1 = -1, mx1 = -1,
       mn2 = -1, mx2 = -1;
    if(lb >= 0){
        mn1 = A[lb];
        mx1 = A[n - 1] - A[lb];
    }

    if(lb + 1 < n - 1){
        mx2 = A[lb + 1];
        mn2 = A[n - 1] - A[lb + 1];
    }
    
    return std::make_tuple(mn1, mx1, mn2, mx2);
}

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

    std::cin >> N;
    
    for(int i=0;i<N;++i){
        std::cin >> A[i];
    }

    copy(A, A+N, B);
    reverse(B, B+N);

    for(int i=0;i<N;++i){
        A[i + 1] += A[i];
    }

    for(int i=0;i<N;++i){
        B[i + 1] += B[i];
    }

    ll res = numeric_limits<ll>::max();
    for(int n=2;n<=N-2;++n){
        ll mns[4], mxs[4];

        tie(mns[0], mxs[0], mns[1], mxs[1]) = f(n, A);
        tie(mns[2], mxs[2], mns[3], mxs[3]) = f(N - n, B);
        
        for(int i=0;i<2;++i){
            for(int j=0;j<2;++j){
                if(mns[i] == -1 || mns[j+2] == -1){
                    continue;
                }
                
                ll diff = abs(max(mxs[i], mxs[j+2]) - min(mns[i], mns[j+2]));
                res = min(res, diff);
            }
        }
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main(){
  int N = 0,K = 0,ans = 0;
  cin >> N >> K;
  vector<int>A(N);
  rep(i,N){
    cin >> A[i];
  }
  rep(i,N){
    ans += min(A[i],abs(K - A[i]));
  }
  cout << ans * 2;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N, H, W;
	while (cin >> N >> W >> H, W) {
		vector<pair<int, int> > G;
		G.push_back(make_pair(H, W));
		for (int i = 0; i < N; ++i) {
			int id, pos;
			cin >> id >> pos; --id;
			int ch = G[id].first, cw = G[id].second;
			G.erase(G.begin() + id);
			if (pos % (ch + cw) < cw) {
				int wa = pos % (ch + cw), wb = cw - wa;
				G.push_back(make_pair(ch, min(wa, wb)));
				G.push_back(make_pair(ch, max(wa, wb)));
			}
			else {
				int ha = pos % (ch + cw) - cw, hb = ch - ha;
				G.push_back(make_pair(min(ha, hb), cw));
				G.push_back(make_pair(max(ha, hb), cw));
			}
		}
		sort(G.begin(), G.end(), [&](pair<int, int> i, pair<int, int> j) { return i.first * i.second < j.first * j.second; });
		for (int i = 0; i <= N; ++i) {
			cout << G[i].first * G[i].second << (i != N ? " " : "\n");
		}
	}
	return 0;
}


Measured memory_bytes: 3012
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
int dp[40][400][400];
int main(){

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


    int n, m_a, m_b;
    cin >> n >> m_a >> m_b;
    PP A[n];
    int a_sum = 0;
    int b_sum = 0;
    rep(i, n){
        cin >>A[i].first >> A[i].second.first >> A[i].second.second;
        a_sum += A[i].first;
        b_sum += A[i].second.first;
    }
    //int dp[40][400][400];
    /*unable→-1*/

    rep(i, 40){
        rep(k, 400) {
            rep(l, 400) dp[i][k][l] = INF;
        }
    }

    dp[0][0][0] = 0;
    dp[0][A[0].first][A[0].second.first] = A[0].second.second;
    rep(i, n - 1){
        rep(k, 400){
            rep(l, 400) {
                if (dp[i][k][l] == INF) continue;
                dp[i + 1][k][l] = min(dp[i + 1][k][l], dp[i][k][l]);
                if(k + A[i + 1].first >= 399 || l + A[i + 1].second.first >= 399) continue;
                dp[i + 1][k + A[i + 1].first][l + A[i + 1].second.first] = min(dp[i + 1][k + A[i + 1].first][l + A[i + 1].second.first], dp[i][k][l] + A[i + 1].second.second);
            }
        }

    }

    ll int min_1 = INF;
    int h = 1;

    while(h * m_a <= a_sum && h * m_b <= b_sum){
        if(dp[n - 1][h * m_a][h * m_b] < min_1) min_1 = dp[n - 1][h * m_a][h * m_b];
        //cout << dp[n - 1][h * m_a][h * m_b] << endl;
        h ++;

    }
    if(min_1 == INF) cout << -1 << endl;
    else cout << min_1 << endl;


}

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

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

int main() {
  int N, L;
  cin >> N >> L;
  int total = 0;
  for(int i = 0; i < N; ++i) {
    total += L + i;
  }
  int ans = 0;
  int diff_min = 1000000;
  for(int i = 0; i < N; ++i) {
    int tt = total - (L + i);
    if(chmin(diff_min, abs(total - tt))) {
      ans = tt;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)

int main(){

  int h,w,m;
  cin>>h>>w>>m;
  vector<map<int,int>> target(h);
  vector<int> row(h);
  vector<int> col(w);
  rep(i,m){
    int hi,wi;
    cin>>hi>>wi;
    hi--;wi--;
    target[hi][wi] = 1;
    row[hi]++;
    col[wi]++;
  }

  vector<int> w_candidate,h_candidate;
  
  {
    int c_max = 0;
    rep(wi,w)c_max=max(c_max,col[wi]);
    rep(wi,w)
      if(col[wi]==c_max)
        w_candidate.emplace_back(wi);
  }
  {
    int r_max = 0;
    rep(hi,h)r_max=max(r_max,row[hi]);
    rep(hi,h)
      if(row[hi]==r_max)
        h_candidate.emplace_back(hi);
  }

  int ans = 0;
  for(int hi:h_candidate)for(int wi:w_candidate){
    if(target[hi].count(wi))
      ans = max(ans,row[hi]+col[wi]-1);
    else{
      ans = max(ans,row[hi]+col[wi]);
      goto end;
    }
  }

end:
  cout<<(ans)<<endl;

}

Measured memory_bytes: 37928
#include <bits/stdc++.h>
using namespace std;
int n,c,i,j,k,h,w;
string s,a,b;
int main(){
  for(cin>>s;i<s.size()/2;i++)if(s[i]!=s[s.size()-1-i])return cout<<"No",0;
  a=s.substr(0,((s.size()-1))/2);b=s.substr((s.size()+3)/2-1,a.size());
  for(i=0;i<a.size();i++){
    if(a[i]!=a[a.size()-1-i])return cout<<"No",0;
    if(b[i]!=b[b.size()-1-i])return cout<<"No",0;
  }
  cout<<"Yes";
}

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


int main(){
  ll i,j,k,n,m;
  cin >> n >> m;
  vector<ll> a(n);
  vector<pair<ll,ll> >q(m);
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  for(i=0;i<m;i++){
    cin >> q[i].second >> q[i].first;
  }
  //sort(a.begin(),a.end());
  sort(q.begin(),q.end());
  reverse(q.begin(),q.end());
  vector<ll> change(n);
  ll now = 0; //置き換えたところ
  priority_queue<ll> que;
  ll qs=q.size();
  for(i=0;i<qs;i++){
    for(j=0;j<q[i].second;j++){
      //change[now++]=q[i].first;
      que.push(q[i].first);
      now++;
      if(now==n)break;
    }
    if(now==n)break;
  }
  //sort(change.begin(),change.end());
  //reverse(change.begin(),change.end());
  //ll s = change.size();
  for(i=0;i<n;i++){
    que.push(a[i]);
  }
  ll ret = 0;
  //for(i=0;i<s;i++)que.push(change[i]);
  for(i=0;i<n;i++){
    ret+=que.top();
    que.pop();
  }
  cout << ret << endl;
  return 0;
}


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

typedef pair<int,int> P;

vector<int> g[200010];
vector<int> add(200010);
bool used[200010];
int inf = 2000000007;
int ans[200010];

void dfs(int cur,int sum){
  used[cur] = true;
  ans[cur] = sum;
  for(int i = 0;i < g[cur].size();i++){
    int e = g[cur].at(i);
    if(used[e] != true){
      dfs(e,sum+add.at(e));
    }
  }
  return;
}

int main(){
  int n,q;
  cin >> n >> q;
  for(int i = 0;i < n-1;i++){
    int a,b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for(int i = 0;i < n+1;i++){
    used[i] = false;
  }
  for(int i = 0;i < q;i++){
    int p,x;
    cin >> p >> x;
    add.at(p) += x;
  }
  dfs(1,add.at(1));
  for(int i = 1;i <= n;i++){
    cout << ans[i] << ' ';
  }
  cout << ' ' << endl;
}


Measured memory_bytes: 24448
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#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;

using namespace std;

struct sieve{
  int p=0;
  vector<bool> furui;
  sieve(int n){
    furui.resize(n,1);
    furui[0]=0;
    furui[1]=0;
    for(int i=2;i<n;i++)if(furui[i])for(int j=i*2;j<n;j+=i)furui[j]=0;
  }
  bool isprime(int m){return furui[m];}
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  sieve si(n+1);
  ll res=1;
  int mod=1e9+7;
  rep(i,n+1){
    if(si.isprime(i)){
      int tres=0;
      int tn=n;
      while(tn>0){
        tres+=tn/i;
        tn/=i;
      }
      res*=(tres+1);
      res%=mod;

    }
  }
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    double a = scanner.nextDouble();
    double b = scanner.nextDouble();
    double c = scanner.nextDouble();
    double d = scanner.nextDouble();

    int numt = (int) Math.ceil(a/d);
    int numa = (int) Math.ceil(c/b);

    if(numt >= numa) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 28840
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  ll n;
  vector <ll> a;
  cin >> n;
  REP(i,n){
    ll b;
    cin >> b;
    a.pb(b);
  }
  sort(a.begin(),a.end(), greater <ll>() );
  ll w =-1,h = -1;
  rep(i,1,n){
    if(a[i] == a[i-1]){
      w = a[i];
      a.erase(a.begin()+i);
      a.erase(a.begin()+i-1);
      break;
    }
    if(i == n-1){
      cout << 0 << endl;
      return 0;
    }
  }
  
  rep(i,1,a.size()){
    if(a[i] == a[i-1]){
      cout << w*a[i] << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 1400
# coding: utf-8
from itertools import permutations
from math import sqrt

def calc(x0, y0, x1, y1):
    return sqrt((x0 - x1) ** 2 + (y0 - y1) ** 2)

N = int(input())
X, Y = [], []
for i in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
    
ll = list(permutations(range(N)))
ls =[]

for l in ll:
    tmp = 0
    x0, y0 = X[l[0]], Y[l[0]]
    for j in range(1, N):
        x1, y1 = X[l[j]], Y[l[j]]
        tmp += calc(x0, y0, x1, y1)
        x0, y0 = x1, y1
    ls.append(tmp)
    
print(sum(ls) / len(ll))

Measured memory_bytes: 10016
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n,n){
        int ans[12]={},kawa[12];
        for(int i=0;i<n;i++){
                cin>>kawa[i];
                ans[i]=kawa[i];
        }
        for(int i=0;;i++){
            int num[100]={};
            for(int j=0;j<n;j++)num[kawa[j]]++;
            bool rever=1;
            for(int j=0;j<n;j++){
                kawa[j]=num[kawa[j]];
                if(kawa[j]!=ans[j])rever=0;
            }
            if(rever){
                cout<<i<<endl;
                for(int j=0;j<n-1;j++)cout<<kawa[j]<<" ";
                cout<<ans[n-1]<<endl;
                break;
            }
            for(int j=0;j<n;j++)ans[j]=kawa[j];
        }
    }
}

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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 8010, M = 1010;

int n, x, y;
char s[N];
vector<int> hor, ver;
set<int> X[2], Y[2];

int main()
{
	cin >> s >> x >> y;
	n = strlen(s);
	
	for (int i = 0, t = 1; i < n; i ++ , t ^= 1)
	{
		int j = i;
		while (j < n && s[j] == 'F') j ++ ;
		if (t) hor.PB(j - i);
		else ver.PB(j - i);
		i = j;
	}
	
	int tx = 0;
	if (hor.size()) X[tx].insert(hor[0]);
	for (int i = 1; i < hor.size(); i ++ )
	{
		tx ^= 1, X[tx].clear();
		for (auto u : X[tx ^ 1])
		{
			X[tx].insert(u + hor[i]);
			X[tx].insert(u - hor[i]);
		}
	}
	
	int ty = 0;
	Y[ty].insert(0);
	for (int i = 0; i < ver.size(); i ++ )
	{
		ty ^= 1, Y[ty].clear();
		for (auto u : Y[ty ^ 1])
		{
			Y[ty].insert(u + ver[i]);
			Y[ty].insert(u - ver[i]);
		}
	}
	

	if (X[tx].count(x) && Y[ty].count(y)) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
 
  int lo = s.size();
  bool k = true, g = true;
  for (int i = 0; i < lo; i += 2) {
    if (s[i] == 'L') k = false;
  }
  for (int i = 1; i < lo; i += 2) {
    if (s[i] == 'R') g = false;
  }
  if (k && g)cout << "Yes";
  else cout << "No";
  return 0;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string s;
int main(){
	ll n , d;
	cin >> n >> d;
	ll a[n][2],ans=0;
	for(ll i =0;i<n;i++){
	   for(ll j =0;j<2;j++){
		cin >> a[i][j];	   
	   }
	}
	for(ll i=0;i<n;i++){
	   long double x = sqrt( (a[i][0] * a[i][0]) + (a[i][1] * a[i][1] ) );
	   if(d>=x)ans++;
	}
	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 6772
//
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define speed ios::sync_with_stdio(false)
using namespace std;

string gs(char x){
    string s(1,x);
    return s;
}

bool comp(ll a,ll b)
{
	return a>b;
}

int main()
{
	speed;
	
	ll n;
	cin>>n;
	if(n<1000)
	{
		cout<<"ABC";
	}
	else
	{
		cout<<"ABD";
	}
	
	return 0;
}

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

using namespace std;

int H, W;
vector<string> grid(30);

int bfs(int x, int y) {
	vector<vector<int>> d(H, vector<int>(W, -1));
	d[y][x] = 0;
	deque<pair<int, int>> que;
	que.emplace_back(x, y);
	int dx[4] = { 1, -1, 0, 0 };
	int dy[4] = { 0, 0, 1, -1 };
	while (!que.empty()) {
		auto p = que.front(); que.pop_front();
		for (int i = 0; i < 4; ++i) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (nx < 0 || nx >= W || ny < 0 || ny >= H) {
				continue;
			}
			if (d[ny][nx] >= 0 || grid[ny][nx] == '#') { continue; }
			d[ny][nx] = d[p.second][p.first] + 1;
			que.emplace_back(nx, ny);
		}
	}

	int ret = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			ret = max(ret, d[i][j]);
		}
	}
	return ret;
}

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; ++i) { cin >> grid[i]; }

	int ans = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (grid[i][j] == '#') { continue; }
			ans = max(ans, bfs(j, i));
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
use std::collections::LinkedList;
use std::collections::VecDeque;


#[derive(Debug)]
struct EdgeInfo {
    uv: (usize, usize),
    color: Option<usize>,
}

impl EdgeInfo {
    fn new(u: usize, v: usize) -> EdgeInfo {
        EdgeInfo {
            uv: (u, v),
            color: None,
        }
    }
}


fn main() {
    let n: usize = read();
    let mut edge_info = vec![];
    // (next_node_id, EdgeInfo_id)
    let mut tree = vec![LinkedList::<(usize, usize)>::new(); n];

    for i in 0..(n - 1) {
        let e: Vec<usize> = read_vec::<usize>().into_iter().map(|x| (x - 1) as usize ).collect();

        edge_info.push(EdgeInfo::new(e[0], e[1]));
        tree[e[0]].push_back((e[1], i));
        tree[e[1]].push_back((e[0], i));
    }

    let d: usize = tree.iter().map(|x| x.len()).max().expect("Failed to find maximum degree");

    let mut que = VecDeque::new();
    // (node_id, color)
    que.push_back((0, 0));

    while !que.is_empty() {
        let (current_node, mut color_id) = que.pop_front().unwrap();

        let edges = &tree[current_node];
        for &(next_node_id, edge_id) in edges.iter() {
            if edge_info[edge_id].color == None {
                color_id = (color_id + 1) % d;
                edge_info[edge_id].color = Some(color_id);
                que.push_back((next_node_id, color_id));
            }
        }

    }

    println!("{}", d);

    for e in edge_info.iter() {
        println!("{}", e.color.expect("Color not defined") + 1);
    }


}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 18940
#include<bits/stdc++.h>
#define N 2005
#define LL long long
using namespace std;
const int mo=1e9+7;
int n,k,f[N][N],s[N][N],ans;
LL fpm(LL x,LL y){ LL s=1; while(y){ if(y&1) s=(s*x)%mo; y>>=1,x=(x*x)%mo;} return s;}
void inc(int &x,int y){ x=x+y>=mo ? x+y-mo : x+y;}
int main()
{
	int i,j;
	cin>>n>>k;
	f[n+1][0]=s[n+1][0]=1;
	for(i=n;i>=1;i--)
		for(j=n;j>=0;j--){
			if(i!=1) f[i][j]=f[i][j+1];
			inc(f[i][j],s[i+1][j]);
			s[i][j]=s[i+1][j-1];
			inc(s[i][j],f[i][j]);
		  }
	ans=1LL*f[1][n-k]*fpm(2,max(n-k-1,0))%mo;
	cout<<ans;
	return 0;
}


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

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

int main(){
	int A,B;
	cin >> A >> B;

	if(A<10 && B<10) 	cout << A*B << endl;
	else	cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 256
from math import factorial

N, M, K = map(int, input().split())
mod = 10 ** 9 + 7

def f(N):
    a = 1
    for i in range(1, N+1):
        a *= i
        a %= mod
    return a % mod

def Comb(N, K):
    a = f(N)
    b = f(K)
    c = f(N-K)
    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod


c = Comb(N*M-2, K-2)

ans = 0

for d in range(M):
    ans += d * (M - d) * (N ** 2)
    ans %= mod

for d in range(N):
    ans += d * (N - d) * (M ** 2)
    ans %= mod

ans *= c
ans %= mod

print(ans)

Measured memory_bytes: 3064
#include<iostream>
 
using namespace std ;
int main()
{
    char b;
    cin>>b;
 
    if(b=='T'){
        cout<<"A"<<endl;
    }
 
    else if(b=='A'){
        cout<<"T"<<endl;
    }
 
    else if(b=='G'){
        cout<<"C"<<endl;
    }
    else if(b=='C'){
        cout<<"G"<<endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int y,m,d;
	scanf("%d/%d/%d",&y,&m,&d);
	if(y>2019)
	{
		printf("TBD");
		return 0;
	}
	if(y==2019)
	{
		if(m>4)
		{
			printf("TBD");
			return 0;
		}
	}
	printf("Heisei");
	return 0; 
} 

Measured memory_bytes: 256
import java.io.PrintWriter
val pw = PrintWriter(System.out)
fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()
  	val p = listOfInt()
  	val ps = p.map{it}.sorted();
    var count = 0;
    for(i in 0 until n){
      if(p[i] != ps[i]) count++;
    }
    if(count == 0 || count == 2){
      println("YES")
    }else{
      println("NO")
    }
}

// 入力取得
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }
fun listOfLong() =listOfString().map { it.toLong() }
fun listOfDouble() =listOfString().map { it.toDouble() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37700
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
map<ll,ll> mp;
ll a,b,c,d;
ll solve(ll n)
{
    if(n==0) return 0;
    if(n==1) return d;
    if(mp.count(n)) return mp[n];
    ll x=(n/2)*2;
    ll y=((n+1)/2)*2;
    ll p=(n/3)*3;
    ll q=((n+2)/3)*3;
    ll r=(n/5)*5;
    ll s=((n+4)/5)*5;
    ll ans=1e18;
    if(n<(ans/d))  ans=n*d;
    ans=min(ans,abs(n-x)*d+a+solve(x/2));
    ans=min(ans,abs(n-y)*d+a+solve(y/2));
    ans=min(ans,abs(n-p)*d+b+solve(p/3));
    ans=min(ans,abs(n-q)*d+b+solve(q/3));
    ans=min(ans,abs(n-r)*d+c+solve(r/5));
    ans=min(ans,abs(n-s)*d+c+solve(s/5));
    return mp[n]=ans;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t; cin>>t; while(t--){
        ll n; cin>>n>>a>>b>>c>>d;
        ll ans=solve(n);
        cout<<ans<<endl;
        mp.clear();
    }
    
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
// #define for(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9

int main() {
    int N;
    string ans;

    cin >> N;

    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (N == i * j) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    int N;
    cin >> N;
    Vl A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }

    ll sum1 = 0, sum2 = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] > B[i])
            sum1 += A[i] - B[i];
        else
            sum2 += (B[i] - A[i]) / 2;
    }

    cout << (sum2 >= sum1 ? "Yes" : "No") << "\n";

    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

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

using namespace std;

int main(){

  int n;
  scanf("%d", &n);

  list<int> v;
  int rev = 1;
  REP(i,n){
    int t;
    scanf("%d", &t);
    if(rev == 1){
      v.pb(t);
    }else{
      v.pf(t);
    }
    rev *= -1;
  }

  if(rev == -1){
    REPIR(itr,v){
      printf("%d ", *itr);
    }
  }
  else{
    REPI(itr,v){
      printf("%d ", *itr);
    }
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 8576
#include <iostream>
#include<vector>
#include <math.h>
#include<stdio.h>
#include <climits>
#include<algorithm>
#include<string>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define LL  long long 
#define Pi 3.14159265358979;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int h1,h2,m1,m2,k;//入力
	int d=0,i = 0, j = 0, run=0;
	int ans;
	
	cin >> h1 >> m1 >> h2 >> m2 >> k;

	ans = (h2 * 60 + m2) - (h1 * 60 + m1) - k;

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


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

template<typename T> struct Combination
{
    vector<T> fact, rfact, inv;
    Combination(int n) : fact(n + 1), rfact(n + 1), inv(n + 1)
    {
        fact[0] = fact[1] = 1;
        rfact[0] = rfact[1] = 1;
        inv[1] = 1;
        for(int i = 2; i < n + 1; i++)
        {
            fact[i] = fact[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            rfact[i] = rfact[i - 1] * inv[i] % MOD;
        }
    }
    T C(int n, int k)
    {
        if(n < k) return 0;
        if(n < 0 or k < 0) return 0;
        return fact[n] * (rfact[k] * rfact[n - k] % MOD) % MOD;
    }
};

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    Combination<ll> cmb(k);
    cout << cmb.C(k, n) << endl;
    return 0;
}




Measured memory_bytes: 3232
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <vector>
#include <stack>
#define mp make_pair
#define MIN(a,b) (a>b?b:a)
//#define MAX(a,b) (a>b?a:b)
typedef long long ll;
typedef unsigned long long ull;
const int MAX=1e5+5;
const int INF=1e9+5;
using namespace std;
//const int MOD=1e9+7;
typedef pair<ll,int> pii;
typedef pair<ll,ll> pll;
const double eps=0.00000001;
ll n,an,m=INF;
vector<pll>edge[MAX];
ll c[MAX];
void calc(ll now,ll pre)
{
    c[now]=1;
    for(auto &X:edge[now])
    {
        ll to,val;
        tie(to,val)=X;
        if(to==pre)
            continue;
        calc(to,now);
        c[now]+=c[to];
    }
}
void solve(ll now,ll pre,ll len)//从pre连到now的一条长为len的边
{
    an+=2*len*min(c[now],n-c[now]);
    pll mx={-1,-1};//now的最大子树的节点数 及连向其的边的权值
    for(auto &X:edge[now])
    {
        ll to,val;
        tie(to,val)=X;
        if(to==pre)
            continue;
        mx=max(mx,{c[to],val});
    }
    mx=max(mx,{n-c[now],len});
    if(2*mx.first==n)
        m=min(m,mx.second);
    else if(2*mx.first<n)
    {
        for(auto &X:edge[now])
            m=min(m,X.second);
    }
    for(auto &X:edge[now])
    {
        ll to,val;
        tie(to,val)=X;
        if(to==pre)
            continue;
        solve(to,now,val);
    }
}

int main()
{
    scanf("%lld",&n);
    for(ll i=1;i<n;i++)
    {
        ll A,B,C;
        scanf("%lld%lld%lld",&A,&B,&C);
        edge[A].push_back({B,C});
        edge[B].push_back({A,C});
    }
    calc(1,0);
    solve(1,0,0);
    printf("%lld\n",an-m);

}


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

int w, h, x, y, r;
int Hor(int W, int X, int R)
{
	if (X - R >= 0 && X + R <= W)
		return 1;
	else
		return 0;
}

int Ver(int H, int Y, int R)
{
	if (Y - R >= 0 && Y + R <= H)
		return 1;
	else
		return 0;
}

int main()
{
	cin >> w >> h >> x >> y >> r;
	if (Hor(w, x, r)*Ver(h, y, r) == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define ld long double
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
int a[505][505];
int main(){
	int k=read(),n=(k+3)/4*2;
	if(k==1){
		puts("1\n1"); exit(0);
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)a[i][j]=(i&1)?(i+j)%n+n:(i+j)%n;
	}
	for(int i=2*n-1;i>=k;i--){
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++)if(a[j][k]==i)a[j][k]-=n;
		}
	}
	writeln(n);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)wri(a[i][j]+1); puts("");
	}
}


Measured memory_bytes: 2176
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;



int main() {
    int n,cnt=0,ju=0; cin>>n;
    for(int i=2;i<=55555;i++){
        if(ju==1) break;
        for(int j=2;j*j<=i;j++){
            if(i%j==0) break;
            if((j+1)*(j+1)>i && i%5==1){
                cout<<i; cnt++;
                if(n!=cnt) cout<<" ";
                if(n==cnt){
                    cout<<endl;
                    ju=1;
                }
            }
        }
    }
}

Measured memory_bytes: 256
package main

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

func main() {
	scan_init()
	n := scanInt()
	a := make([]int,n)
	for i:= 0; i<n; i++ {
		a[i] = scanInt()
	}
	sum := a[0]
	for i:= 1; i<n;i++ {
		sum ^= a[i]
	}
	for i:= 0; i<n; i++ {
		fmt.Println(sum^a[i])
	}
}
var sc = bufio.NewScanner(os.Stdin)
func scan_init () {
	sc.Split(bufio.ScanWords)
}
func scanInt () int{
sc.Scan()
	i,_ := strconv.Atoi(sc.Text())
	return i
}
//func scan () string{
//  sc.Scan()
//	return sc.Text()
//}


Measured memory_bytes: 7272
#abc174 c
K = int(input())
amari = set([])
cnt = 0
while True:
    cnt +=1
    if cnt ==1:
        num = 7
    else:
        num = (num*10+7)%K
    tmp = num%K

    if tmp == 0:
        print(cnt)
        exit()
    else:
        if tmp in amari:
            print(-1)
            exit()
        else:
            amari |=set([tmp])


Measured memory_bytes: 77860
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();

		String answer = "NG";
		for(int i = A;i <= B; i++) {
			if(i % K == 0) {
				answer = "OK";
				break;
			}
		}
		System.out.println(answer);

	}

}


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

ll f(ll n){
  if (n==1) return 1;
  else return 2*f(n/2)+1;
}
int main(){
  ll h;
  cin >> h;
  ll ans = f(h);
  cout << ans << endl;
  return 0;
}

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

int n, m, p, d;
int grid[100][100];

bool check()
{
	int y = 1;
	int x = m;
	for (; y <= d; y++){
		x += grid[y][x];
	}
	return p == x;
}

int main()
{
	while (scanf("%d", &n), n){
		memset(grid, 0, sizeof(grid));
		scanf("%d %d %d", &m, &p, &d);
		for (int y = 1; y <= d; y++){
			for (int x = 1; x <= n - 1; x++){
				char c;
				scanf(" %c", &c);
				if (c != '1') continue;
				grid[y][x] = 1;
				grid[y][x + 1] = -1;
			}
		}
		
		if (check()){
			puts("0");
			continue;
		}
		
		for (int y = 1; y <= d; y++){
			for (int x = 1; x <= n - 1; x++){
				if (grid[y][x] || grid[y][x + 1]) continue;
				grid[y][x] = 1;
				grid[y][x + 1] = -1;
				if (check()){
					printf("%d %d\n", y, x);
					goto BREAK;
				}
				grid[y][x] = 0;
				grid[y][x + 1] = 0;
			}
		}
		
		puts("1");
		
		BREAK:;
	}
	return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
//#define uint __int128_t
 
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;
 
int N,M;
vpint g[200020];
struct LazySegmentTree{
    private:
    int n;
    vector<ll> node,lazy;


    public:
    LazySegmentTree(vector<ll> v){
        int sz = (int)v.size();
        n = 1;while(n < sz)n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1,0);

        for(int i=0;i<sz;i++)node[i+n-1] = v[i];
        for(int i=n-2;i>=0;i--)node[i]=max(node[2*i+1],node[2*i+2]);
    }

    void eval(int k,int l,int r){
        if(lazy[k] != 0){
            node[k] += lazy[k];

            if(r-l > 1){
                lazy[2*k+1] += lazy[k];
                lazy[2*k+2] += lazy[k];
            }
            lazy[k] = 0;
        }
    }

    void add(int a,int b,ll x,int k=0,int l=0,int r=-1){
        if(r<0)r = n;

        eval(k,l,r);
        if(b <= l || r <= a)return;

        if(a <= l && r <= b){
            //SUMじゃなければ+= xで更新
            lazy[k] += x;
            eval(k,l,r);
        }
        else{
            add(a,b,x,2*k+1,l,(l+r)/2);
            add(a,b,x,2*k+2,(l+r)/2,r);
            node[k] = max(node[2*k+1],node[2*k+2]);
        }
    }
    ll getmax(int a,int b,int k=0,int l=0,int r=-1){
        if(r < 0)r = n;
        if(b <= l || r <= a)return 0;
        eval(k,l,r);
        if(a <= l && r <= b)return node[k];
        ll vl = getmax(a,b,2*k+1,l,(l+r)/2);
        ll vr = getmax(a,b,2*k+2,(l+r)/2,r);
        return max(vl,vr);
    }
};

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    //MOD同士の引き算に注意
    cin>>N>>M;
    vint a(M),l(M),r(M);
    LazySegmentTree seg(vint(N+2,0));
    rep(i,0,M){
        cin>>l[i]>>r[i]>>a[i];
        r[i]--;l[i]--;
        g[r[i]].pb(pint(l[i],a[i]));
    }
    
    rep(i,0,N){
        int now=0;
        if(i)chmax(now,seg.getmax(0,i));
        //cout<<now<<endl;
        seg.add(i,i+1,now);
        for(auto e:g[i]){
            seg.add(e.fi,i+1,e.se);
        }
    }
    cout<<max(0ll,seg.getmax(0,N+1))<<endl;
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 25060
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
const ll MAXN=151;
string x;
ll kk,l;
ll dp[MAXN][4][2];
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
} 
inline ll dfs(ll l,ll cur,ll x)
{
	ll p,res=0;
	if(cur>kk)
	{
		return 0;
	}
	if(l>=::l)
	{
		return cur==kk;
	}
	if(dp[l][cur][x]!=-1)
	{
		return dp[l][cur][x];
	}
	p=x==1?::x[l]-'0':9;
	for(register int i=0;i<=p;i++)
	{
		res+=dfs(l+1,cur+!!i,x&&i==p);
	}
	return dp[l][cur][x]=res;
}
int main()
{
	cin>>x,kk=read(),l=x.length(),memset(dp,-1,sizeof(dp));
	printf("%lld\n",dfs(0,0,1));
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
  int N;
  cin >> N;
  int A[N];
  for(int i=0; i<N; i++)
    cin >> A[i];

  for(int i=0; i<N; i++){
    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: 256
#include <bits/stdc++.h>
using namespace std;

int main() {

   int a[3];
   for(int i=0;i<3;i++)
   {
   	cin>>a[i];
   }
   int rem=(a[2]-(a[0]-a[1]));
   if(rem>=0)
   	cout<<rem;
   else
   	cout<<0;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();
    for (int i = 0; i < K; i++) {
      if (i%2 == 0) {
        if (A%2 == 1) {
          A--;
        }
        B += A/2;
        A /= 2;
      } else {
        if (B%2 == 1) {
          B--;
        }
        A += B/2;
        B /= 2;
      }
    }
    System.out.println(A + " " + B);
  }
}

Measured memory_bytes: 21844
num = input().split()
type = int(num[0])
target = int(num[1])
list = input().split()
listnum = []
for i in list:
  listnum.append(int(i))

count = 0
sum = 0
for i in listnum:
  sum += i

for i in listnum:
  if i >= sum/(4*target):
    count += 1

if count >= target:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define bitcount(x)  __builtin_popcount(x)
#define bitcountll(x)  __builtin_popcountll(x)
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 200005
int main()
{
    int n,a,x,i;
    in(n);
    int ans=0;
    lp(i,1,n+1)
    {
        a=i,x=0;
        while(a>0)
            x++,a/=10;
        if(x&1)
            ans++;
    }
    out(ans);
}





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

int main() {
  int n,m;
  cin >>n>>m;
  vector<pair<int,int>>p(n);
  for(int i=0;i<n;i++){
    cin>>p[i].first>>p[i].second;
  }
  sort(p.begin(),p.end());
  for(int i=0;i<n;i++){
    if(p[i].second<=m){
      cout<<p[i].first;
      return 0;
    }
  }
  cout<<"TLE"<<endl;
  return 0;
}

Measured memory_bytes: 256
# 73

MOD = 10**9 + 7
x, y = map(int, input().split())

a = 2*y - x
b = 2*x - y

fac_l = [0] * (int((a + b) / 3) + 1)
inv_l = [0] * (int((a + b) / 3) + 1)
finv_l = [0] * (int((a + b) / 3) + 1)


def com_init():
    fac_l[1] = 1
    inv_l[0] = 1
    inv_l[1] = 1
    finv_l[0] = 1
    finv_l[1] = 1
    for i in range(2, a+b+1):
        fac_l[i] = (fac_l[i-1] * i) % MOD
        inv_l[i] = MOD - (inv_l[MOD % i] * int(MOD / i)) % MOD
        finv_l[i] = (finv_l[i-1] * inv_l[i]) % MOD

def ncr(n, r):
    return (fac_l[n] * (finv_l[r] * finv_l[n-r]) % MOD) % MOD


if a % 3 != 0 or b % 3 != 0 or a < 0 or b < 0:
    print("0")
else:
    a = int(a/3)
    b = int(b/3)

    com_init()
    print(ncr(a+b, a))


Measured memory_bytes: 88076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
ll n, m, q;
vector<ll> a, b, c, d;
ll calc(vector<ll> &A) {
    ll res = 0;
    for (ll i = 0; i < q;i++){
        if (A[b[i] - 1] - A[a[i] - 1] == c[i]) res += d[i];
    }
    return res;
}
ll dfs(vector<ll> &A){
    if (A.size() == n) return calc(A);
    ll res = 0;
    ll last;
    if (A.empty()) last = 0;
    else
        last = A.back();
    for (ll i = last; i < m;i++){
        A.push_back(i);
        chmax(res, dfs(A));
        A.pop_back();
    }
    return res;
}
int main() {
cin >> n >> m >> q;
a.resize(q);
b.resize(q);
c.resize(q);
d.resize(q);
vector<ll> A;
for (ll i = 0; i < q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
cout << dfs(A) << endl;
}


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

int main() {
  int N; cin >> N;
  int counter = 0;
  rep(i,N){
    int A; cin >> A;
    if (A%2 == 1) counter++;
  }  
  if(counter%2==1){
    cout << "NO" << endl;
    return 0;
  }else{
    cout << "YES" << endl;
    return 0;
  }

}

Measured memory_bytes: 3600
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        int go,day,furo,puru,Fken,Pken,wari;
        Scanner sc=new Scanner(System.in);
        day=sc.nextInt();
        
        for(int a=0;a<day;a++){
            furo=sc.nextInt();
            puru=sc.nextInt();
            Fken=sc.nextInt();
            Pken=sc.nextInt();
            go=furo*Fken+puru*Pken;
            
            if(Fken>=5 && Pken>=2){
                go=go*8/10;
                
            }else{
                if(Fken<5){
                Fken=5;
                
            }if(Pken<2){
                Pken=2;
              
            }
              wari=(furo*Fken+puru*Pken)*8/10;  
       
               if(wari<go){
                go=wari;
               }
            }
           System.out.println(go);
        }
    }
}
            
            
                
            
                

Measured memory_bytes: 23452
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n; cin >> n; std::vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	
	std::vector<int> dp(n + 1, 0);
	for(int i = 0; i < n; i++) {
		dp[a[i]] = dp[a[i] - 1] + 1;
	}
	std::vector<int> dp2(n + 2, 0);
	for(int i = n - 1; i >= 0; i--){
		dp2[a[i]] = dp2[a[i] + 1] + 1;
	}
	
	int ans = n;
	for(int i = 1; i < n + 1; i++) {
		ans = std::min(ans, n - dp[i]);
		ans = std::min(ans, n - dp2[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
n, m = map(int, input().split())

ac = [False] * n
pena = [0] * n

acCnt = 0
waCnt = 0
for i in range(m):
  p, s = input().split()
  p = int(p) - 1
  if ac[p]:
    continue
  if s == 'AC':
    ac[p] = True
    acCnt += 1
    waCnt += pena[p]
  else:
    pena[p] += 1

print(acCnt, waCnt)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  vector<int> MY={A, B, C};
  sort(MY.begin(), MY.end());
  int ni=1;
  for(int i=1;i<=K;i++){
    ni*=2;
  }
  cout << MY.at(0)+MY.at(1)+ni*MY.at(2) << endl;
}
  

Measured memory_bytes: 256
using System;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            string nm = System.Console.ReadLine().Replace('?','D');
            System.Console.WriteLine(nm);
            int num = 0;
            int foundIndex = nm.IndexOf("PD");
            while (0 <= foundIndex)
            {
                //見つかった位置を表示する
                num = num + 1;

                //次の検索開始位置
                int nextIndex = foundIndex + 2;
                
                if (nextIndex < nm.Length)
                {
                    //次の位置を探す
                    foundIndex = nm.IndexOf("PD", nextIndex);
                }
                else
                {
                    //最後まで検索したときは終わる
                    break;
                }
            }


     



        }
        public static int CountChar(string s, char c)
        {
            return s.Length - s.Replace(c.ToString(), "").Length;
        }


    }
}


Measured memory_bytes: 27116
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll a,b,h;
  cin >> a >> b >> h;
  cout << (h*(a+b))/2<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long

int inf = (1LL <<  62);

using namespace std;

signed main(){
    int n;
    cin >> n;
    vector<vector <int>> v(3);
    int ans = 0;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < n; j++){
            int x;
            cin >> x;
            v[i].push_back(x);
        }
        sort(v[i].begin(), v[i].end());
    }
    for(int i = 0; i < n; i++){
        int x = v[1][i];
        auto a = lower_bound(v[0].begin(), v[0].end(), x);
        int as;
        if(a == v[0].end()){
           as = n;
        }else{
            as = distance(v[0].begin(), a);
        }
        auto b = upper_bound(v[2].begin(), v[2].end(), x);
        if(b == v[2].end()){
            continue;
        }
        int bs = distance(b, v[2].end());
        ans += as * bs;
    }
    cout << ans;
}

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

namespace ConsoleApp15
{
    class Class291
    {
        static void Main()
        {
            var R = int.Parse(Console.ReadLine());
            double PI = 3.14;
            Console.WriteLine(2*PI*R);

        }
    }
}


Measured memory_bytes: 27592
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int a, b;
	scanf("%d %d", &a, &b);
	for(int c = 1; c <= 3; c++){
		if ((a * b * c) % 2 == 1) {
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
}

Measured memory_bytes: 128