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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

ll calc(ll a,ll x) {
  if( a < 0 ) return 0;
  return a / x + 1;
}

int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  ll ans = calc(b,c) - calc(a-1,c); 
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
const ll mod=998244353;
int main()
{
	int a,b,c,d;
	sc(a);sc(b);sc(c);sc(d);
	while(a>0&&c>0){
		c-=b;
		if(c<=0)break;
		a-=d;
	}if(c<=0)pf("Yes\n");
	else pf("No\n");
}


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

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  if (s < t) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}


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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int main(){
    int N, K;
    cin >> N >> K;
    vector<int64_t> A, Apos, Aneg;
    int z = 0;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        A.push_back(abs(a));
        if(a > 0){
            Apos.push_back(a);
        }else if(a < 0){
            Aneg.push_back(abs(a));
        }else{
            z++;
        }
    }
    sort(Apos.rbegin(), Apos.rend());
    sort(Aneg.rbegin(), Aneg.rend());
    int szp = Apos.size(), szn = Aneg.size();

    int64_t ans = 1;
    if(szp + szn/2*2 >= K && (K%2 == 0 || szp > 0)){
        int pp = 0, pn = 0;
        if(K%2){
            ans = Apos[0];
            pp++;
            K--;
        }
        while(K){
            int64_t v1 = (szp-pp >= 2 ? Apos[pp] * Apos[pp+1] : 0);
            int64_t v2 = (szn-pn >= 2 ? Aneg[pn] * Aneg[pn+1] : 0);
            if(v1 >= v2){
                mul(ans, v1 % MOD);
                pp += 2;
            }else{
                mul(ans, v2 % MOD);
                pn += 2;
            }
            K -= 2;
        }
    }else if(z){
        ans = 0;
    }else{
        sort(A.begin(), A.end());
        for(int i=0; i<K; i++) mul(ans, A[i]);
        ans = (MOD-ans) % MOD;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int n;
  scanf("%d", &n);
  int ans = 0;
  vector<vector<int>> arr(n); 
  vector<int> nowq, nxtq;
  vector<int> cnt(n);
  for (int i = 0; i < n; ++i)
    for (int j = 1; j < n; ++j) {
      int x;
      scanf("%d", &x);
      arr[i].push_back(x - 1);
    }
  for (int i = 0; i < n; ++i)
    if (i == arr[arr[i][0]][0])
      nowq.push_back(i);
  while (!nowq.empty()) {
    ++ans;
    nxtq.clear();
    for (auto &x: nowq) {
      cnt[x]++;
      if (cnt[x] < n - 1) {
        int y = arr[x][cnt[x]];
        if (cnt[y] < n - 1 && arr[y][cnt[y]] == x)
          nxtq.push_back(x), nxtq.push_back(y);
      }
    }
    sort(nxtq.begin(), nxtq.end());
    nxtq.erase(unique(nxtq.begin(), nxtq.end()), nxtq.end());
    nowq.swap(nxtq);
  }
  for (int i = 0; i < n; ++i)
    if (cnt[i] != n - 1)
      return puts("-1") & 0;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 4352
n = int(input())


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]

def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a


ans = 0
for i in range(105, n+1):
    fct = factorize(i)
    if i % 2 == 0:
        continue
    if len(divisorize(fct)) == 8:
       ans += 1
print(ans)


Measured memory_bytes: 3064
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
s=0
buf=-2
for i in range(n):
    x=a[i]-1
    s+=b[x]
    if x==buf+1:
        s+=c[buf]
    buf=x
print(s)

Measured memory_bytes: 3060
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

int main() {
  ll k, a, b;
  cin >> k >> a >> b;
  bool cond = b - a <= 2 || k < a + 1;
  
  if(cond){
    cout << k + 1 << endl;
    return 0;
  }

  ll ans = a + (k - a + 1) / 2 * (b - a) + (k - a + 1) % 2;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
char1 = input()
char2 = input()
char3 = ""
char4 = ""
for x in reversed(range(3)):
  char3=char3+char2[x]
for y in reversed(range(3)):
  char4=char4+char1[y]
if char2 == char4:
  print("YES")
else:
  print("NO")


Measured memory_bytes: 2940
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		long a = sc.nextLong();
		long b = sc.nextLong();
		
		PrimeNumberGenerator pg = new PrimeNumberGenerator();
		int p = 2;
		
		//最低でも1は公約数
		int count = 1;
		
		while(a > 1 && b > 1 && p <= 1_000_000) {
			if(!pg.isPrime(p)) {
				p++;
				continue;
			}
			
//			System.out.println(a + " "+ b);
			if(a % p == 0 && b % p == 0) {
				count++;
			}
			
			while(a % p == 0) {
				a /= p;
			}
			
			while(b % p == 0) {
				b /= p;
			}
			p++;
		}
		
		if(a > 1 && b > 1 && a == b) {
			count++;
		}
		
		System.out.println(count);
	}

}

class PrimeNumberGenerator {
    private boolean[] isPrime= new boolean[1000001];
 
