akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  int k, a, b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; ++i) if (i % k == 0) {
    cout << "OK\n";
    return 0;
  }
  cout << "NG\n";
  return 0;
}


Measured memory_bytes: 3636
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::*;
use std::string::*;
use std::f64::consts::PI;

struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }

    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }

    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let s: String = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();

        return s.parse::<T>().ok().unwrap();
    }

    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

fn prime_factorization(n: i64) -> HashMap<i64, i64> {
    let mut n = n;
    let mut res = HashMap::new();
    let mut i = 2;
    while i * i <= n {
        while n % i == 0 {
            n /= i;
            let count = res.entry(i).or_insert(0);
            *count += 1;
        }
        i += 1;
    }

    if n > 1 {
        res.insert(n, 1);
    }

    return res;
}

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let x:usize = sc.read();
    let mut dp = vec![false; 100010];
    dp[0] = true;
    let to = vec![100, 101, 102, 103, 104, 105usize];

    for i in 0..100010 {
        for t in &to {
            if i + *t < 100010 {
                dp[i + *t] |= dp[i];
            }
        }
    }

    println!("{}", dp[x] as usize);
}


Measured memory_bytes: 4352
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    d=dict()
    for i in range(1,N+1):
        i=str(i)
        head=i[0]
        tail=i[-1]
        if tail=="0":
            continue
        if (head,tail) not in d:
            d[(head,tail)]=1
        else:
            d[(head,tail)]+=1

    ans=0
    s=set()
    for k in d.keys():
        m,l=k[0],k[1]
        if (m,l) in s:
            continue
        if (l,m) in d:
            ans+=d[(m,l)]*d[(l,m)]
            if (m,l)!=(l,m):
                ans+=d[(m,l)]*d[(l,m)]
        s.add((m,l))
        s.add((l,m))

    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 3064
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
k_sum = (k-1)*k//2

ans = 0
minus = 0
for i in range(n):
    tentou1 = 0
    tentou2 = 0
    for j in range(n):
        if i<j and a[i]>a[j]:
            tentou1 += 1
        if a[i]>a[j]:
            tentou2 += 1
    ans += tentou1*k+tentou2*k_sum

print(ans%1000000007)


Measured memory_bytes: 3188
n = gets.chomp!.to_i

n.times do
  ax, ay, ar, bx, by, br = gets.chomp!.split(" ").map(&:to_f)

  dist = Math.sqrt((ax - bx) ** 2 + (ay - by) ** 2)

  if (ar+br) < dist
    puts 0
  elsif (dist + br) < ar
    puts 2
  elsif (dist + ar) < br
    puts -2
  else
    puts 1
  end

end

Measured memory_bytes: 8720
n,m,a,b=map(int, input().split())
x=list(map(int, input().split()))
y=list(map(int, input().split()))
j=False
for i in range(a+1,b+1):
    if max(x)<i and min(y)>=i:
        j=True

print("No War" if j else "War")

Measured memory_bytes: 3060
import fractions
import functools

