akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define nl '\n'
 
#define y1 aza_ibagaliev
 
#define f first
#define s second
	
#define ed end()
#define bg begin()
#define rbg rbegin()
 
#define rv reverse
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ppf pop_front
 
#define sz size()
#define all(x) x.bg, x.ed
 
#define pll pair < ll, ll >
#define pii pair < int, int >
 
#define sqr(x) ((x) * 1ll * (x))
#define sqrd(x) ((x) * 1.0 * (x))
 
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define rnl cout << "----------------------------------------" << nl
 
#define bit __builtin_popcount
 
inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
        	
const int ppr = 257;
const ll INF = 2e18;
const int inf = 2e9;
const int mod = 1e9 + 7;
const int N = 1e6 + 123;
const ld pi = acos(-1.0);
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int n, ans, x;
bool u[N];
 
main() {             	
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
 
//	srand(time(NULL));

//	speed;

	cin >> n;

	u[0] = 1;
	ans = -1;
	for(int i = 1; i <= n; i++) {
		cin >> x;
		if(u[x - 1]) {
			u[x] = 1;
			ans = max(ans, x);
		}
	}

	if(ans == -1) return cout << ans, 0;
	cout << n - ans;
          
    return 0;                                        
}

Measured memory_bytes: 384
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <string>
using namespace std;
string s;
int main() {
	cin>>s;
	int R=0;
	int a0,a1,a2,a3;

	for(a0=0;a0<s.size();a0=a3){
		for(a1=a0;s[a1]=='J';a1++);
		for(a2=a1;s[a2]=='O';a2++);
		for(a3=a2;s[a3]=='I';a3++);
		if(a1-a0>=a2-a1&&a2-a1<=a3-a2)R=max(R,a2-a1);
	}
	cout<<R<<endl;
	return 0;
}

Measured memory_bytes: 3988
k,n = map(int,input().split())
a = list(map(int,input().split()))
tmp = a[0] + (k - a[n-1])
for i in range(n-1):
         if a[i+1] - a[i] > tmp:
                  tmp = a[i+1] - a[i]
print(k - tmp)         



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

int main(void){
    long long int a, b, c, ans=0;
    scanf("%lld %lld %lld", &a, &b, &c);
    ans = b;
    if(c-1>(a+b)) ans += (a+b+1);
    else ans += c;
    printf("%lld", ans);
}

Measured memory_bytes: 128
N = int(input())
Second = 0
MaxA = 0

for x in range(N):
    A = int(input())
    if MaxA <= A:
        Second = MaxA
        MaxA = A
        i = x
        continue
    if Second < A:
        Second = A

for x in range(N):
    if x == i:
        print(Second)
    else:
        print(MaxA)

Measured memory_bytes: 4540
a,b,i,t;long long k=1;L(x,y){!y?t=x:L(y,x%y);}main(n){for(;scanf("%d%d",&a,&b)*a;L(n,k),k*=n/t,n=++i>2?i=!printf("%lld\n",k),k=1:1)for(t=a;t-1;t=t*a%b)++n;}

Measured memory_bytes: 0
n=gets.chomp.to_i
a=gets.split.map(&:to_i)

a.map!{|e| -e} if a[0]<0

s, m=a[0], 0
if a[0]==0
  s, m=1, 1
end
(1...n).each do |i|
  s+=a[i]
  if i%2==0
    if s<=0
      m+=(-s+1)
      s=1
    end
  else
    if s>=0
      m+=s+1
      s=-1
    end
  end
end

s, m2=-1, a[0]+1
(1...n).each do |i|
  s+=a[i]
  if i%2==0
    if s>=0
      m2+=s+1
      s=-1
    end
  else
    if s<=0
      m2+=(-s+1)
      s=1
    end
  end
end

puts [m, m2].min


Measured memory_bytes: 8588
M = Hash.new{|h, k| h[k] = 0}
gets.to_i.times{
  s = gets.chomp
  M[s[0]] += 1 if ['M', 'A', 'R', 'C', 'H'].include?(s[0])
}

ans = 0
M.keys.combination(3){|a, b, c|
  ans += M[a] * M[b] * M[c]
}

puts ans


Measured memory_bytes: 1788
#include<iostream>

using namespace std;
    int n=100;
    int x;
    int cnt=0;

void solve(){
    cnt = 0;
    for(int i=1;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n+1;k++){
                if(i+j+k == x) cnt++;
            }
        }
    }
    cout << cnt << endl;
}

int main(){
    int flag = 0;
    while(!flag){
        cin >> n >> x;
        if(n == 0){
            break;
        }
        solve();
    }
    return 0;
}


Measured memory_bytes: 3092
n = int(input())
dlist = list(map(int, input().split()))

dlist_sorted = sorted(dlist)