    public PrimeNumberGenerator() {
        //Date from = new Date();
        Arrays.fill(isPrime, true);
 
        isPrime[0] = false;
        isPrime[1] = false;
        isPrime[2] = true;
 
        int limit = (int)Math.sqrt(isPrime.length);
        for(int i = 3; i <= limit; i+=2){
            /*
            if(i % 2 == 0){
                isPrime[i] = false;
                continue;
            }
            */
 
            if(isPrime[i] == false){
                continue;
            }
 
            for(int j = i * 2; j <= isPrime.length - 1; j += i){
                isPrime[j] = false;
            }
        }
        //Date to = new Date();
        //System.out.println("init takes "+ (to.getTime() - from.getTime())+ "milli sec");
    }
 
    public boolean isPrime(int index){
        if(index % 2 == 0 && index != 2){
            return false;
        }
        return isPrime[index];
    }
}


Measured memory_bytes: 25684
import numpy as np

def chmin(a,b):
    a = a if a < b else b

    return a

def chmax(a, b):
    a = a if a > b else b

    return a


N = int(input().strip())

h_point = []
temp = input().split()
for i in range(N):
    h_point.append(int(temp[i]))

costs = [0, abs(h_point[1]-h_point[0])]
for i in range(2, N):
    ans_temp = chmin(costs[i-1]+abs(h_point[i]-h_point[i-1]), costs[i-2]+abs(h_point[i]-h_point[i-2]))
    costs.append(ans_temp)

print(costs[N-1])

Measured memory_bytes: 42440
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
const int MAX_V = 110;
int n;
int m;//道路の数
int s;
int b1,b2;
int g1,g2;
int c;

int d[MAX_V];
int cost[MAX_V][MAX_V];

int main(){
	while(cin>>n>>m>>s>>g1>>g2,n||m||s||g1||g2){
		rep(i,n+1){
			rep(j,n+1){
				cost[i][j] = INF;
				if(i==j){
					cost[i][j] = 0;
				}
			}
		}
		rep(i,m){
			cin>>b1>>b2>>c;
			cost[b1][b2] = c;
		}
		for(int k = 1;k <=n;k++){
			for(int i = 1;i <=n;i++){
				for(int j = 1;j <=n;j++){
					cost[i][j] =min(cost[i][j],cost[i][k]+cost[k][j]);
				}
			}
		}
		int ans = INF;
		for(int i = 1;i <=n;i++){
			ans = min(ans,cost[s][i]+cost[i][g1]+cost[i][g2]);
		}
		cout <<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int n,k,a;
int s[7],s1[7];
int num[12];
bool che(int n)
{
	while(n>=1)
	{
		int x=n%10;
		if(num[x]==1)
		{
			return 0;
		}
		n/=10;
	}
	return 1;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++)
	{
		scanf("%d",&a);
		num[a]=1;
	}
	while(1)
	{
		if(che(n))
		{
			printf("%d",n);
			return 0;
		}
		n++;
	}
}


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

int n;
int x[24],y[24],r[24],c[24];
bool memo[1<<24];
char bit_count[1<<24];

bool ok(int a,int bit){
    for(int i=0;i<a;i++){
        if(((bit>>i)&1)==0)continue;
        int dist=(x[i]-x[a])*(x[i]-x[a])+(y[i]-y[a])*(y[i]-y[a]);
        int sum=(r[i]+r[a])*(r[i]+r[a]);
        if(dist<sum)return false;
    }
    return true;
}

int dfs(int bit){
    memo[bit]=true;

    int ret=n;
    for(int i=0;i<n;i++)if((bit>>i)&1)ret--;

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(((bit>>i)&1)==0)continue;
            if(((bit>>j)&1)==0)continue;
            int to_bit=(bit^(1<<i))^(1<<j);
            if(c[i]==c[j]&&ok(i,bit)&&ok(j,bit)&&!memo[to_bit]){
                ret=max(ret,dfs(to_bit));
            }
        }
    }


    return ret;
}

void solve(){
    fill_n(memo,1<<n,false);

    cout<<dfs((1<<n)-1)<<endl;
}

bool input(){
    cin>>n;
    if(!n)return false;
    for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>r[i]>>c[i];
    return true;
}

void init(){
    for(int i=0;i<(1<<24);i++){
        for(int j=0;j<24;j++)if((i>>j)&1){
            bit_count[i]++;
        }
    }
}

int main(){
    //init();
    while(input())solve();
    return 0;
}

Measured memory_bytes: 17552
#include<stdio.h>

int main () {
    int c = 0, i, j, k, l, n [98], x [301];
    for (i = 0; n [i - 1] != 0 || x [i - 1] != 0; i++) {
         scanf("%d %d", &n [i], &x [i]);
    }
    for (i = 0; n [i] != 0 || x [i] != 0; i++) {
        for (j = 1; j < n [i] - 1; j++) {
            for (k = j + 1; k < n [i]; k++) {
                for (l = k + 1; l < n [i] + 1; l++) {
                    if (j + k + l == x [i]) {
                        c++;
                    }
                }
            }
        }
    printf("%d\n", c);
    c = 0;
    }

    return 0;
}