N, M = [int(i) for i in input().split()]
a = {int(i) // 2 for i in input().split()}  # 予め2で割っておく


def lcm(a, b):
    """a, bの最小公倍数を求める"""
    return a * b // fractions.gcd(a, b)


# aの中で一番小さい数が2で何回割れるか
n_2 = 0
min_a = min(a)
while True:
    if min_a % 2 != 0:
        break
    min_a //= 2
    n_2 += 1

# aのすべての数が2でn_2回割り切れる
cond1 = all({i % (2**n_2) == 0 for i in a})
# n_2回割った後、さらに2で割り切れる数は存在しない
cond2 = all({(i // (2**n_2)) % 2 != 0 for i in a})

if cond1 and cond2:
    all_lcm = functools.reduce(lcm, a)  # aの全要素の最小公倍数
    ans = -((-(M // all_lcm)) // 2)
    print(ans)
else:
    print(0)


Measured memory_bytes: 89580
#include <iostream>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <vector>
#include <cmath>
#include <cstdint>
#include <string>

using namespace std;

void print(const std::vector<int>& A) {
  for (int i = 0; i < A.size(); ++i) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;
}

void insertionSort(std::vector<int>& A) {
  print(A);
  for (int i = 1; i < A.size(); ++i) {
    int v = A[i];
    int j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      --j;

    }
    A[j + 1] = v;
    print(A);
  }
}

int main() {
  int count;
  std::vector<int> A;
  cin >> count;
  for (int i = 0; i < count; ++i) {
    int v;
    cin >> v;
    A.push_back(v);
  }
  insertionSort(A);
}



Measured memory_bytes: 3152
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  lli n, k;
  scanf("%lld %lld", &n, &k);

  if ( k % 2 == 1 ) {
    long long int a = n / k;
    printf("%lld\n", a * a * a);
  } else {
    long long int a = n / k;
    long long int b = (n + (k / 2)) / k;
    printf("%lld\n", a * a * a + b * b * b);
  }
  return 0;
}


Measured memory_bytes: 128
N, K = map(int, input().split())
ABs = [tuple(map(int, input().split())) for _ in range(N)]

ans = 0
for i, b in enumerate(bin(K+1)[2:][::-1]):
    if b == '0': continue
    v = 0
    C = (K+1) & ~((1<<i)-1)
    mask = ~(C-1)
    for A, B in ABs:
        if A < C and A & mask == 0:
            v += B
    ans = max(ans, v)

print(ans)


Measured memory_bytes: 18636
#abc136 D
s = gets.chomp
n,l,r = s.length, 0, 0
ans = Array.new(n,0)

n.times do |i|
	if s[i]=='R'
		if (l+r).even?
			l+=1
		else
			r+=1
		end
	else
		ans[i-1] += l
		ans[i] += r
		l,r=0,0
	end
end

(n-1).downto(0) do |i|
	if s[i]=='L'
		if (l+r).odd?
			l+=1
		else
			r+=1
		end
	else
		ans[i] += l
		ans[i+1] += r
		l,r=0,0
	end
end

ans.each do |x|
  print x,' '
end

Measured memory_bytes: 2940
#include <iostream>
    #include <string>
    #include <set>  
    #include <stack>
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
    #include <cassert>
    #include <iomanip>
    #include <sstream>
    #include <ctime>
    #include <bitset> 
    #include <cctype>
using namespace std;
#define for1(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,maxn) for1(i,0,maxn)
#define ford(i,b,a) for(int i=(int)(b)-1;i>=a;--i)
typedef long long ll;
typedef unsigned long long int128;
typedef pair<int,int> pii;
typedef pair<int,pii > piii;
#define inf 0x3f3f3f3f
#define mod 1000000007
#define st first
#define nd second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define dprintf(...) printf(__VA_ARGS__)
#define abs(a) (a>0?a:(-a))
#define min(x,y) (x<y?x:y)
const int maxn=1e5+10;
int n;
int a[maxn*2];
int b[maxn*2];
int ans[maxn*2];
bool cal(int x)
{
	memset(b,0,sizeof(b));
	rep(i,n*2-1)
		if(a[i]>=x)b[i]=1;
	int startt,endt;
	ans[0]=b[0];
	for1(i,1,n*2-2)
	{
		if(b[i]!=b[i-1]&&b[i]!=b[i+1])
		{
			startt=b[i-1];
			int j=i+1;
			while(j<n*2-1&&b[j]!=b[j-1])
				endt=b[j++];
		//	cout<<i<<" "<<j<<" "<<startt<<" "<<endt<<endl;
		//	system("pause"); 
			if(startt==endt)
			{
				for1(k,i,j)
					ans[k]=startt;
			}
			else
			{
				int mid=(i+j)>>1;
				for1(k,i,mid)
					ans[k]=startt;
				for1(k,mid,j)
					ans[k]=endt;
			}
			i=j-1;
		}
		else ans[i]=b[i];
	}
/*	cout<<x<<endl;
	rep(i,n*2-1)
		cout<<ans[i];
	cout<<endl;
	system("pause");*/
	return ans[n-1]==1;
}
int main()
{
	scanf("%d",&n);
	rep(i,2*n-1)
		scanf("%d",a+i);
	int l=1,r=2*n-1;
	int ans;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(cal(mid))l=mid+1,ans=mid;
		else r=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}

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

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

    vector<int> p(n);
    for(int i=0; i<n; i++){
        cin>>p[i];
    }

    int temp_min;
    int count=1; // i=1は常に条件を満たす

    temp_min=p[0];

    for(int i=1; i<n; i++){
        if(p[i]<temp_min){
            count++;
            temp_min=p[i];
        }
    }

    cout<<count<<endl;
}

Measured memory_bytes: 1024
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;

struct rect {
	ll hei; ll pos;
};

ll const MAX = 1e5 + 5;
ll a[MAX][3];
ll dp[MAX][3];

int main() {
	ll n;
	cin >> n;
	REP(i, 1, n) {
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	REP(j, 0, 2) {
		dp[0][j] = 0;
	}
	REP(i, 1, n) {
		REP(j, 0, 2) {
			ll x = 0;
			REP(k, 0, 2) {
				if (j != k) {
					x = max(x, dp[i - 1][k]);
				}
			}
			dp[i][j] = a[i][j] + x;
		}
	}
	cout << max({ dp[n][0],dp[n][1],dp[n][2] }) << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define ld long double
#define pp pair<ll,pair<ll,ll> >
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell 1000000007
#define f first
#define s second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree< ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
void solve() 
{
    ll n , m , x , y ;
    cin >> n >> m ;
    vector< pair<ll,ll> > v ;
    rep( i , 0 , n )
    {
        cin >> x >> y ;
        v.pb( {x,y} ) ;
    }
    sort(all(v));
    ll ans = 0 ;
    rep( i , 0 , n )
    {
        ll cur = min(m,v[i].s);
        ans += cur*v[i].f ;
        m -= cur ;
    }
    cout << ans ;
}   
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}

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

using namespace std;
typedef long long int lli;
lli height[100005];
lli dp[100005];
lli n;
lli solve(lli i);

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	for (int i=0;i<100005;i++) height[i]=999999999;
	cin>>n;
	for (int i=1;i<=n;i++) cin>>height[i];
	for (int i=1;i<=n;i++) dp[i]=-1;
	solve(1);
	//for (int i=1;i<=n;i++) cout<<dp[i]<<endl;
	cout<<dp[1]<<endl;
	
	return 0;
}

lli solve(lli i){
	if (i==n) return 0;
	if (dp[i]!=-1) return dp[i];
	dp[i]=min(solve(i+1)+abs(height[i+1]-height[i]),solve(i+2)+abs(height[i+2]-height[i]));
	return dp[i];
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    double x,y,w,h;
    std::cin >> w>>h;
    std::cin >> x>>y;

    if(w/2==x&&h/2==y){
        std::cout <<keta(8)<< w*h/2<<" "<<1 << std::endl;
    }else std::cout <<keta(8)<< w*h/2<<" "<<0 << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

int main()
{
    ll a1, a2, a3;
    input(a1, a2, a3);

    cout << (a1 + a2 + a3 >= 22 ? "bust" : "win") << endl;
    return 0;
}

Measured memory_bytes: 256
/* Accepted. */
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;
#define MAXN 100006
int n , m;
vector<int> G[MAXN];
int in[MAXN] , par[MAXN];
queue<int> Q;
void topsort(  ) {
	for( int i = 1 ; i <= n ; ++ i ) if( !in[i] ) 
		Q.push( i );
	while( ! Q.empty() ) {
		int x = Q.front();Q.pop();
		for( int i = 0 ; i < G[x].size() ; ++ i ) {
			if( ! --in[G[x][i]] ) Q.push( G[x][i] );
			par[G[x][i]] = x;
		}
	}
}
int main() {
	//freopen( "input" , "r",stdin );
	cin >> n >> m;
	for( int i = 0 , u , v ; i < n-1+m ; ++ i )
		scanf("%d%d",&u,&v) , G[u].push_back( v ) , ++ in[v];
	topsort() ;
	for( int i = 1 ; i <= n ; ++ i ) cout << par[i] << endl;
}

//qwq


Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
typedef long long ll;

int main(){
  ll a,b,n;
  cin >> a >> b >> n;
  ll ans = 0;
  if(n >= b){
    cout << ((b-1)*a/b) - a*((b-1)/b);
  }
  if(n < b){
    cout << n*a/b - a*(n/b);
  }
}


Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(void) {
	int a, b, i, ans = 0;
	cin >> a >> b;
	for (i = 1; i < b; i += a - 1) {
		ans++;
	}
	cout << ans << "\n";
	return 0;
}

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

int main(){
	int a,b,c; cin >>a>>b>>c;
	cout <<min({a,b,c})<<" ";
	cout <<a+b+c-min({a,b,c})-max({a,b,c})<<" ";
	cout << max({a,b,c})<<endl;
	

}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORr(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORr(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  int n;
  cin >> n;
  
  vector<int> h(n);
  REP(i, n) cin >> h[i];

  vector<int> dp(n+1, INF);
  dp[0] = 0;
  REP(i, n){
    if(i+1 >= n) continue;
    chmin(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
    if(i+2 >= n) continue;
    chmin(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
  }

  cout << dp[n-1] << endl;

  return 0;
}

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

#define ll          long long
#define ull         unsigned long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
//#define mod        998244353
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define INF         numeric_limits<ll>::max();
#define NINF        numeric_limits<ll>::min();
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))
const long double pi=3.14159265359;
inline ll add(ll a,ll b,ll m){
    if((a+b)>=m)return (a+b)%m;
    return a+b;
}
inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}



void solve(){
    int r;cin>>r;
    cout<<2*pi*r<<endl;

}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3800
<?php
// Your code here!
    while($input_line = trim(fgets(STDIN))){
        $student = explode(" ",$input_line);
        if($student[0]==-1 && $student[1]==-1 && $student[2]==-1){
            break;
        }elseif($student[0]==-1 || $student[1]==-1){
            echo "F";
        }elseif($student[0]+$student[1]>=80){
            echo "A";
        }elseif($student[0]+$student[1]>=65){
            echo "B";
        }elseif($student[0]+$student[1]>=50){
            echo "C";
        }elseif($student[0]+$student[1]>=30){
            if($student[2]>=50){
                echo "C";
            }else{
                echo "D";
            }
        }else{
            echo "F";
        }
        echo "\n";
            
            
    }
    

?>


Measured memory_bytes: 9220
N = int(input())
S = input()

#print(ord("A"))
#print(ord("B"))
#print(ord("Z"))

for i in range(len(S)):
	ascii = ord(S[i]) + N   #Sのi文字目のアスキーコードを計算してしれにNを足してづらす
	if ascii > ord("Z"):    #アスキーコードがよりも大きくなった時はA初まりにづらす
		ascii = ascii - (ord("Z") - ord("A") + 1)
	print(chr(ascii),end = "") #,end = "" は１行ごとに改行しないでプリントする仕組み


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

A.sort()
# print(A)
bucket = [0] * (max(A) + 1)
for el in A:
    bucket[el] += 1
# print(bucket)

odd = len(list(filter(lambda x: x % 2 == 1, bucket)))
# print(odd)
even = len(list(filter(lambda x: x % 2 == 0 and x != 0, bucket)))

print(odd + (even // 2) * 2)

Measured memory_bytes: 54188
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;


signed main(){
	string s[3];
	REP(i,3)cin >> s[i];
	string ans = "";
	REP(i,3){
		ans += toupper(s[i][0]);
	}
	out(ans);
}

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

namespace ConsoleApplication15
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] str = Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            if (a == b)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


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

#define endl '\n'
#define int ll
using namespace std;
typedef long long ll;

ll n, k;

void init();
void process();

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n >> k;
}

void process()
{
    if(k == 0)
    {
        for(ll i = 0; i < (1<<n); i++) cout << i << " " << i << " ";
        cout << endl;
    }
    else if(n == 1 && k == 1) cout << -1 << endl;
    else if(k < (1<<n))
    {
        for(ll i = 0; i < (1<<n); i++) if(i != k) cout << i << " ";
        cout << k << " ";
        for(ll i = (1<<n)-1; i >= 0; i--) if(i != k) cout << i << " ";
        cout << k << endl;
    }
    else cout << -1 << endl;
}



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

void myprint(vector<int> &a) {
  for (auto it = a.begin(); it != a.end(); ++it) {
    if (it != a.begin()) {
      cout << " ";
    }
    cout << *it;
  }
  cout << endl;
}

int main() {
  int N;
  cin >> N;
  vector<int> a;
  for (int i = 0; i < N; ++i) {
    int t;
    cin >> t;
    a.push_back(t);
  }

  int counter = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = N - 1; j >= i + 1; --j) {
      if (a[j] < a[j - 1]) {
        int t = a[j];
        a[j] = a[j - 1];
        a[j - 1] = t;
        ++counter;
      }
    }
  }
  myprint(a);

  cout << counter << endl;

  return 0;
}

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

int main() {
  string name;
  int ans;
  cin >> name;
  if (name == "SUN")
    ans = 7;
  else if (name == "MON")
    ans = 6;
  else if (name == "TUE")
    ans = 5;
  else if (name == "WED")
    ans = 4;
  else if (name == "THU")
    ans = 3;
  else if (name == "FRI")
    ans = 2;
  else
    ans = 1;
  cout << ans << endl;
}

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

int W, H;
int G[100][100];
int ans;

void dfs(int pi, int pj, int c) {
  static int di[] = {0,1,0,-1};
  static int dj[] = {1,0,-1,0};
  if(c + 1 >= ans) return;
  for(int k = 0; k < 4; ++k) {
    int ni = pi, nj = pj;
    for(int l = 0; ; ++l) {
      int ti = ni + di[k];
      int tj = nj + dj[k];
      if(ti < 0 || ti >= H) break;
      if(tj < 0 || tj >= W) break;
      if(G[ti][tj] == 3) {
        ans = c + 1;
        return;
      }
      if(G[ti][tj] == 1) {
        if(l) {
          G[ti][tj] = 0;
          dfs(ni, nj, c+1);
          G[ti][tj] = 1;
        }
        break;
      }
      ni = ti;
      nj = tj;
    }
  }
}

int main() {
  while(cin >> W >> H && (W|H)) {
    int si, sj;
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        cin >> G[i][j];
        if(G[i][j] == 2) {
          si = i; sj = j;
          G[i][j] = 0;
        }
      }
    }
    ans = 11;
    dfs(si, sj, 0);
    if(ans == 11) ans = -1;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1176
def gs() STDIN.gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
 
def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def find_mode(x,y)
	return y>x ? (y>(-1*x) ? 2 : 3 ) : (y>(-1*x) ? 1 : 0 ) 
end

n = gi
xys = Array.new(n){ gsmi } #扱い方を後で見る
MODE = ['D','R','U','L']

max = 0
odd = (xys[0][0]+xys[0][1]).odd?
xys.each do |x,y|
	max = max(max,x.abs+y.abs)
	(puts(-1);exit) if odd!=(x+y).odd?
end

ds = []
d = 1
until d>max
	ds << d
	d*=2
end

desc ds
puts ds.length + (odd ? 0 : 1)
puts (odd ? ds : [1]+ds).join(" ")

xys.each do |x,y|
	w = []
	if !odd
		w << 'R'
		x-=1
	end
	
	ds.each do |d2|
		mode = find_mode(x,y)
		w << MODE[mode]
		x += d2*((mode==0||mode==2) ? 0 : (mode==1 ? -1 : 1) )
		y += d2*((mode==1||mode==3) ? 0 : (mode==2 ? -1 : 1) )
	end
	
	puts w.join ""
end

Measured memory_bytes: 2428
n = int(input())
s = [list(map(int, input().split())) for _ in range(n)]
ans = 0
ma1, mi1 = -10000000000, 10000000000
ma2, mi2 = -10000000000, 10000000000
for i in range(n):
    x = s[i][0] + s[i][1]
    y = s[i][0] - s[i][1]
    ma1 = max(ma1, x)
    mi1 = min(mi1, x)
    ma2 = max(ma2, y)
    mi2 = min(mi2, y)
    ans = max(ans, ma1 - mi1, ma2 - mi2)
print(ans)

Measured memory_bytes: 102520
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
template<typename T> void remove(std::vector<T>& vector, unsigned int index){vector.erase(vector.begin() + index);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    int a,b;
    cin >> a >> b;
    int ans;
    ans = max(a+b,a-b);
    ans = max(ans,a*b);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

  int x1, y1, x2, y2; std::cin >> x1 >> y1 >> x2 >> y2;

  int dx = x2-x1;
  int dy = y2-y1;

  int x3 = x2 - dy;
  int y3 = y2 + dx;
  int x4 = x1 - dy;
  int y4 = y1 + dx;

  std::cout << x3 << " " << y3 << " " << x4 << " " << y4 << std::endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.IntStream;
import java.io.*;

public class Main {

	List<Integer>[] graph;
	int[] color;
	void dfs(int u, int c) {
		color[u] = c;
		for (int t = 0; t < graph[u].size(); t++) {
			int v = graph[u].get(t);
			if (color[v] == -1) {
				dfs(v, c);
			}
		}
	}
	void solve() {
		int n = in.nextInt();
		graph = new List[n];
		for (int i = 0; i < n; i++) {
			graph[i] = new ArrayList<>();
		}
		for (int i = 0; i < n - 1; i++) {
			int from = in.nextInt() - 1, to = in.nextInt() - 1;
			graph[from].add(to);
			graph[to].add(from);
		}
		
		int[] q = new int[n];
		int head = 0, tail = 0;
		int[] prev = new int[n];
		int[] dist = new int[n];
		Arrays.fill(dist, -1);
		dist[0] = 0;
		q[tail++] = 0;
		while (head < tail) {
			int cur = q[head++];
			for (int v : graph[cur]) {
				if (dist[v] == -1) {
					dist[v] = dist[cur] + 1;
					prev[v] = cur;
					q[tail++] = v;
				}
			}
		}
		
		color = new int[n];
		Arrays.fill(color, -1);
		int len = dist[n - 1];
		int cur = n - 1;
		while (cur > 0) {
			if (dist[cur] <= len / 2) {
				color[cur] = 0;
			} else {
				color[cur] = 1;
			}
			cur = prev[cur];
		}
		color[0] = 0;
		for (int i = 0; i < n; i++) {
			if (color[i] != -1) {
				dfs(i, color[i]);
			}
		}
		int[] cnt = new int[2];
		for (int i = 0; i < n; i++) {
			cnt[color[i]]++;
		}
		
		out.println(cnt[0] > cnt[1] ? "Fennec" : "Snuke");
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


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

int main() {
  int N;
  cin >> N;
  int f;
  int n = N;
  while (n > 0) {
    f += n % 10;
    n /= 10;
  }
  if (N % f == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

long power(long a, long b) {
	if (b == 0) return 1;
	long res = power(a * a, b / 2);
	if (b % 2) res = a * res;
	return res;
}

int main() {
	int A, B, Q;
	cin >> A >> B >> Q;
	vector<long> s(A + 2), t(B + 2);
	long LONG_MIN = -power(10, 18), LONG_MAX = power(10, 18);
	s[0] = LONG_MIN;
	for (int i = 1; i <= A; ++i) cin >> s[i];
	s[A + 1] = LONG_MAX;
	t[0] = LONG_MIN;
	for (int i = 1; i <= B; ++i) cin >> t[i];
	t[B + 1] = LONG_MAX;
	for (int i = 0; i < Q; ++i) {
		long x, first, second, ans = LONG_MAX;
		cin >> x;
		first = s[upper_bound(s.begin(), s.end(), x) - s.begin() - 1];
		second = t[upper_bound(t.begin(), t.end(), first) - t.begin() - 1];
		ans = min(labs(x - first) + labs(first - second), ans);
		second = t[lower_bound(t.begin(), t.end(), first) - t.begin()];
		ans = min(labs(x - first) + labs(first - second), ans);
		first = s[lower_bound(s.begin(), s.end(), x) - s.begin()];
		second = t[upper_bound(t.begin(), t.end(), first) - t.begin() - 1];
		ans = min(labs(x - first) + labs(first - second), ans);
		second = t[lower_bound(t.begin(), t.end(), first) - t.begin()];
		ans = min(labs(x - first) + labs(first - second), ans);
		first = t[upper_bound(t.begin(), t.end(), x) - t.begin() - 1];
		second = s[upper_bound(s.begin(), s.end(), first) - s.begin() - 1];
		ans = min(labs(x - first) + labs(first - second), ans);
		second = s[lower_bound(s.begin(), s.end(), first) - s.begin()];
		ans = min(labs(x - first) + labs(first - second), ans);
		first = t[lower_bound(t.begin(), t.end(), x) - t.begin()];
		second = s[upper_bound(s.begin(), s.end(), first) - s.begin() - 1];
		ans = min(labs(x - first) + labs(first - second), ans);
		second = s[lower_bound(s.begin(), s.end(), first) - s.begin()];
		ans = min(labs(x - first) + labs(first - second), ans);
		cout << ans << endl;
	}
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const int N = 100005;
#define ll long long
int cmp(int a,int b){
	return a>b;
}	
int gcd(int x, int y)
{
    while(y^=x^=y^=x%=y);
    return x;
}
int main(){
	int n,k;
	cin >> n >> k;
	if(n<=k) cout <<"unsafe";
	else cout <<"safe";
	return 0;
}



Measured memory_bytes: 3624
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
  
    ll n,k,i;
    cin>>n>>k;
    ll a[n+2];
    for(i=0;i<n;i++) cin>>a[i];
    
    ll lo = 1,hi = 10000000000000;
    while(hi>lo)
    {
    	ll sum=0,mid = (hi+lo)/2;
    	for(i=0;i<n;i++)
    	{
    		sum += (a[i]-1)/mid;
    	}
    	if(sum <=k) hi = mid;
    	else lo = mid + 1;
    }
    cout<<hi;
    
}

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

int main()
{
	int MAX_NUM = pow(10, 5);
	vector<int> sosuu;
	sosuu.push_back(2);
	sosuu.push_back(3);
	sosuu.push_back(5);
	sosuu.push_back(7);

	for (int i = 11; i <= MAX_NUM; i += 2) {
		bool isSosuu = true;
		for (int a : sosuu) {
			if (i % a == 0) {
				isSosuu = false;
				break;
			}
		}
		if (isSosuu) {
			sosuu.push_back(i);
		}
	}
	//outofbouds防止でテキトーにでかい数字をいれておく
	sosuu.push_back(10000007);

	//累積和をとる
	vector<int> countSum(MAX_NUM + 1);
	int sosuuIndex = 0;
	int likeNum = 0;
	for (int i = 0; i <= MAX_NUM; i++) {
		if (i >= sosuu[sosuuIndex]) {
			int v = sosuu[sosuuIndex];
			int v2 = (v + 1) / 2;
			if (binary_search(sosuu.begin(), sosuu.end(), v2)) {
				likeNum += 1;
			}
			sosuuIndex += 1;
		}
		countSum[i] = likeNum;
	}

	//問題解析
	int Q;
	cin >> Q;
	vector<int> Li(Q);
	vector<int> Ri(Q);
	rep(i, Q) {
		cin >> Li[i] >> Ri[i];
	}
	rep(i, Q) {
		int diff = countSum[Ri[i]] - countSum[Li[i] - 1];
		cout << diff << endl;
	}
	return 0;
}


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

typedef long long int ll;
#define deb(x) cout << #x << " " << x << endl;
#define debtwo(x,y) cout << #x << " " << x << ", " << #y << " " << y << endl;
#define mod 1000000000000000000

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string n;
  cin >> n;

  ll sum = 0;
  for (int i = 0; i < n.length(); i++) {
    sum += n[i] - '0';
  }
  if (sum % 9) cout << "No";
  else cout << "Yes";
}

Measured memory_bytes: 3764
N=int(input())
L=list(map(int,input().split()))
count=0
sum=0
A=float("inf")
for i in L:
	sum+=abs(i)
	A=min(A,abs(i))
	if i<0:
		count+=1
if count%2==0:
	print(sum)
else:
	B=float("inf")
	for i in L:
		if abs(i)==A:
			if i==0:
				print(sum)
				exit()
			elif i>0:
				print(sum-2*i)
				exit()
			elif i<0:
				print(sum-2*A)
				exit()

Measured memory_bytes: 14412
from collections import deque

h, w = map(int, input().split())
a = [input() for _ in range(h)]
r = 0
for i in range(h):
  for j in range(w):
    if a[i][j] == '.':
      b = list(map(list, a))
      q = deque()
      b[i][j] = 0
      q.append((i, j))
      while(q):
        i, j = q.popleft()
        r = max(r, b[i][j])
        d = 0
        for i1 in range(i - 1, i + 2):
          if 0 <= i1 < h:
            for j1 in range(j - d, j + 2, 2):                
              if 0 <= j1 < w and b[i1][j1] == '.':
                b[i1][j1] = b[i][j] + 1
                q.append((i1, j1))
          d ^= 1
print(r)


Measured memory_bytes: 3316
N, C = map(int, input().split())

xv = [list(map(int, input().split())) for _ in range(N)]

xinc = [0] * N
xinc2 = [0] * N
xdec = [0] * N
xdec2 = [0] * N

nowx = 0
nowv = 0

nowxin = C
nowvin = 0

for i in range(N):
  xi, vi = xv[i]
  nowv = nowv - (xi-nowx) + vi
  xinc[i] = nowv
  xinc2[i] = nowv - xi
  nowx = xi
  
  xin, vin = xv[N-1-i]
  nowvin = nowvin - (nowxin-xin) + vin
  xdec[i] = nowvin
  xdec2[i] = nowvin - (C-xin)
  nowxin = xin
  
mxinc2 = [0]*N
mxdec2 = [0]*N
for i in range(1, N):
  mxinc2[i] = max(mxinc2[i-1], xinc2[i-1])
  mxdec2[i] = max(mxdec2[i-1], xdec2[i-1])
  
ans = 0
for i in range(N):
  ans = max(ans, xinc[i], xdec[i])
  ans = max(ans, mxinc2[i]+xdec[N-1-i])
  ans = max(ans, mxdec2[i]+xinc[N-1-i])

print(ans)
  

Measured memory_bytes: 48380
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[10010][110][2] = {};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string K;
    ll D;
    cin >> K >> D;
    ll keta = K.size();
    dp[0][0][0] = 1;
    rep(i,0,keta){
        rep(j,0,D){
            ll d = K[i] - '0';
            rep(k,0,d+1){
                if(k == d){
                    dp[i+1][(j+k)%D][0] += dp[i][j][0];
                    dp[i+1][(j+k)%D][0] %= MOD;
                }else{
                    dp[i+1][(j+k)%D][1] += dp[i][j][0];
                    dp[i+1][(j+k)%D][1] %= MOD;
                }
            }
            rep(k,0,10){
                dp[i+1][(j+k)%D][1] += dp[i][j][1];
                dp[i+1][(j+k)%D][1] %= MOD;
            }
        }
    }
    ll ans = (dp[keta][0][0] + dp[keta][0][1]) % MOD;
    print((ans-1+MOD)%MOD);


    

}

Measured memory_bytes: 17408
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
const ll INF = (ll)1e18 + 1;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int n; cin >> n;
    int a[n]; rep(i,n) cin >> a[i];
    int res=0;

    for(int i=0; i<n; i+=2) if(a[i]%2==1) res++;

    cout << res << ln;
    return 0;
}

Measured memory_bytes: 3648
b,w = map(int,input().split())
a,v = map(int,input().split())
t = int(input())
d = abs(a-b)
v1 = w-v
if v1 <= 0:
    print("NO")
else:
    if d-v1*t <= 0:
        print("YES")
    else:
        print("NO")

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

using namespace std;

int main () {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	long long n, k, m1, m2;
	cin >> n >> k;
	m1 = n % k;
	m2 = abs(m1 - k);
	cout << min(m1, m2);
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)


class Perm:
    def __init__(self, size, mod):
        self.size = size
        self.mod = mod
        self.factrial = [1]
        self.inverse = [1]
        pre_f = 1
        for i in range(1, self.size+1):
            pre_f = (pre_f * i) % self.mod
            self.factrial.append(pre_f)
            self.inverse.append(pow(pre_f, self.mod-2, self.mod))
    def perm(self, n, r):
        if n < r:
            return 0
        return (self.factrial[n] * self.inverse[n-r]) % self.mod


mod = 10**9 + 7
n,k = map(int, input().split())
per = Perm(1000, mod)
print(per.perm(k,n))


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

const ll INF = 1LL << 60;

ll mod=1000000007;

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


int main() {
  string s,t;cin>>s>>t;
  int n=s.size();
  int ans=0;
  rep(i,n){
    if(s[i]!=t[i])ans++;
  }
  cout<<ans;
}

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

using namespace std;


typedef long long ll;
ll mod=1e9+0LL;
ll MOD=1e18+0LL;
double pi=acos(-1);


int main()
{
    int cs=1;
    //scanf("%d",&cs);
    while(cs--)
    {
        ll n,m;char c;ll k;
        cin>>n>>m>>c>>k;
        m*=100;
        m+=k;
        k=(n*m)/100;
        cout<<(k);
    }
}

Measured memory_bytes: 3624
// Aizu 1269: Sum of Different Primes
// 2017.9.21 bal4u@uu

#include <stdio.h>

#define N 189
int pm[N+1] = { 0,
     2,      3,      5,      7,     11,     13,     17,     19,     23,     29, 
    31,     37,     41,     43,     47,     53,     59,     61,     67,     71, 
    73,     79,     83,     89,     97,    101,    103,    107,    109,    113, 
   127,    131,    137,    139,    149,    151,    157,    163,    167,    173, 
   179,    181,    191,    193,    197,    199,    211,    223,    227,    229, 
   233,    239,    241,    251,    257,    263,    269,    271,    277,    281, 
   283,    293,    307,    311,    313,    317,    331,    337,    347,    349, 
   353,    359,    367,    373,    379,    383,    389,    397,    401,    409, 
   419,    421,    431,    433,    439,    443,    449,    457,    461,    463, 
   467,    479,    487,    491,    499,    503,    509,    521,    523,    541, 
   547,    557,    563,    569,    571,    577,    587,    593,    599,    601, 
   607,    613,    617,    619,    631,    641,    643,    647,    653,    659, 
   661,    673,    677,    683,    691,    701,    709,    719,    727,    733, 
   739,    743,    751,    757,    761,    769,    773,    787,    797,    809, 
   811,    821,    823,    827,    829,    839,    853,    857,    859,    863, 
   877,    881,    883,    887,    907,    911,    919,    929,    937,    941, 
   947,    953,    967,    971,    977,    983,    991,    997,   1009,   1013, 
  1019,   1021,   1031,   1033,   1039,   1049,   1051,   1061,   1063,   1069, 
  1087,   1091,   1093,   1097,   1103,   1109,   1117,	  1123 };

int dp[190][16][1125];

int main()
{
	int n, k, i, j, m;

	dp[1][0][0] = 1, dp[1][1][2] = 1;
	for (i = 2; i < N; i++) for (j = 0; j <= 14; j++) {
		for (m = 0; m <= 1120; m++)	{
			dp[i][j][m] += dp[i-1][j][m];
			if (m + pm[i] <= 1120) dp[i][j+1][m+pm[i]] += dp[i-1][j][m];
		}
	}
	while (scanf("%d%d", &n, &k) && n) printf("%d\n", dp[N-1][k][n]);
	return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


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

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

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

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N, K;
  cin >> N >> K;
  vector< int > A(N);
  cin >> A;

  vector< int > dame(1 << N);
  for(int i = 0; i < (1 << N); i++) {
    int64 X = 0;
    for(int j = 0; j < N; j++) {
      if((i >> j) & 1) {
        X += A[j];
      }
    }
    if(X == K) dame[i] = 1;
  }

  for(int i = 0; i < (1 << N); i++) {
    if(dame[i]) {
      for(int j = 0; j < N; j++) {
        dame[i | (1 << j)] = true;
      }
    }
  }
  int ret = 0;
  for(int i = 0; i < (1 << N); i++) {
    if(dame[i]) continue;
    chmax(ret, __builtin_popcount(i));
  }
  cout << N - ret << endl;

}



Measured memory_bytes: 7056
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main(): #startline-------------------------------------------
    n = int(input())
    h = list(map(int,input().split()))
    dp = [0]*(n)
    dp[1] = abs(h[1]-h[0])
    for i in range(2,n):
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
    print(dp[n-1])
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 23960