kiwa_upper = dlist_sorted[n//2]
kiwa_low = dlist_sorted[(n//2)-1]

# 同じ数の選び方が存在しない場合
if len(dlist_sorted[n//2:]) != n//2:
    print(0)
# 存在する場合
else:
    print(kiwa_upper - kiwa_low)

Measured memory_bytes: 20464
#include <iostream>
#include <algorithm>
#include <vector>
#define pb push_back

using namespace std;

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

const int NMAX = 500005;

int aint[4*NMAX];
char s[NMAX];

void build(int nod, int st, int dr);
void update(int nod, int st, int dr, int poz, char c);
int query(int nod, int st, int dr, int x, int y);
int prelucreaza(int x);

int main()
{
    int n, m, t, st, dr;
    char c;

    cin >> n;
    cin >> s+1;
    build(1,1,n);
    cin >> m;
    while (m--)
    {
        cin >> t;
        if (t == 1)
        {
            cin >> st >> c;
            update(1,1,n,st,c);
        }
        else
        {
            cin >> st >> dr;
            int aux = query(1,1,n,st,dr);
            cout << prelucreaza(aux) << '\n';;
        }
    }
    return 0;  
}

void build(int nod, int st, int dr)
{
    if (st == dr)
    {
        aint[nod] = 1 << (s[st]-'a');
        return;
    }
    int mij = (st+dr)/2;
    build(2*nod,st,mij);
    build(2*nod+1,mij+1,dr);
    aint[nod] = aint[2*nod] | aint[2*nod+1];
}

void update(int nod, int st, int dr, int poz, char c)
{
    if (st == dr)
    {
        aint[nod] = 1 << (c-'a');
        return;
    }
    int mij = (st+dr)/2;
    if (poz <= mij)
        update(2*nod,st,mij,poz,c);
    else
        update(2*nod+1,mij+1,dr,poz,c);
    aint[nod] = aint[2*nod] | aint[2*nod+1];
}

int query(int nod, int st, int dr, int x, int y)
{
    if (x <= st && dr <= y)
        return aint[nod];
    int mij = (st+dr)/2;
    int nr1=0, nr2=0;
    if (x <= mij)
        nr1 = query(2*nod,st,mij,x,y);
    if (y > mij)
        nr2 = query(2*nod+1,mij+1,dr,x,y);
    return nr1 | nr2;
}

int prelucreaza(int x)
{
    int ans = 0;
    while (x)
    {
        ans += (x & 1);
        x >>= 1;
    }
    return ans;
}

Measured memory_bytes: 6400
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>

struct edge
{
  int to;
  int cap;
  int rev;
};

std::vector<edge> edges[202];
int level[202];
int iter[202];

void add_edge(int from, int to, int cap)
{
  edges[from].emplace_back(edge{to, cap, edges[to].size()});
  edges[to].emplace_back(edge{from, 0, edges[from].size() - 1});
}

void bfs(int from)
{
  std::memset(level, -1, sizeof(level));
  std::queue<int>  q;
  level[from] = 0;
  q.push(from);
  while (q.size() > 0)
  {
    int v = q.front(); q.pop();
    for (auto& e : edges[v])
    {
      if (e.cap > 0 && level[e.to] < 0)
      {
        level[e.to] = level[v] + 1;
        q.push(e.to);
      }
    }
  }
}

int dfs(int v, int to, int f)
{
  if (v == to) return f;
  for (int &i = iter[v]; i < edges[v].size(); ++i)
  {
    edge& e = edges[v][i];
    if (e.cap > 0 && level[v] < level[e.to])
    {
      int d = dfs(e.to, to, std::min(f, e.cap));
      if (d > 0)
      {
        e.cap -= d;
        edges[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int from, int to)
{
  int flow = 0;
  while (true)
  {
    bfs(from);
    if (level[to] < 0) break;
    std::memset(iter, 0, sizeof(iter));
    int f;
    while ((f = dfs(from, to, 1e9)) > 0)
    {
      flow += f;
    }
  }
  return flow;
}

int redx[100], redy[100];
int bluex[100], bluey[100];

int main()
{
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
  {
    scanf("%d%d", redx + i, redy + i);
  }
  for (int i = 0; i < n; ++i)
  {
    scanf("%d%d", bluex + i, bluey + i);
  }
  for (int i = 0; i < n; ++i)
  {
    add_edge(2 * n, i, 1);
    add_edge(n + i, 2 * n + 1, 1);
    for (int j = 0; j < n; ++j)
    {
      if (redx[i] < bluex[j] && redy[i] < bluey[j])
      {
        add_edge(i, j + n, 1);
      }
    }
  }
  int ans = max_flow(2 * n, 2 * n + 1);
  printf("%d\n", ans);
  return 0;
}


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


int selectionSort(int *A,int  N){
int i,j,n,minj,x=0;

 for(i = 0;i<N;i++){
        minj=i;
        for(j=i;j<N;j++){
                if(A[j]<A[minj]){
                minj=j;
        }}
        if(i!=minj){
        n=A[i];
        A[i]=A[minj];
        A[minj]=n;
        x++;
        }
 }
return x;
}

int main(void){
 int N,x,i;
 int *A;

 scanf("%d",&N);
 A=(int *)malloc(N * sizeof(int));
 for (i=0; i<N;i++){
  scanf("%d",&A[i]);
 }

x=selectionSort(A,N);

printf("%d",A[0]);
 for(i=1;i<N;i++){
  printf(" %d",A[i]);
 }
printf("\n%d\n",x);

free(A);
return 0;
}

Measured memory_bytes: 1856
a = input().split() + input().split() + input().split()
n = int(input())
hit = [False] * 9
for _ in range(n):
    b = input()
    for i, ai in enumerate(a):
        if ai == b:
            hit[i] = True
            break
bingo = False
for i in range(3):
    if all(hit[i * 3:(i + 1)*3]):
        bingo = True
        break
    if all(hit[i::3]):
        bingo = True
        break
if all(hit[::4]) or all(hit[2:7:2]):
    bingo = True
print("Yes" if bingo else "No")

Measured memory_bytes: 3064
n = int(input())
s = input()
c = s.count('R')*s.count('G')*s.count('B')

for i in range(n):
    for j in range(i+1,n):
        if j + j - i >= n:break
        # print(j+j-i+1)
        if s[i]!=s[j] and s[j]!=s[j+j-i] and s[i]!=s[j+j-i]:
            c-=1

print(c)

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

int main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n;
    cin>>n;
    if(n%1000==0)
        cout<<"0";
    else
        cout<<1000-n%1000;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  int a,b;

  bool ok;
  int ans=0;
  cin>>n>>m;
  int ed[n][n]={};
  vector<int>v(n);
  for(int i=0;i<m;i++){
    cin>>a>>b;
    ed[a-1][b-1]=1;
    ed[b-1][a-1]=1;  
  }
  for(int i=0;i<n;i++){
    v.at(i)=i;
  }
  sort(v.begin(), v.end());

  do{
    ok=true;
    if(v.at(0)!=0)continue;
    for(int i=1;i<n;i++){
      a=v[i-1];
      b=v[i];
      if(!ed[a][b])ok=false;
    }
    if(ok) ans++;
    
    
  }while(next_permutation(v.begin(), v.end()));
  cout<<ans;
  
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,0,n) cin>>a[i];
    sort(all(a));
    
    int x=a[n-1];
    cout<<x<<" ";
    a.pop_back();
  int k=lower_bound(all(a),x/2)-a.begin();
  int l=a[max(0,k-1)];
  int r=a[min(k,n-2)];
  if(x/2-l < r-x/2) cout<<l<<endl;
  else cout<<r<<endl;
}


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

int main(){
    int N,M; long long K;
    cin >> N >> M >> K;
    vector<long long> A(N),B(M);
    vector<long long> SA(N+1,0),SB(M+1,0);
    for(int i = 0; i < N; i++) cin >> A[i], SA[i+1] = SA[i] + A[i];
    for(int i = 0; i < M; i++) cin >> B[i], SB[i+1] = SB[i] + B[i];
    
    int ans = 0;
    for(int i = 0; i < N + 1; i++){
        long long target = K - SA[i];
        if(target < 0)continue;
        int a = upper_bound(SB.begin(),SB.end(),target) - SB.begin();
        //cout << target << " " << a - 1 << " " << i << endl;
        ans = max(a - 1 + i  ,ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 9576
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    string ans;
    int nx=tx-sx,ny=ty-sy;
        rep(i,nx)ans+="R";
        rep(i,ny)ans+="U";
        rep(i,nx)ans+="L";
        rep(i,ny)ans+="D";
        ans+="D";
        rep(i,nx+1)ans+="R";
        rep(i,ny+1)ans+="U";
        ans+="L";
        ans+="U";
        rep(i,nx+1)ans+="L";
        rep(i,ny+1)ans+="D";
        ans+="R";
    cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int i,j,m,n,a[100],sum=0;
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>a[i];sum+=a[i];
	}
	float x;
	x=1.0*sum/(4*m);
	sort(a,a+n);
	if(a[n-m]>=x)
	cout<<"Yes";
	else
	cout<<"No";

	
 } 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(A, B) << " " << max(A + B - N, 0) << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())

cnt = 0
def func(cur):
  global cnt
  if cur>N: return
  if set(str(cur)) == {'3', '5', '7'}: cnt += 1
  func(cur*10 + 3)
  func(cur*10 + 5)
  func(cur*10 + 7)

func(0)
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
        int N,a[30];
        cin >> N;
        bool dp[21][2001]={0};
        for(int i=0 ; i<N ; i++ ){
                cin >> a[i];
                dp[i][0]=1;
        }
        dp[0][0]=1;
        for(int i=1 ; i<=N ; i++ ){
                for(int j=1 ; j<=2000 ; j++ ){
                        if(j>=a[i-1])
                                dp[i][j]=dp[i-1][j-a[i-1]]|dp[i-1][j];
                        else
                                dp[i][j]=dp[i-1][j];
                }
        }
        int m;
        cin >> m;
        int x;
        for(int i=0 ; i<m ; i++ ){
                cin >> x;
                if(dp[N][x])cout<<"yes"<<endl;
                else    cout<<"no"<<endl;
        }
        return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <algorithm>
#include <cctype>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);

int a,b,c,tyo=0,hi=0;
char t;

int main(){
	while(cin>>a>>t>>b>>t>>c){
		if(c*c==a*a+b*b) tyo++;
		if(a==b) hi++;
	}
	cout<<tyo<<endl;
	cout<<hi<<endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) cin >> vec.at(i);

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

  if (vec.at(N / 2 - 1) == vec.at(N / 2)) cout << 0 << endl;
  else cout << vec.at(N / 2) - vec.at(N / 2 - 1) << endl;
}

Measured memory_bytes: 640
#[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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        a: i32,
        b: i32,
    }
    let plus = a + b;
    let minus = a - b;
    let mul = a * b;
    println!("{}", [plus, minus, mul].iter().max().unwrap());
}


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

const long double PI = (acos(-1));

int main(){
    long double a, b, x;
    cin >> a >> b >> x;

    long double ans;

    if(x <= a*a*b/2.0){
        ans = PI/2 - atan(2*x/(a*b*b));
    }else{
        ans = atan(2*b/a - 2*x/(a*a*a));
    }

    cout << fixed << setprecision(10) << ans * 180.0 / PI << endl;
    //cout << ans*180.0/PI << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
bitset <2005> pre[2005], suf[2005];
bitset <2005> preA[2005], sufA[2005];

int dp[2005][2005];
int a[2005][2005];
int n;
char txt[2005];

int delP[2005], delS[2005];

int main(int argc, char const *argv[])
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		a[i][i] = 1;
	}
	for(int i = 2; i <= n; i++) {
		scanf("%s", txt);
		for(int j = 1; j < i; j++) {
			int c = txt[j - 1] - '0';
			a[i][j] = c;
			a[j][i] = c ^ 1;
		}
	}
	for(int len = 1; len < n; len++) {
		for(int i = 1; i <= n; i++) {
			int j = i + len;
			if(j > n) break;
			if(len == 1) {
				dp[i][j] = 1;
			} else {
				bitset <2005> xx = preA[i] & suf[j];
				xx |= pre[i] & sufA[j];
				if(xx.count() > 0) {
					dp[i][j] = 1;
				} else {
					dp[i][j] = 0;
				}
			}
			if(dp[i][j]) {
				preA[i][j] = 1;
				sufA[j][i] = 1;
				if(a[j][i]) {
					suf[j][i] = 1;
				}
				if(a[i][j]) {
					pre[i][j] = 1;
				}
			}
		}
	}
	delP[1] = 1;
	for(int i = 2; i <= n; i++) {
		for(int j = 1; j < i; j++) {
			if(a[i][j] && dp[j][i]) {
				delP[i] |= delP[j];
			}
		}
	}
	delS[n] = 1;
	for(int i = n - 1; i >= 1; i--) {
		for(int j = i + 1; j <= n; j++) {
			if(a[i][j] && dp[i][j]) {
				delS[i] |= delS[j];
			} 
		}
	}
	int cnt = 0;
	for(int i = 1; i <= n; i++) {
		if(delP[i] && delS[i]) {
			++cnt;
		}
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 33792
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x))
#define vec1(a,n) vector<in> a(n);rep(i,n)cin>>a[i]

int main(){
in n;cin>>n;
  vector<in> a(0);
  while(n>0ll){
    a.push_back(n%10ll);
    n /=10ll;
  }
  in t=0ll;
  in ten=1ll;
  
  for (in tmp = 0; tmp < (1 <<(a.size()-1ll)); tmp++) {
  bitset<9> s(tmp);
    t +=a[0];
  for(in i=0;i<a.size()-1ll;i++){
     if(s.test(i)){ten =1ll;}
    else{ten *=10ll;}
    t += ten * a[i+1];
  }
    ten =1ll;
  }
  cout<<t;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>

using namespace std;


int main(){
	queue<long long int>que;
	long long int n,a[200006],d,ireru[200006]={},count=0;
	cin>>n>>d;
	cout<<(n+2*d)/(2*d+1);
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 400005
ll a[N],f[N][3];
int n,fl[N];
ll read(){
	#define gc getchar
	int x=0,f=0; char ch=gc();
	for (;ch<'0'||ch>'9';ch=gc())
		if (ch=='-') f=1;
	for (;ch>='0'&&ch<='9';ch=gc())
		x=x*10-48+ch;
	return (f?-x:x);
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		a[i]=read();
		fl[i]=(a[i]>0);
		a[i]=abs(a[i]);
	}
	memset(f,233,sizeof(f));
	f[0][0]=0;
	for (int i=1;i<=n;i++){
		if (!fl[i]) f[i-1][2]=f[i-1][1],f[i-1][1]=f[i-1][0],f[i-1][0]=-1e18;
		for (int cur=0;cur<=2;cur++)
			for (int now=0;now<=cur;now++)
				f[i][now]=max(f[i][now],f[i-1][cur]+(cur&1?-a[i]:a[i]));
	}
	printf("%lld\n",max(f[n][0],f[n][1]));
}

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

int main(){
    int w,h,n;
    cin>>w >>h >>n;
    int minX = 0,minY = 0,maxX = w, maxY = h;
    
    for(int i=0;i<n;i++){
        int x,y,a;
        cin>>x >>y >>a;
        if(a==1){
            minX = max(minX,x);
        }else if(a==2){
            maxX = min(maxX,x);
        }else if(a==3){
            minY = max(minY,y);
        }else{
            maxY = min(maxY,y);
        }
    }
    
    cout<<max(0,maxX-minX)*max(0,maxY-minY)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

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; }

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

const ll INF = 1LL << 60;

// v: 現在探索中の頂点(vertex)、p: v の親
void dfs(vvi &G, vi &cnt,int v, int p){

  for (auto nv : G[v]){// nvはvのchild
    if (nv == p) continue;// nvが親pだったらスルー
    cnt[nv] += cnt[v];// 親のカウンターの値を子のカウンターに加える
    dfs(G, cnt, nv, v);// v は新たに nv の親となる
  }
}

int main(){
  int n,q; cin >> n >> q;
  vvi G(n);
  for (int i = 0; i < n-1; i++) {
    int a,b; cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vi cnt(n);// 頂点iのカウンター（初期値０）
  rep(i, q){
    int p,x; cin >> p >> x; p--;
    cnt[p] += x;
  }
  int v = 0, p = -1;
  dfs(G, cnt, v, p);
  rep(i, n) std::cout << cnt[i] << ' ';
  std::cout << '\n';
}


Measured memory_bytes: 29696
//#pragma GCC optimize(2)
// Happy TLE and WA every day!
// by: zxb the vegetable chicken
#include<bits/stdc++.h>
#define mp              make_pair
#define rep(i,n)        for(int i = 0; i < n; i++)
#define foreach(i,c)    for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define BINF            0x7fffffff
#define INF             0x3f3f3f3f
#define LINF            4557430888798830399
#define END(s)          {cout<<s; return 0;}
#define CON(s)          {cout<<s; continue;}
#define BRE(s)          {cout<<s; break;}
#define pb              push_back
#define All(a)          a.begin(), a.end()  //with A in CAPITAL!!!
#define sz(a)           (int)a.size()
#define F               first
#define S               second
#define Time            clock()/CLOCKS_PER_SEC
//#define usingFiles
using namespace std;

typedef unsigned int ui;
typedef pair<int, int> pii;
typedef long long ll;

inline bool Read(int& x){
	x = 0;
	int c;
	int sign = 1;
	while( (c = getchar()) < '0' || c > '9' ) if(c == '-') sign = -1;
	x = c ^ '0';
	while( (c = getchar()) >= '0' && c <= '9' ) x = (x<<3) + (x<<1) + (c ^ '0');
	x *= sign;
	return 1;
}

inline bool Write(int x){
	if(x >= 10) Write(x / 10);
	putchar(x % 10 + '0');
	return 1;
}

const int rp = 666666;
const bool debug = 1;
const bool I_good_vegetable_a = 1;

signed main(){
	ios::sync_with_stdio(false);
	#ifdef usingFiles
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int n, h, w;
	cin >> n >> h >> w;
	cout << (n - h + 1) * (n - w + 1); 
	return 0;
}

Measured memory_bytes: 256
def main():
    from collections import deque
    import sys
    input = sys.stdin.readline

    N = int(input())
    Graph = tuple(set() for _ in range(N))
    for _ in range(N - 1):
        a, b = (int(x) - 1 for x in input().split())
        Graph[a].add(b)
        Graph[b].add(a)

    Fennec = [-1] * N
    Snuke = [-1] * N

    def bfs(start, arr):
        arr[start] = 0
        dq = deque()
        dq.append(start)
        while dq:
            v = dq.popleft()
            d = arr[v]
            for u in Graph[v]:
                if ~arr[u]:
                    continue
                arr[u] = d + 1
                dq.append(u)

    bfs(start=0, arr=Fennec)
    bfs(start=N - 1, arr=Snuke)

    cnt_f = sum(1 for f, s in zip(Fennec, Snuke) if f <= s)
    cnt_s = N - cnt_f

    print('Fennec' if cnt_f > cnt_s else 'Snuke')


if __name__ == '__main__':
    main()


Measured memory_bytes: 40732
import math
N, M = map(int, input().split())

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

comb_n = 0
comb_m = 0
if N >= 2:
    comb_n = combinations_count(N, 2)
if M >= 2:
    comb_m = combinations_count(M, 2)
print(comb_n + comb_m)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>

#define INF 100000

int n = 6;

std::vector<std::vector<int> >cost;
std::vector<int>min_cost;
std::vector<bool>used;

void dijkstra(int i){

	used[i] = true;

	bool flg = true;
	for (int j = 0; j < n; j++){
		if (!used[j])flg = false;
	}
	if (flg)return;

	for (int j = 0; j < n; j++){
		if (cost[i][j] != INF){
			if (min_cost[j] > min_cost[i] + cost[i][j]){
				min_cost[j] = min_cost[i] + cost[i][j];
			}
		}
	}

	int min;
	for (int j = 0; j < n; j++){
		if (min_cost[j] != INF&&j != i&&!used[j]){
			min = j;
			break;
		}
	}

	for (int j = 0; j < n; j++){
		if (min_cost[j] != INF&&j != i&&!used[j]){
			if (min_cost[min]>min_cost[j])min = j;
		}
	}

	dijkstra(min);
}

int main(){

	std::cin >> n;

	for (int i = 0; i < n; i++){
		min_cost.push_back(INF);
		used.push_back(false);
		cost.push_back(std::vector<int>());
		for (int j = 0; j < n; j++){
			cost[i].push_back(INF);
		}
	}

	int m;
	std::cin >> m;

	for (int i = 0; i < m; i++){
		int a, b, c, d;
		char ch;
		std::cin >> a >> ch >> b >> ch >> c >> ch >> d;

		a--; b--;
		cost[a][b] = c;
		cost[b][a] = d;
	}

	int res = 0;
	int x1, x2, y1, y2;
	char ch;
	std::cin >> x1 >> ch >> x2 >> ch >> y1 >> ch >> y2;

	x1--; x2--;

	min_cost[x1] = 0;
	dijkstra(x1);

	res = y1 - y2 - min_cost[x2];

	for (int i = 0; i < n; i++){
		min_cost[i] = INF;
		used[i] = false;
	}
	
	min_cost[x2] = 0;
	dijkstra(x2);

	res -= min_cost[x1];

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

	return 0;
}

Measured memory_bytes: 1220
INFTY = 10**13
def floyd():
    for k in range(n):
        for i in range(n):
            if d[i][k] == INFTY:
                continue
            for j in range(n):
                if d[k][j] == INFTY:
                    continue
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])

n, e = map(int, input().split())
d = [[0 if i == j else INFTY for j in range(n)]for i in range(n)]

for i in range(e):
    u, v, c = map(int, input().split())
    d[u][v] = c

floyd()

negative = False
for i in range(n):
    if d[i][i] < 0:
        negative = True

if negative:
    print("NEGATIVE CYCLE")
else:
    for i in range(n):
        for j in range(n):
            if j:
                print(" ", end='')
            if d[i][j] == INFTY:
                print("INF", end='')
            else:
                print(d[i][j], end='')
        print()



Measured memory_bytes: 6804
# -*- coding: utf-8 -*-
import math


#----------
A,B,C,D,E,F = list(map(int, input().rstrip().split()))

water_set=set()
for i in range( F // (A*100) + 1):
    for j in range( F // (B*100) + 1 ):
        volume_water = i*(A*100) + j*(B*100)
        
        if volume_water < F and volume_water != 0:
            water_set.add( volume_water )
        
water_list=sorted(water_set)


max_concent = -1
materials=[]
for w in water_list:
    max_sugar = (w // 100) * E

    for i in range( max_sugar // C + 1 ):
        for j in range( max_sugar // D + 1 ):
            volume_sugar = (i*C) + (j*D)
            
            if volume_sugar <= max_sugar and (w + volume_sugar) <= F:
                concent = volume_sugar / (w + volume_sugar) * 100
                if concent > max_concent:
                    max_concent = concent
                    materials = [w,volume_sugar]
            
print( (materials[0] + materials[1]) , materials[1])


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf = 1e9;
typedef pair<mp,ll> mmp;
typedef pair<mp,mp> mpp;
typedef pair<mpp,ll> mpm;
int main(){
    while(1){
	ll n,m,c,s,gg;
	cin>>n>>m>>c>>s>>gg;
	if(n==0)break;
	s--,gg--;
	vector<vector<mmp> > g(n);
	for(int i=0;i<m;i++){
	    int x,y,d,cc;
	    cin>>x>>y>>d>>cc;
	    x--,y--;
	    cc--;
	    g[x].push_back(mmp( mp(d,cc), y ) );
	    g[y].push_back(mmp( mp(d,cc), x ) );
	}

	vector<ll> p(c);
	for(int i=0;i<c;i++)cin>>p[i];
	vector<vector<ll> > q(c),r(c);
	vector<map<ll,ll> > price(c+1);
	for(int i=0;i<c;i++){
	    for(int j=0;j<p[i]-1;j++){
		ll qq;
		cin>>qq;
		q[i].push_back(qq);
	    }
	    q[i].push_back(inf);
	    for(int j=0;j<p[i];j++){
		ll rr;
		cin>>rr;
		r[i].push_back(rr);
	    }
	    for(int j=0;j<p[i];j++){
		price[i][q[i][j]] = r[i][j];
	    }
	}
	price[c][inf] = 0;
	vector<vector<vector<ll> > > gd(c,vector<vector<ll> >( n,vector<ll>(n,inf) ) );
	vector<vector<vector<ll> > > gp(c,vector<vector<ll> >( n,vector<ll>(n,0) ) );
	for(int i=0;i<n;i++){
	    for(int j=0;j<g[i].size();j++){
		ll next = g[i][j].second;
		ll com = g[i][j].first.second;
		gd[com][i][next] = min(g[i][j].first.first,gd[com][i][next]);
		gd[com][next][i] = min(g[i][j].first.first,gd[com][next][i]);
	    }
	}
	for(int com=0;com<c;com++){
	    for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
		    for(int j=0;j<n;j++){
			gd[com][i][j] = min(gd[com][i][j],gd[com][i][k] + gd[com][k][j] );
		    }
		}
	    }
	}
	for(int com=0;com<c;com++){
	    //cout<<com<<endl;
	    for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
		    ll tmp = 0;
		    while( tmp != gd[com][i][j]){
			auto it = price[com].upper_bound(tmp);
			ll add_dis = min( it->first,gd[com][i][j])-tmp;
			tmp += add_dis;
			gp[com][i][j] += add_dis* it->second;
		    }
		//    cout<<gp[com][i][j]<<' ';
		}
	//	cout<<endl;
	    }
	}
	vector<ll> cs(n,inf);
	priority_queue<mp,vector<mp>,greater<mp> > que;
	que.push(mp(0,s) );
	bool flag = true;
	while(!que.empty()){
	    mp now = que.top();
	    que.pop();
	    ll nn = now.second;
	    ll cost = now.first;
	 //   cout<<nn<<' '<<cost<<endl;
	  /*  if(nn==gg){
		cout<<cost<<endl;
		flag = false;
		break;
	    }*/
	    if(cs[nn] <= cost) continue;
	    cs[nn] = cost;
	    for(int com = 0;com < c;com++)
	    for(int i=0;i<n;i++){
		if(cs[i] <= cost + gp[com][nn][i])continue;
		que.push(mp(cost+gp[com][nn][i],i) );
	    }
	}
	if(cs[gg] >= inf) cout<<-1<<endl;
	else cout<<cs[gg]<<endl;

    }
    return 0;
}



Measured memory_bytes: 10180
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;
typedef vector<long long int> vll;

int main() {
	string s;
	int w;
	cin >> s >> w;
	int cou = 0;
	cout << s[0];
	rep(i, 0, s.size()) {
		if (cou == w) {
			cout << s[i];
			cou = 0;
		}
		cou++;
	}
	cout << endl;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll x2 = 0;
    rep(i, n)
    {
        if (i % 2)
            x2 -= a[i];
        else
            x2 += a[i];
    }
    vector<int> ans(n);
    ans[0] = x2 / 2;
    rep(i, n - 1)
    {
        ans[i + 1] = a[i] - ans[i];
    }
    rep(i, n) ans[i] *= 2;
    rep(i, n) printf("%d%c", ans[i], i == n - 1 ? '\n' : ' ');

    return 0;
}

Measured memory_bytes: 2048
def calc(N, S):
    d = {}
    n_max = 0
    for s in S:
        d[s] = 1 + (d[s] if s in d else 0)
        n_max = max(n_max, d[s])
    result = [s for s in d.keys() if d[s] == n_max]
    result.sort()
    return '\n'.join(result)


N = int(input())
S = [input() for _ in range(N)]
print(calc(N, S))

Measured memory_bytes: 35220
A,B,C,X = [int(input()) for i in range(4)]
# print(a,b,c,x)
ans = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500*a +100*b + 50*c == X:
                ans += 1
# print(sum(500*a+100*b+50*c == X for a in range(A+1) for b in range(B+1) for c in range(C+1)))
print(ans)

Measured memory_bytes: 3060
using System;
class Program
{
    static void Main(string[] args)
    {
        while (true)
        {
            //A op Bを定義
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            string op = input[1];
            int b = int.Parse(input[2]);
            int answer = 0;
            //出力
            if (op == "?") break;
            else if (op == "+") { answer = a + b; Console.WriteLine(answer); }
            else if (op == "-") { answer = a - b; Console.WriteLine(answer); }
            else if (op == "*") { answer = a * b; Console.WriteLine(answer); }
            else if (op == "/") { answer = a / b; Console.WriteLine(answer); }
        }
    }
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  while (true) {
    c -= b;
    if (c <= 0) {
      cout << "Yes" << endl;
      return 0;
    }

    a -= d;
    if (a <= 0) {
      cout << "No" << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	vector<string> v(m);
	rep(i, m) cin >> v[i];

	map<char, vector<int> > x, y;
	rep(i, m) {
		rep(j, n) {
			if('A' <= v[i][j] && v[i][j] <= 'Z') {
				y[v[i][j]].push_back(i);
				x[v[i][j]].push_back(j);
			}
		}
	}

	set<char> st[30][2];
	bool used[30][2];
	memset(used, 0, sizeof(used));

	rep(i, 26) {
		char c = 'A' + i;
		if(x[c].size() == 0) continue;

		if(x[c][0] == x[c][1]) {
			if(abs(y[c][0] - y[c][1]) == 1) continue;
			used[i][0] = true;
			int x1 = x[c][0];
			int y1 = y[c][0], y2 = y[c][1];

			REP(j, min(y1, y2) + 1, max(y1, y2)) {
				if(v[j][x1] == '.') continue;
				st[i][0].insert(v[j][x1]);
			}
		} else if(y[c][0] == y[c][1]) {
			if(abs(x[c][0] - x[c][1]) == 1) continue;
			used[i][0] = true;
			int y1 = y[c][0];
			int x1 = x[c][0], x2 = x[c][1];
			REP(j, min(x1, x2) + 1, max(x1, x2)) {
				if(v[y1][j] == '.') continue;
				st[i][0].insert(v[y1][j]);
			}
		} else {
			used[i][0] = true;
			used[i][1] = true;
			int x1 = x[c][0], x2 = x[c][1];
			int y1 = y[c][0], y2 = y[c][1];

			REP(j, min(x1, x2), max(x1, x2) + 1) {
				if(v[y1][j] == '.' || v[y1][j] == c) continue;
				st[i][0].insert(v[y1][j]);
			}

			REP(j, min(y1, y2), max(y1, y2) + 1) {
				if(v[j][x2] == '.' || v[j][x2] == c) continue;
				st[i][0].insert(v[j][x2]);
			}

			REP(j, min(y1, y2), max(y1, y2) + 1) {
				if(v[j][x1] == '.' || v[j][x1] == c) continue;
				st[i][1].insert(v[j][x1]);
			}

			REP(j, min(x1, x2), max(x1, x2) + 1) {
				if(v[y2][j] == '.' || v[y2][j] == c) continue;
				st[i][1].insert(v[y2][j]);
			}
		}
	}

	int sum = 0;
	while(true) {
		bool flag = true;
		rep(i, 26) {
			char c = 'A' + i;

			rep(j, 2) {
				if(!used[i][j]) continue;
				if(st[i][j].size() == 0) {
					flag = false;
					used[i][j] = false;
					used[i][!j] = false;

					rep(k, 26) {
						rep(l, 2) {
							st[k][l].erase(c);
						}
					}
					sum += 2;
				}
			}
		}

		if(flag) break;
	}

	cout << sum << endl;


	return 0;
}

Measured memory_bytes: 1508
n = int(raw_input())
px = 0
py = 0
ph = 0
ls = []
for _ in range(n):
    x,y,h = map(int, raw_input().split())
    if ph == 0 and h != 0:
        px = x
        py = y
        ph = h
    ls.append((x,y,h))
ok = True
for cy in range(101):
    for cx in range(101):
        ch = ph + abs(cx - px) + abs(cy - py)
        ok = True
        for (x, y, h) in ls:
            if max(ch-abs(x-cx)-abs(y-cy), 0) != h:
                ok = False
                break
        if ok:
            print cx,cy,ch
            break
    if ok:
        break


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

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

    int N;
    string S;
    cin >> N >> S;
    for (char c : S)
        cout << (char) ((c - 'A' + N) % 26 + 'A');
    cout << '\n';

    return 0;
}

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

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v)
{
    for (auto& e : v) {
        is >> e;
    }
    return is;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;


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

    ll K, A, B;
    cin >> K >> A >> B;
    cout << ((K <= A) ? 1 : (A - B) > 0 ? 1 + (K - B - 1) / (A - B) * 2 : -1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	getline(cin, s);
	//apple
	auto pos = s.find( "apple" );
	while( pos != string::npos ){
		if( pos != string::npos ){
			s = s.replace( pos, 5, "+" );
			pos = s.find( "apple", pos , 5 );
		}
	}
	//peach
	auto pos2 = s.find( "peach" );
	while( pos2 != string::npos ){
		if( pos2 != string::npos ){
			s = s.replace( pos2, 5, "-" );
			pos2 = s.find( "peach", pos2 , 5 );
		}
	}
	//replace
	for(int i=0; i<(int)s.size(); i++){
		if(s[i]=='+'){
			s = s.replace( i, 1, "peach" );
		}else if(s[i]=='-'){
			s = s.replace( i, 1, "apple" );
		}
	}
	cout << s << endl;
	
	return 0;
}

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

int main() {
  long long int H, W;
  cin >> H >> W;
  long long int ans = 1000000000000;
  for (long long int i = 1; i < H; i++) {
    long long int A = i * W;
    long long int B = (H - i) * (W / 2);
    long long int C = (H - i) * W - B;
    long long int Smax = max(max(A, B), C);
    long long int Smin = min(min(A, B), C);
    ans = min(ans, Smax - Smin);
    B = (H - i) / 2 * W ;
    C = (H - i) * W - B;
    Smax = max(max(A, B), C);
    Smin = min(min(A, B), C);
    ans = min(ans, Smax - Smin);
  }
  swap(H, W);
  for (long long int i = 1; i < H; i++) {
    long long int A = i * W;
    long long int B = (H - i) * (W / 2);
    long long int C = (H - i) * W - B;
    long long int Smax = max(max(A, B), C);
    long long int Smin = min(min(A, B), C);
    ans = min(ans, Smax - Smin);
    B = (H - i) / 2 * W;
    C = (H - i) * W - B;
    Smax = max(max(A, B), C);
    Smin = min(min(A, B), C);
    ans = min(ans, Smax - Smin);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>

using namespace std;

int main(void) {
	unsigned long N, div, rem;
	unsigned long A, B, ans;
	cin >> N >> A >> B;
	div = N / (A + B);
	rem = N % (A + B);
	if (rem < A) {
		ans = A * div + rem;
	}
	else {
		ans = A * div + A;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


M = defaultdict(int)

for n in range(1, N+1):
    P = prime_factorize(n)
    for p in P:
        M[p] += 1

MOD = 10 ** 9 + 7
ans = 1
for k, v in M.items():
    ans *= v+1
    ans %= MOD

print(ans)


Measured memory_bytes: 41436
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		int ASC = 96;
		List<Character> name = new ArrayList<>();
     
        while (N > 0) {
			if (N%26==0)
			{name.add('z');}
		else {name.add((char)((N%26)+96));}
			N = (N-1)/26;
            }
        Collections.reverse(name);
      
      StringBuilder str = new StringBuilder();
    for (Character character : name){
        str.append(character);
    }

			
		System.out.println(str.toString());
        }
		
}

Measured memory_bytes: 35884
#include<stdio.h>
char s[200010];
long long sum = 0;
int main()
{
    scanf ("%s", s);
    
    for (int i = 0; s[i]; i++)
    sum += s[i] - '0';
    
    if (sum % 9 == 0) printf("Yes\n");
    else puts("No");
  //  printf("%d", sum % 9)
}


Measured memory_bytes: 1764
import java.util.*;
public class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int n = Integer.parseInt(sc.next());
            int x = Integer.parseInt(sc.next());
            
            if(n==0 && x==0) break;
            
            int count = 0;
            for(int i=1; i<=n; i++){
                for(int j=i+1; j<=n; j++){
                    for(int k=j+1; k<=n; k++){
                        if(i+j+k == x) count++;
                    }
                }
            }
            System.out.println(count);
        }

    }

}



Measured memory_bytes: 26552
#include <bits/stdc++.h>  // clang-format off
using Int = int;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun May 31 22:01:10 JST 2020
 **/

signed main() {
    Int n;
    std::cin >> n;
    std::vector<Int> a(n), b(n);
    REP(i, n) std::cin >> a[i] >> b[i];
    std::nth_element(a.begin(), a.begin() + n / 2, a.end());
    std::nth_element(b.begin(), b.begin() + n / 2, b.end());
    Int ans = 0;
    if (n % 2) {
        ans = b[n / 2] - a[n / 2];
    } else {
        ans += b[n / 2] - a[n / 2];
        std::nth_element(a.begin(), a.begin() + n / 2 - 1, a.end());
        std::nth_element(b.begin(), b.begin() + n / 2 - 1, b.end());
        ans += b[n / 2 - 1] - a[n / 2 - 1];
    }
    std::cout << ans + 1 << std::endl;
}


Measured memory_bytes: 4760
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  int a, b;

  cin >> a >> b;

  if (a >= 13)
    cout << b << endl;
  else if (a <= 5)
    cout << 0 << endl;
  else
    cout << b / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdio.h>

int main(){
  int n;
  double a,b,c,d,e,f,x,y,r;
  double x1,y1,x2,y2,x3,y3;

  std::cin >> n;

  for(int i=0;i<n;i++){
    std::cin >> x1>>y1>>x2>>y2>>x3>>y3;
    a = 2*(x1-x2);
    b = 2*(y1-y2);
    c = +(x1*x1-x2*x2)+(y1*y1-y2*y2);
    d = 2*(x2-x3);
    e = 2*(y2-y3);
    f = +(x2*x2-x3*x3)+(y2*y2-y3*y3);

    x = (double)(c*e-b*f)/(a*e-b*d);
    y = (double)(a*f-c*d)/(a*e-b*d);

    if(x == 0){x = 0;}
    if(y == 0){y = 0;}

    r = sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));

    printf("%.3f %.3f %.3f\n",x,y,r);
  }
}

Measured memory_bytes: 3196