Measured memory_bytes: 2140
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
using namespace std;

int main(void)
{
	int a,b;
	int t;

	int countt=0;
	int counth=0;

	string input;
	string n;

	stringstream ss;

	while(1)
	{
		cin >> input;
		if(cin.eof())
			break;
		ss.clear();
		ss << input.substr(0,input.find(','));
		ss >> a;
		input = input.substr(input.find(',')+1);

		ss.clear();
		ss << input.substr(0,input.find(','));
		ss >> b;
		input = input.substr(input.find(',')+1);

		ss.clear();
		ss << input.substr(0,input.find(','));
		ss >> t;
		if(a*a+b*b == t*t)//直角を持つ
		{
			if(a == b);// ++counth;
			else
				++countt;
		}
		else
			if(a == b)
				++counth;
	}
	cout << countt << endl;
	cout << counth << endl;
	//system("pause");
	return 0;
}

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

using namespace std;

class Dice{
private:
  void roll(int a,int b,int c,int d){
    swap(x[a],x[b]);
    swap(x[b],x[d]);
    swap(x[c],x[d]);
  }
public:
  int x[6];
  void roll_N(){ roll(0,1,4,5); }
  void roll_E(){ roll(0,3,2,5); }
  void roll_S(){ roll(0,4,1,5); }
  void roll_W(){ roll(0,2,3,5); }
  void rotation(){ roll(1,2,3,4); }
  void roll(int top,int front){
    for(int i = 0 ; i < 2 ; i++){
      for(int j = 0 ; j < 4 ; j++){
        roll_N();
        if(top == x[0]){ goto next; }
      }
      roll_E();
    }
     next:
    for(int i = 0 ; i < 4 ; i++){
      rotation();
      if(front == x[1]){ break; }
    }
  }
  bool operator == (Dice &d){
    for(int i = 0 ; i < 4 ; i++){
      for(int j = 0 ; j < 4 ; j++){
        d.roll_N();
        bool equals = true;
        for(int k = 0 ; k < 6 ; k++){
          if(x[k] != d.x[k]){
            equals = false;
            break;
          }
        }
        if(equals){ return true; }
      }
      for(int j = 0 ; j < 4 ; j++){
        d.roll_E();
        bool equals = true;
        for(int k = 0 ; k < 6 ; k++){
          if(x[k] != d.x[k]){
            equals = false;
            break;
          }
        }
        if(equals){ return true; }
      }
      d.rotation();
    }
    return false;
  }
};

int main(){
  Dice die[2];
  for(int i = 0 ; i < 2 ; i++){
    for(int j = 0 ; j < 6 ; j++){
      cin >> die[i].x[j];
    }
  }
  cout << (die[0] == die[1] ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;



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

    ll N, M, K;
    cin >> N >> M >> K;

    vl a(N), b(M);
    REP(i, N) cin >> a[i];
    REP(i, M) cin >> b[i];

    vl ca(N+1);
    vl cb(M+1);
    ca[0] = 0;
    cb[0] = 0;
    REP(i, N) ca[i+1] = ca[i] + a[i];
    REP(i, M) cb[i+1] = cb[i] + b[i];

    int ans = 0;
    REP(i, N+1) if (ca[i] <= K) {
        int j = distance(cb.begin(), upper_bound(ALL(cb), K-ca[i]));
        ans = max(ans, i+j-1);
    }
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9508
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,w) for (int i = 0;i < (w); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;

const int mod = 1000000007;
class mint {
  long long x;
public:
  mint(long long x=0) : x((x%mod+mod)%mod) {}
  mint operator-() const { 
  return mint(-x);
  }
  mint& operator+=(const mint& a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint& a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const  mint& a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint& a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint& a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint& a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint& a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint& a) const {
    mint res(*this);
    return res/=a;
  }
  friend ostream& operator<<(ostream& os, const mint& m){
    os << m.x;
    return os;
  }
};

int main(){
  int n;cin >> n;
  vector<int> a(n);
  vector<int> mp(200005,INF);
  vector<mint> dp(200005);
  dp[0] = 1;
  rep(i,n){
    cin >> a[i];
    dp[i+1] = dp[i] + ((mp[a[i]] != i-1&&mp[a[i]] != INF) ? dp[mp[a[i]]+1] : 0);
    mp[a[i]] = i;
  }
  cout << dp[n] << endl; 
  
}

Measured memory_bytes: 6392
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;

ll n, a[100001], b1[100001]{}, b2[100001]{}, ans1 = 0, ans2 = 0;

int main() {

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (a[0] != 0) {
		b1[0] += a[0];
	}
	else {
		ans1++;
		int j = 1;
		while (j<n && a[j] == 0)j++;
		if (j != n) {
			b1[0] = (a[j] / abs(a[j]));
			if (j % 2 == 1)b1[0] *= -1;
		}

		else
			b1[0] = 1;

	}
	for (int i = 1; i < n; i++) {
		b1[i] += a[i] + b1[i - 1];
		if (b1[i] * (b1[i - 1] / abs(b1[i - 1])) >= 0) {
			if (b1[i - 1] > 0) {
				ans1 += abs(b1[i]) + 1;
				b1[i] = -1;
			}
			else {
				ans1 += abs(b1[i]) + 1;
				b1[i] = 1;
			}
		}
	}


	if (a[0] != 0) {
		b2[0] += a[0];
		ans2 += abs(b2[0]) + 1;
		b2[0] = -b2[0] / abs(b2[0]);
	}
	else {
		ans2++;
		int j = 1;
		while (j<n && a[j] == 0)j++;
		if (j != n) {
			b2[0] = (a[j] / abs(a[j]));
			if (j % 2 == 0)b2[0] *= -1;
		}

		else
			b2[0] = -1;

	}
	for (int i = 1; i < n; i++) {
		b2[i] += a[i] + b2[i - 1];
		if (b2[i] * (b2[i - 1] / abs(b2[i - 1])) >= 0) {
			if (b2[i - 1] > 0) {
				ans2 += abs(b2[i]) + 1;
				b2[i] = -1;
			}
			else {
				ans2 += abs(b2[i]) + 1;
				b2[i] = 1;
			}
		}
	}
	cout << min(ans1,ans2) << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)
const ll INF=1e17;
using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  ll a,b,q,x,y;
  cin>>a>>b>>q;
  vector<ll> s,t;
  map<ll,ll> m;
  rep(i,0,a) {cin>>y; if(m.find(y)==m.end()) s.pb(y),m[y]=1;}
  m.clear();
  rep(i,0,b) {cin>>y; if(m.find(y)==m.end())t.pb(y),m[y]=1;}

  sort(all(s));
  sort(all(t));

  rep(i,0,q){
    cin>>x;
    ll ans=INF;
    ll si,tj,tj1,idx= lower_bound(all(t),x)-t.begin();

    if(idx==t.size()) tj1=INF;
    else tj1=t[idx];
    if(idx==0) tj=-INF;
    else tj=t[idx-1];
    // cout<<tj<<" "<<tj1<<endl;

    ll idx1=lower_bound(all(s),x)-s.begin(),idx2=lower_bound(all(s),x)-s.begin();
    if(idx1==s.size()) si=s[idx1-1];
    else si=s[idx1];

    if(si>=tj1) ans=min(ans,si-x);
    else if(x<=si) ans=min(ans,tj1-x),ans=min(ans,min(abs(x-tj),abs(x-si))+abs(si-tj));
    else if(si>=tj )ans=min(ans,min(abs(x-si),abs(x-tj1))+abs(si-tj1)),ans=min(ans,min(abs(x-tj),abs(x-si))+abs(si-tj));
    else ans=min(ans,abs(x-si));

      // cout<<si<<"...."<<ans<<endl;

    if(idx2==s.size()) si=s[idx2-1];
    else if(idx2>=1 )si=s[idx2-1];
    else si=s[idx2];

    if(si>=tj1) ans=min(ans,si-x);
    else if(x<=si) ans=min(ans,tj1-x),ans=min(ans,min(abs(x-tj),abs(x-si))+abs(si-tj));
    else if(si>=tj )ans=min(ans,min(abs(x-si),abs(x-tj1))+abs(si-tj1)),ans=min(ans,min(abs(x-tj),abs(x-si))+abs(si-tj));
    else ans=min(ans,abs(x-si));


    // cout<<si<<"...."<<ans<<endl;
    cout<<ans<<endl;
  }
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 11376
while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")

Measured memory_bytes: 7632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	int k; cin>>k;
	int sum=0;
	for(int i=1; i<=k; i++)
		for(int j=1; j<=k; j++)
			for(int l=1; l<=k; l++){
				int nw=__gcd(i, j);
				nw=__gcd(nw, l);
				sum+=nw;
			}
	cout<<sum<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main() 
{
	int a, b, C;
	double S, L, h, PI;
	PI = 3.14159265358979;
	cin >> a >> b >> C;
	S = 0.5 * a * b * sin(C * PI / 180);
	L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(C * PI / 180));
	h = b * sin(C * PI / 180);
	cout << fixed << setprecision(8) << S << endl;
	cout << fixed << setprecision(8) << L << endl;
	cout << fixed << setprecision(8) << h << endl;
	return 0;
}


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

using namespace std;

int main()
{
  int H,W = 0;

  while(true)
    {
      cin >> H >> W;
      
      if(H == 0 && W == 0)
	{
	  break;
	}

      for(int i = 0;i < H;i++)
	{
	  for(int j = 0;j < W;j++)
	    {
	      if(i == 0 || i == H-1)
		{
		  cout <<"#";
		}
	      
	      if(i > 0 && i < H-1)
		{
		  if(j == 0 || j == W-1)
		    {
		      cout << "#";
		    }

		  if(j > 0 && j < W-1)
		    {
		      cout << ".";
		    }
		}
	    }
	  cout << endl;
	}
      cout << endl;
    }
  return 0;
}



Measured memory_bytes: 3044
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
fast_io
vi x(2); cin>>x[0]>>x[1];
int a[3]={0};
rep(i,2){
	if((x[i]<=7 and x[i]&1) or (x[i]>=8 and !(x[i]&1))){ a[0]++;}
	else if(x[i]==2) a[1]++;
	else a[2]++;
}
if(a[0]==2 or a[1]==2 or a[2]==2)cout<<"Yes";
else cout<<"No";
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, k;
  scanf("%d %d", &n, &k);

  // vector<int> v(n);
  int counter = 0;
  for (int i = 0; i < n; i++) {
    int h;
    scanf("%d", &h);
    if (h >= k) {
      counter++;
    }
  }

  cout << counter << endl;
  
  return 0;
}


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

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

	int n = 0;
	char ch;
	while (1) {
		if (n++ == 0 || ch == 'a') {
			if (a.empty()) {
				cout << 'A' << endl;
				break;
			}
			ch = a.front(); a.erase(a.begin());
			//cout << a << endl;
		}
		else if (ch == 'b') {
			if (b.empty()) {
				cout << 'B' << endl;
				break;
			}
			ch = b.front(); b.erase(b.begin());
			//cout << b << endl;
		}
		else if (ch == 'c') {
			if (c.empty()) {
				cout << 'C' << endl;
				break;
			}
			ch = c.front(); c.erase(c.begin());
			//cout << c << endl;
		}
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int linearSearch(int a, int n, int S[]){

  for(int i=0; i<n; i++){
    if(a == S[i]) return 1;
  }

  return 0;
}

int main(){

  int i, n, q;
  scanf("%d", &n);
  int S[n];
  for(i=0; i<n; i++) scanf("%d", &S[i]);
  scanf("%d", &q);
  int T[n];
  for(i=0; i<n; i++) scanf("%d", &T[i]);

  int anw = 0;

  for(i=0; i<q; i++){
    if(linearSearch(T[i], n, S)) anw++;
  }

  printf("%d\n", anw);
  
  return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include <queue>
#include<algorithm>
typedef long long int ll;
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,a) for (int i=1;i<=(a);i++)
const ll MOD = (10*10*10*10*10*10*10*10*10+7);
    int ans=0,id;
    int N,M;
    int A,B;
    string O,E;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>O>>E;
    if(O.size()>E.size())cout<<"GREATER";
    else if(O.size()<E.size())cout<<"LESS";
    else {
        for(int i=0;i<(signed)O.size();i++){
            if(O[i]==E[i])continue;
            if(O[i]<E[i]){
                cout<<"LESS";
                return 0;
            }else{
                cout<<"GREATER";
                return 0;
            }
        }
        cout<<"EQUAL";
        return 0;
    }
    //cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a,b; cin >> a >> b;
    if(a > b){
        cout << "a > b" << endl;
    } else if( a < b){
        cout << "a < b" << endl;
    } else {
        cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>

using namespace std;

int main()
{
	int N, A, B,S=0;
	cin >> N >> A >> B;
	
	for (int i = 1; i <= N; i++)
	{
		int s = 0;
		for (int r = i % 10, n = i; n; n /= 10,r=n%10)
			s += r;
		if (s >= A && s <= B)
			S += i;
	}
	cout << S << endl;
	return 0;
}


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

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

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> a(N);
    rep(i, N) { 
        cin >> a[i];
    }
    ll cnt = 1;
    ll ans = 0;
    rep(i, N) {
        if (a[i] == cnt) {
            cnt++;
        } else {
            ans++;
        }
    }
    if (ans == N) ans = -1;
    print(ans);
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	/** 英文字のアルファベット */
	private static final char[] ALPHABET = "abcdefghijklmnopqrstuvwxyz".toCharArray();

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			long n = scanner.nextLong();
			StringBuilder sb = new StringBuilder();
			while (n > 0) {
				sb.append(ALPHABET[(int) ((n - 1) % 26)]);
				n = (n - 1) / 26;
			}
			System.out.println(sb.reverse().toString());
		}
	}
}


Measured memory_bytes: 35820
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;
bool islow(char c) {
  return ('a' <= c && c <= 'z');
}
int main() {
  string s;
  cin >> s;
  int cf = 0;
  if (s[0] == 'A' && islow(s[1]) && islow(s[s.size() - 1])) {
    for (int i = 2; i < (int) (s.size() - 1); ++i) {
      if (s[i] == 'C') {
        cf++;
      } else if (!islow(s[i])) {
        cout << "WA";
        return 0;
      }
    }
  } else {
    cout << "WA";
    return 0;
  }
  if (cf == 1)
    cout << "AC";
  else
    cout << "WA";
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

cost = [0] * (n + 1)
cost[0] = 0
cost[1] = abs(h[1] - h[0])

for i in range(2, n):
  cost1 = cost[i-2] + abs(h[i] - h[i-2])
  cost2 = cost[i-1] + abs(h[i] - h[i-1])
  cost[i] = min(cost1, cost2)
print(cost[n-1])

Measured memory_bytes: 13928
#include <bits/stdc++.h>
using namespace std;
int main()
{
vector<int> vec = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
int x , y ; cin >> x >> y ;
cout << ( vec.at(x) ==vec.at(y)? " Yes " : " No ") << endl ;
}

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

int main()
{
    int64_t X;
    cin >> X;
    int64_t a500, a5;
    a500 = X / 500;
    a5 = (X - a500 * 500) / 5;
    int64_t ans = a500 * 1000 + a5 * 5;
    cout << ans << endl;
}

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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 998244353;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

const int N = 1e5 + 7;
vector<int> g[N];

void dfs(int v, vector<int>& d, int cd = 0) {
    d[v] = cd;
    for (int u : g[v]) {
        if (d[u] == -1) {
            dfs(u, d, cd + 1);
        }
    }
}

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

    int n, u, v;
    cin >> n >> u >> v;
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        g[a].eb(b);
        g[b].eb(a);
    }

    vector<int> du(n + 1, -1), dv(n + 1, -1);
    dfs(u, du);
    dfs(v, dv);

    int ans = max(du[v] - 1, 0);
    for (int i = 1; i <= n; ++i) {
        if (du[i] < dv[i]) {
            xmax(ans, dv[i] - 1);
        }
    }

    cout << ans;
    return 0;
}


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

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


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

typedef long long int ll;

int main(void) {
    int N, M;
    cin >> N >> M;

    ll goukei = 0;
    for(int i=0; i<M; i++) {
        int tmp;
        cin >> tmp;
        goukei += tmp;
    }

    if(goukei <= N) {
        cout << (N-goukei);
    } else
    {
        cout << -1;
    }
}

Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>

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

using namespace std;

typedef long long ll;

const int N_BIN=64;
ll nCr[N_BIN+1][N_BIN+1];
void binom(){
	rep(n,N_BIN+1) nCr[n][0]=1;
	rep(n,N_BIN) rep(r,n+1) nCr[n+1][r+1]=nCr[n][r+1]+nCr[n][r];
}

int main(){
	binom();

	char s[64]; scanf("%s",s);
	int n=strlen(s);

	int freq[128]={};
	rep(i,n) freq[s[i]]++;

	int even=0,odd=0;
	rep(c,128) if(freq[c]%2==0) even++; else odd++;

	if(odd>=2) puts("0");
	else{
		int sum=0;
		rep(c,128) sum+=freq[c]/2;
		ll ans=1;
		rep(c,128) ans*=nCr[sum][freq[c]/2], sum-=freq[c]/2;
		printf("%lld\n",ans);
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        new Main().run(k, n);
    }

    final long MOD = 998244353;

    long[] fac = new long[4001];
    long[] ifac = new long[4001];
    long[] inv = new long[4001];
    long[] pow2 = new long[4001];
    {
        fac[0] = fac[1] = ifac[0] = ifac[1] = inv[0] = inv[1] = pow2[0] = 1;
        for(int i = 2;i < fac.length; ++i){
            fac[i] = fac[i-1] * i % MOD;
        }
        for(int i = 2;i < inv.length;++i){
            inv[i] = MOD - inv[(int)MOD % i] * (MOD / i)%MOD;
        }
        for(int i = 2;i < ifac.length;++i){
            ifac[i] = ifac[i-1] * inv[i] % MOD;
        }
        for(int i = 1;i < pow2.length; ++i){
            pow2[i] = 2 * pow2[i - 1] % MOD;
        }
    }

    long solve(int K, int N, int t, boolean f){
        if(t % 2 == 0 && !f) return (solve(K, N - 1, t, true) + solve(K, N, t, true)) % MOD;
        long ret = 0;
        int p = 0;
        for(int i = 1;i < t && i < t - i; ++i) if(t - i <= K) ++p;
        for(int q = 0;q <= p; ++q){
            ret += comb(p ,q) * pow2[q] % MOD * comb(N - q + K - 2 * p - (f? 1 : 0 ) + q - 1, N - q) % MOD;
            ret %= MOD;
        }
        return ret;
    }


    void run(int K, int N){
        for(int t = 2;t <= 2 * K; ++t){
            System.out.println(solve(K, N, t, false));
        }
    }


    long comb(int n,int k){
        if(n < k) return 0;
        if(n < 0 || k < 0) return 0;
        return fac[n] * ifac[k] % MOD * ifac[n-k] % MOD;
    }

    void tr(Object...objects){
        System.out.println(Arrays.deepToString(objects));
    }
}

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

int main() {
    int a[9999];
    int count = 0;
    for(int i = 0;; i++){
        cin >> a[i];
        if (a[i] == 0){
            count = i;
            break;
        }
    }
    
    for(int i = 0 ; i < count; i++){
        cout << "Case " << i + 1 << ": " << a[i] << endl;
    }
    return 0;
}


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

int main(){
	int q;
	int *a;
	int x,y,com;
	int right,left;
	
	scanf("%d",&q);
	a=malloc(sizeof(int)*2*q);
	left=q-1;
	right=q;
	
	
	for(int i=0;i<q;i++){
	
		scanf("%d",&com);
		
		if(com==0){
			scanf("%d %d",&x,&y);
			if(x)a[right++]=y;
			else a[left--]=y;
		}
		
		if(com==1){
			scanf("%d",&x);
			printf("%d\n",a[left+x+1]);
		}
		
		if(com==2){
			scanf("%d",&x);
			if(x)a[right--]=-1;
			else a[left++]=-1;
		}
		
	}
	
	return 0;
	
}


Measured memory_bytes: 3288
import java.math.BigInteger;
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		BigInteger x=BigInteger.ZERO;
		for(;;)
		{
			BigInteger n=in.nextBigInteger();
			if(n.compareTo(x)==0)
				return;
			String k=n.toString(8);
			char ch[]=k.toCharArray();
			for(int i=0;i<ch.length;i++)
			{
				if(ch[i]=='4')
					ch[i]='5';
				else if(ch[i]=='5')
					ch[i]='7';
				else if(ch[i]=='6')
					ch[i]='8';
				else if(ch[i]=='7')
					ch[i]='9';
			}
			System.out.println(ch);
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
#define endl '\n'
typedef long long LL;
LL sum[N],a[N],m,n;
int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin >> n >> m;
    for(int i = 1;i <= n; ++i) cin >> a[i];
    sort(a+1,a+1+n);
    for(int i = 1;i <= n; ++i) sum[i] = sum[i - 1] + a[i];
    LL l = 0,r = 2*N,ans,res,cnt;
    while(l < r) {
        LL mid = l + r + 1 >> 1;
        res = cnt = 0;
        for(int i = 1;i <= n; ++i) {
            LL pos = lower_bound(a+1,a+1+n,mid-a[i]) - a;
            cnt += n - pos + 1;
            res += sum[n] - sum[pos - 1] + a[i] * (n - pos + 1);
        }
        if(cnt >= m) l = mid;
        else r = mid - 1;
    }
    cout << res - (cnt - m) * l << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  
  string S,T;
  cin >> S >> T;

  if(S == T.erase(T.size()-1)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    int W,H,N;
    int Ans=0;
    int x[104],y[104],a[104];
    bool f[104][104]={};
    cin >> W >> H >> N;
    REP(i,N){cin >> x[i] >> y[i] >> a[i];}
    REP(i,N){
        if(a[i]==1){
            for(int j=1;j<=x[i];j++){
                for(int k=1;k<=H;k++){
                    f[j][k]=1;
                }
            }
        }
        if(a[i]==2){
            for(int j=x[i]+1;j<=W;j++){
                for(int k=1;k<=H;k++){
                    f[j][k]=1;
                }
            }
        }
        if(a[i]==3){
            for(int j=1;j<=y[i];j++){
                for(int k=1;k<=W;k++){
                    f[k][j]=1;
                }
            }
        }
        if(a[i]==4){
            for(int j=y[i]+1;j<=H;j++){
                for(int k=1;k<=W;k++){
                    f[k][j]=1;
                }
            }
        }
    }
    REP(i,H){
        REP(j,W){
            //cout << f[j+1][i+1] << " ";
            if(f[j+1][i+1]==0){
                Ans++;
            }
        }//cout << endl;
    }
    cout << Ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>

int n,k;
int t[222222];
int r[222222];

int sum_t[222222];
int sum_r[222222];
double sum_d[222222];


int main(){
    cin>>n>>k;
    rep(i,n)cin>>t[i];
    rep(i,n)r[i]=t[i]*(1+t[i])/2;


    int tt=0,rr=0;
    double ss=0.0;
    double ans=0.0;

    rep(i,k){
        tt+=t[i],rr+=r[i];
        ss+=(double)r[i]/(double)t[i];
    }

    for(int i=k;i<=n;i++){
        
        ans=max(ss,ans);
        ss-=(double)r[i-k]/(double)t[i-k];
        ss+=(double)r[i]/(double)t[i];
       // sum_r[i]=rr;
        //sum_t[i]=tt;

       // rr+=r[i];
        //rr-=r[i-k];
        //tt+=t[i];
       // tt-=t[i-k];
    }
    printf("%.10lf\n",ans);


    return 0;
}


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

using namespace std;

int a[100100]; 
long long m[100100];

int mod(int n, int m){
    if(n > 0) return (n % m);
    else return (n % m + m);
}

int main(){
    int n; 
    long long sm;
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    sm = 0;
    for(int i = 1; i <= n; i++){
        if(i & 1) sm += 1ll * a[i];
        else sm -= 1ll * a[i];
    }
    m[1] = sm;
    for(int i = 2; i <= n; i++){
        m[i] = 2ll * a[mod(i - 1, n)] - m[mod(i - 1, n)];
    }
    for(int i = 1; i <= n; i++) cout << m[i] << ' ';
    cout << '\n';
}

Measured memory_bytes: 2432
#include <math.h>
#include <stdio.h>

#define EPS 1e-10

int rel_s_s( double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, double *x, double *y ) {
	double dn = ( x2 - x1 ) * ( y4 - y3 ) - ( x4 - x3 ) * ( y2 - y1 );
	double nm = ( x3 - x1 ) * ( y4 - y3 ) - ( x4 - x3 ) * ( y3 - y1 );

	if ( fabs( dn ) < EPS )
		if ( fabs( nm ) < EPS ) {
			double h1 = x1 == x2 ? ( y3 - y1 ) / ( y2 - y1 ) : ( x3 - x1 ) / ( x2 - x1 );
			double h2 = x1 == x2 ? ( y4 - y1 ) / ( y2 - y1 ) : ( x4 - x1 ) / ( x2 - x1 );

			if ( ( h1 < h2 ? h1 : h2 ) < 0.0 && fabs( h1 < h2 ? h2 : h1 ) < EPS ) {
				*x = x1;
				*y = y1;
				return 4;
			} else if ( fabs( ( h1 < h2 ? h1 : h2 ) - 1.0 ) < EPS && 1.0 < ( h1 < h2 ? h2 : h1 ) ) {
				*x = x2;
				*y = y2;
				return 4;
			} else if ( h1 < 0.0 && h2 < 0.0 || 1.0 < h1 && 1.0 < h2 )
				return 3;
			else
				return 5;
		} else
			return 2;
	else
		if ( fabs( nm / dn - 0.5 ) < 0.5 + EPS && fabs( ( ( x3 - x1 ) * ( y2 - y1 ) - ( x2 - x1 ) * ( y3 - y1 ) ) / dn - 0.5 ) < 0.5 + EPS ) {
			*x = x1 + nm / dn * ( x2 - x1 );
			*y = y1 + nm / dn * ( y2 - y1 );

			if ( fabs( ( x2 - x1 ) * ( x4 - x3 ) + ( y2 - y1 ) * ( y4 - y3 ) ) < EPS )
				return 1;
			else
				return 0;
		} else
			return 6;
}

int main( void ) {
	int q;

	scanf( "%d", &q );
	while ( q-- ) {
		double x0, y0, x1, y1, x2, y2, x3, y3, x, y;

		scanf( "%lf %lf %lf %lf %lf %lf %lf %lf", &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3 );

		rel_s_s( x0, y0, x1, y1, x2, y2, x3, y3, &x, &y );
		printf( "%.8f %.8f\n", x, y );
	}

	return 0;
}

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

typedef long long ll;
ll n,ans;

int main(){
	cin>>n;
	for(ll i=1e17,pos=17;i;i/=10,--pos){
		if(n/i%10>0)
			ans=max(ans,n/i%10-1+pos*9);
	}
	int tmp=0;
	while(n)
		tmp+=n%10,n/=10;
	ans=max(ans,(ll)tmp);
	cout<<ans<<endl;
	return 0;
}


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

int main()
{
  int a;
  cin >> a;
  if(a < 1000) cout << "ABC" << endl;
  else cout << "ABD" << endl;
  return 0;
}


Measured memory_bytes: 3564
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        var n = int.Parse(Console.ReadLine());
        var list = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
        if(list.Count(x => x % 4 == 0) + list.Count(x => x % 4 != 0 && x % 2 == 0) / 2 >= n / 2){
            Console.WriteLine("Yes");
        }else{
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 21216
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
typedef vector<int> vi;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];
int gcd(int a,int b)
{
    if(b==0){
      return a;
     }
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    int res=(a*b)/gcd(a,b);
    return res;
}
int po(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b%2!=0)
        {
            res*=a;
            b--;
        }
        else
        {
            a*=a;
            b/=2;
        }
    }
    return res;
}

lln modMul(lln  a, lln b,lln mod){
    lln ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}
lln powerMod(lln a,lln b,lln mod){
	if(b==0)return 1LL%mod;
	lln x=powerMod( a,b/2,mod );
	x = ( x%mod * x%mod ) % mod;
	if( b%2==1 )x = ( x%mod * a%mod ) % mod;
	return x%mod;
}

int main()
{
   string a;
   int len;
   cin>>len;
   cin>>a;
   int maxi=0;

   int c=0;
   for(int i=0;i<len;i++)
   {
       if(a[i]=='I')
       {
           c++;
           maxi=max(maxi,c);
       }
       else
       {
           c--;
           maxi=max(maxi,c);
       }
   }
   cout<<maxi;

}






Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string bans(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  string s;cin>>s;
  s[3]='8';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
//hinagata.cpp
//作成日
//更新日
//目的
//手段
/*includes*/
#include <bits/stdc++.h>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPi(i,a,b) for(ll i=(a);i<(b);i++)
#define REPRi(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    string S;
    string T;
    cin>>S;
    cin>>T;
    int Slen=S.length();
    int Tlen=T.length();
    //inputend
    int ok=-1;
    REP(i,Slen-Tlen+1){
        int cont=0;
        REP(j,Tlen){
            if(S[i+j]!='?'&&S[i+j]!=T[j]){
                cont=1;
            }
        }
        if(cont==0){
            ok=i;
        }
    }
    if(ok==-1){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }else{
        REP(i,Tlen){
            S[ok+i]=T[i];
        }
        REP(i,Slen){
            if(S[i]=='?'){
                S[i]='a';
            }
        }
        REP(i,Slen){
            cout<<S[i];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256