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

using namespace std;

int main(){
    string T;
    char c;

    cin >> T;
    for(int i = 0;i < (int)T.length();i++){
        c = T[i];
        if(c == '?'){
            T[i] = 'D';
        }
    }
    cout << T << endl;
}

Measured memory_bytes: 3748
import sys
input=lambda: sys.stdin.readline().rstrip()
mod=10**9+7
n,m=map(int,input().split())
A=set(int(i) for i in input().split())
B=set(int(i) for i in input().split())
if len(A)<n or len(B)<m:
  print(0)
else:
  ans=1
  r,c=0,0
  for i in range(1,m*n+1)[::-1]:
    if i in A and i in B:
      r+=1
      c+=1
    elif i in A:
      ans=(ans*c)%mod
      r+=1
    elif i in B:
      ans=(ans*r)%mod
      c+=1
    else:
      if r==n and c==m:
        ans=(ans*i)%mod
      else:
        ans=(ans*(r*c-(m*n-i)))%mod
  print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main(){

    string s;
    cin>>s;
    set<char>c;
    for(int i=0;i<s.size();i++){
        c.insert(s.at(i));
    }
    if(c.size()==2){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }



}









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

int main() {
  int a,b;
  b=0;
  cin>>a;
  int c[a];
  for(int i=0;i<a;i++){
    cin>>c[i];
  }
  for(int i=0;i<a-1;i++){
    for(int j=i+1;j<a;j++){
      b+=c[i]*c[j];
    }
  }
  cout<<b<<endl;
}

Measured memory_bytes: 256
//This disgusting code is wriiten by Juruo D0zingbear
//Please don't hack me! 0v0 <3
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string.h>
#include <stdio.h>
#include <assert.h>
#define LL long long
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define piii pair<int, pii >
#define REP(i,n) for (int (i)=0;(i)<(n);(i)++)
#define vi vector<int>
#define vpi vector< pii >
#define INF 2147483647
#define big 19260817
#define pb push_back
#define mp make_pair
using namespace std;
const int Maxk=1005;
string mul(string a,string b){
	int res[Maxk];
	memset(res,0,sizeof(res));
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for (int i=0;i<a.length();i++){
		for (int j=0;j<b.length();j++){
			res[i+j]+=(a[i]-'0')*(b[j]-'0');
		}
	}
	for (int i=0;i<Maxk;i++){
		if (res[i]>=10) {
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	string ret;
	bool flag=false;
	for (int i=Maxk-1;i>=0;i--){
		if (flag || res[i]){
			flag=true;
			ret=ret+(char)(res[i]+'0');
		}
	}
	if (ret=="") ret="0";
	return ret;
}
string add(string a,string b){
	if (a.length()<b.length()) swap(a,b);
	while (a.length()!=b.length()){
		b='0'+b;
	}
	for (int i=a.length()-1;i>=0;i--){
		a[i]+=(b[i]-'0');
		if (a[i]>'9' && i){
			a[i]-=10;
			a[i-1]++;
		}
	}
	if (a[0]>'9'){
		a[0]-=10;
		a='1'+a;
	}
	return a;
}

// cf IO: I64d
// atcoder IO: ｌｌｄ
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int Maxn=3005;
const long long mod=1e9+7;
long long dp[Maxn][Maxn][2];
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	for (int i=0;i<=n;i++){
		if (i)dp[0][i][0]=1;
		else dp[0][i][1]=1;
	}
	for (int i=0;i<m;i++){
		for (int j=0;j<=n;j++){
			for (int k=0;k<2;k++){
				dp[i][j][k]%=mod;
				if (j) dp[i+1][j-1][k|(j==1)]+=dp[i][j][k];
				if (j) dp[i+1][j][k|(j==1)]+=dp[i][j][k];
				if (j!=n) dp[i+1][j][k]+=dp[i][j][k];
				if (j!=n) dp[i+1][j+1][k]+=dp[i][j][k];
			}
		}
	}
	LL ans=0;
	for (int j=0;j<=n;j++){
		ans+=dp[m][j][1];
	}
	printf("%lld\n",ans%mod);
	return 0;
}

Measured memory_bytes: 141184
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>

#define N 100010
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define pii pair <int, int>
#define PI 3.1415926535897932384626433832795

using namespace std;

int x;
int vis[N];

int main()
{
	cin >> x;
	
	for(int i = 2; i <= x; i++)
		if(vis[i] == 0)
			for(int h = i*i; h <= x; h *= i)
				vis[h] = 1;
	
	for(int i = x; i >= 1; i--)
		if(vis[i] == 1) {
			cout << i;
			return 0;
		}	
	
	cout << 1;
}

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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	string s;
  cin >> s;

  int ans = 0;
  for(int i = 0; i < s.size() - 1; ++i){
    if(s[i] == s[i+1]){
      s[i+1] = (s[i] == '0') ? '1' : '0';
      ans++;
    }
  }

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



Measured memory_bytes: 512
#ifndef LOCAL
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e6 + 10 ;
const ll INF = 1e18 + 10 ;
int n;
vector<vector<int> > v(100000 , vector<int> (3));
int dp[100000 + 1][4];
int dfs(int i , int last) {
    if(i == n) {
        return 0;
    }
    if(dp[i][last] != -1) return dp[i][last] ;
    int ans = 0;

    if(last == 0) {
        ans = max(ans , dfs(i + 1 , 1) + v[i][0]);
        ans = max(ans , dfs(i + 1 , 2) + v[i][1]);
        ans = max(ans , dfs(i + 1 , 3) + v[i][2]);
    }
    else if(last == 1){
        ans = max(ans , dfs(i + 1 , 2) + v[i][1]);
        ans = max(ans , dfs(i + 1 , 3) + v[i][2]);
    }
    else if ( last == 2 ) {
        ans = max(ans , dfs(i + 1 , 1) + v[i][0]);
        ans = max(ans , dfs(i + 1 , 3) + v[i][2]);
    }
    else if ( last == 3 ) {
        ans = max(ans , dfs(i + 1 , 1) + v[i][0]);
        ans = max(ans , dfs(i + 1 , 2) + v[i][1]);
    }
    return dp[i][last] = ans ; 
}
signed main(){
    fastio
    memset(dp , -1 , sizeof dp);
    cin >> n;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> v[i][j];
        }
    }
    int ans = dfs(0 , 0);
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 19564
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); ++i)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();++i) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();++i) vdeb(da[i]);
    std::cout << std::endl;
}

using namespace std;

const ll MOD = 1000000007;

ll modpow(ll a, ll b){
    if(b == 1) return a;
    if(b&1) return modpow(a, b-1) * a % MOD;
    ll tmp = modpow(a, b/2);
    return tmp*tmp%MOD;
}

int main(){
    ll n,k; cin >> n >> k;
    vector<ll> da(k+1);
    rip(i,k+1,1) da[i] = modpow(k/i, n);
    vector<bool> isPrime(k+1, true);
    rip(i,k+1, 2){
        if(isPrime[i]){
            int now = i;
            while(now <= k){
                isPrime[now] = false;
                da[now/i] += MOD - da[now];
                da[now/i] %= MOD;
                now += i;
            }
        }
    }
    ll ans = 0;
    rip(i,k+1,1){
        ans += da[i] * i;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4052
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
ll a[4];
int main(void){
    // Your code here!
    for (ll i = 0; i < 3; i++) {
        cin >> a[i];
    }
    sort(a, a + 3);
    cout << a[2] - a[0] << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,start,lim) for(lld i=start;i<lim;i++)
#define repd(i,start,lim) for(lld i=start;i>=lim;i--)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld ",x)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define br printf("\n")
#define YES printf("YES\n")
#define NO printf("NO\n")
#define all(c) (c).begin(),(c).end()
using namespace std;
#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define MOD         1000000007
#define PI          3.14159265358979323
using namespace std;
typedef long double ldb;
typedef long long lld;
lld powm(lld base,lld exp,lld mod=MOD) {lld ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
typedef vector<lld> vlld;
typedef pair<lld,lld> plld;
typedef map<lld,lld> mlld;
typedef set<lld> slld;
#define N 1005
char a[N][N];
int main()
{
	rep(i,0,N) rep(j,0,N) a[i][j]='#'; 
	lld n,m;
	cin>>n>>m;
	rep(i,1,n+1) rep(j,1,m+1) cin>>a[i][j];
	rep(i,0,n+2) {
		rep(j,0,m+2) cout<<a[i][j];
		br;
	}
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int main()
{
    int n=read();
    cout<<3*n*n<<"\n";
	return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll A; long double B; cin >> A >> B;
    cout << (ll) (A * B) << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    int changes = 0;
    for(int i = 1; i < n; i++) {
        if(a[i] == a[i-1]){
            changes++;
            i++;
        }
    }
    cout << changes << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Fri May  8 00:57:52 2020

@author: Kanaru Sato
"""
import itertools
ans = []
while True:
    n,x = list(map(int,input().split()))
    if n == 0 and x == 0:
        break
    else:
        nums = [i for i in range(1,n+1)]
        count = 0
        for combi in itertools.combinations(nums,3):
            if sum(list(combi)) == x:
                count += 1
        ans.append(count)

[print(ans[i]) for i in range(len(ans))]


Measured memory_bytes: 5660
from subprocess import*
call(('python3','-c',"""
from numpy import*
a=loadtxt(open(0),'i',skiprows=1,ndmin=2)
n=x=len(a)
while a.any():
  t=bincount(a[:,0])
  x,a=min(x,max(t)),reshape(a[a!=argmax(t)],(n,-1))
print(x)
"""))

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

#define rep(i,n) for(int i = 0; i < n; ++i)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

using ll = int_fast64_t;

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

int main() {
  int n; cin >> n;
  vector<ll> a(n); rep(i,n) cin >> a[i];
  int res = 0;
  for (int i = 1; i < n; ++i) {
    if (a[i] == a[i-1]) {
      a[i] = 10000;
      res++;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n; cin >> n;
	vector<vector<int>> graph(n),cost(n);

	rep(i,n-1)
	{
		int foo,fooo,hoge;
		cin >> foo >> fooo >> hoge;
		foo--;fooo--;
		graph[foo].push_back(fooo);
		cost[foo].push_back(hoge%2);
		graph[fooo].push_back(foo);
		cost[fooo].push_back(hoge%2);
	}

	//bfs
	queue<int>Q;
	vector<int> color(n);
	rep(i,n)color[i]=-1;
	color[0]=0;
	Q.push(0);
	while(!Q.empty())
	{
		int now=Q.front();
		Q.pop();
		//graph[now].size()
		rep(i,graph[now].size())
		{
			//cout<<graph[now][i]<<endl;
			if(color[graph[now][i]]==-1)
			{
				Q.push(graph[now][i]);
				color[graph[now][i]]=(color[now]+cost[now][i])%2;
			}
		}
	}

	rep(i,n)
	{
		cout<<color[i]<<endl;
	}

	return 0;
}

Measured memory_bytes: 11904
def resolve():
    A, B, M = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    grid=[list(map(int,input().split())) for i in range(M)]

    res = min(a) + min(b)
    for m in grid:
        if m[0]-1 < A and m[1]-1 < B:
            tmp = a[m[0]-1] + b[m[1]-1] - m[2]
        
            if tmp < res:
                res = tmp

    print(res)
    
resolve()

Measured memory_bytes: 38560
#include<stdio.h>
#define N 100000

typedef struct{
  char name[10];
  int time;
}Pro;

Pro pro[N];
int head = 0, tail = 0, n;

void enqueue(Pro);
Pro dequeue(void);

main(){
  int i, q, r, time = 0;
  Pro pro2;
  scanf("%d %d", &n, &q);
  for(i = 0;i < n;i++){
    scanf("%s %d", pro2.name, &pro2.time);
    enqueue(pro2);
  }
  while(head != tail){
    pro2 = dequeue();
    r = pro2.time;
    pro2.time -= q;
    if(pro2.time > 0){
      enqueue(pro2);
      time += q;
    }
    else if(pro2.time <= 0){
      time += r;
      printf("%s %d\n", pro2.name, time);
    }
  }
  return 0;
}

void enqueue(Pro x){
  pro[tail] = x;
  if(tail == n){
    tail = 0;
  }
  else{
    tail++;
  }
}

Pro dequeue(void){
  Pro y;
  y = pro[head];
  if(head == n){
    head = 0;
  }
  else{
    head++;
  }
  return y;
}

Measured memory_bytes: 1380
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
  int D, T, S;
  cin >> D >> T >> S;
  double tmp = double(D) / S;
  if(T >= tmp)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#include <sstream>
#include <iterator>
 
using namespace std;
 
using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;
 
int main()
{
    i64 n, c;
    scanf("%lld %lld", &n, &c);
 
    vector<i64> dist(n);
    vector<i64> value(n);
 
    for (int i = 0; i < n; i++)
        scanf("%lld %lld", &dist[i], &value[i]);
 
    vector<i64> clock(n), counter(n);
    clock[0] = value[0];
    counter[n - 1] = value[n - 1];
 
    for (int i = 1; i < n; i++)
        clock[i] = value[i] + clock[i - 1];
 
    for (int i = n - 2; i >= 0; i--)
        counter[i] = counter[i + 1] + value[i];
 
    //앞뒤로 시작점에서의 거리만큼 빼준다
 
    for (int i = 0; i < n; i++)
        clock[i] -= dist[i];
 
    for (int i = 0; i < n; i++)
        counter[i] -= c - dist[i];
 
    //각각의 방향에서 특정지점까지 갔을 때 최대치 구하기
    for (int i = 1; i < n; i++)
        clock[i] = max(clock[i - 1], clock[i]);
 
    for (int i = n - 2; i >= 0; i--)
        counter[i] = max(counter[i + 1], counter[i]);
 
    i64 ans = max({ 0ll, clock[n - 1], counter[0] });
 
    //각 방향에서 중간 꺾는 거 계산
 
    for (int i = 0; i < n - 1; i++)
        ans = max(ans, clock[i] - dist[i] + counter[i + 1]);
 
    for (int i = 1; i < n; i++)
        ans = max(ans, counter[i] + clock[i - 1] - (c - dist[i]));
 
 
    printf("%lld", ans);
 
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
const ll maxn = 1e6+10;
const ll inf = 1e14;
struct node{
	ll x,y;
	 
}r[1100];
bool cmp(node a,node b){
	return atan2(a.y,a.x) < atan2(b.y,b.x);
	
}
int main(){
	ll n,x,y;
	cin >> n;
	for(ll i = 0; i < n; i++){
		cin >> r[i].x >> r[i].y;
	}
	ll ans = 0;
	sort(r,r+n,cmp);
	for(ll i = 0; i < n; i++){
		x = r[i].x ; y = r[i].y;
		ans = max(ans,x*x+y*y);
		for(ll j = (i+1)%n; j != i; j = (j+1)%n){
			x += r[j].x ; y += r[j].y;
			ans = max(ans,x*x+y*y);
		}

	}

	double ans1 = sqrt(ans);
	printf("%.13lf\n",ans1);
//	for(int i=0;i<n;i++)
//	{
//		printf("%d %d\n",r[i].x,r[i].y);
//	}
	return 0;
}

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

using namespace std;

typedef long long LL;

LL N,A,B,C,D;

int main()
{
	cin>>N>>A>>B>>C>>D;
	if (A>B) swap(A,B);
	N--;
	LL delta = B-A;
	LL mind = 10000000000000LL;
	bool ok = false;
	for (int i=0;i<=N;i++)
	{
		int j = N-i;
		LL tmp = A + LL(i)*C - LL(j)*C;
		if (B <= tmp + LL(i)*(D-C) && B >= tmp - LL(j)*(D-C))
			ok = true;
	}
	puts(ok?"YES":"NO");
}

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

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

    string s;
    cin >> s;
    cout << s;
    if (s[(int) s.size() - 1] != 's')
        cout << 's' <<  endl;
    else
        cout << "es" << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  cin >> N;
  va.resize(N);
  rep(i, 0, N - 1) { cin >> va[i]; }
}
void solve() {
  sort(all(va));
  map<int, int> mp;
  for (auto x : va) {
    mp[x]++;
  }

  cout << (mp.size() & 1 ? mp.size() : mp.size() - 1) << endl;

  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n, X;
	scanf("%d%d", &n, &X);
	struct Exam {
		int b, l, u;
		ll add;
	};
	vector<Exam> E(n);
	vector<ll> psum(n + 1);
	ll base = 0;
	for (int i = 0; i < n; ++i) {
		scanf("%d%d%d", &E[i].b, &E[i].l, &E[i].u);
		E[i].add = (ll)E[i].u * (X - E[i].b) + (ll)E[i].l * E[i].b;
		base -= (ll)E[i].l * E[i].b;
	}
	sort(E.begin(), E.end(), [&](Exam a, Exam b) {
		return a.add > b.add;
	});
	for (int i = 0; i < n; ++i) {
		psum[i + 1] = psum[i] + E[i].add;
	}
	ll lo = 0, hi = (ll)n * X;
	while (lo < hi) {
		ll m = (lo + hi) >> 1;
		ll add = LLONG_MIN;
		int take = m / X;
		int extra = m % X;
		if (extra == 0) {
			add = psum[take];
		} else {
			assert(take < n);
			for (int i = 0; i < n; ++i) {
				ll single = (ll)E[i].l * min(E[i].b, extra);
				if (extra > E[i].b) single += (ll)E[i].u * (extra - E[i].b);
				ll v;
				if (i < take) {
					v = psum[take + 1] - E[i].add + single;
				} else {
					v = psum[take] + single;
				}
				add = max(add, v);
			}
		}
		if (add + base >= 0) hi = m;
		else lo = m + 1;
	}
	printf("%lld\n", lo);
}


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

using ull = unsigned long long;
using ll = long long;
using ld = long double;


const int MX = 100 * 1000 + 7;

int a[MX];
int b[MX];

ll t[8 * MX];

void add(int v, int tl, int tr, int pos) {
    if (tl == tr) {
        t[v]++;
    } else {
        int tm = (tl + tr) >> 1;
        if (pos <= tm) {
            add(v + v, tl, tm, pos);
        } else {
            add(v + v + 1, tm + 1, tr, pos);
        }
        t[v] = t[v + v] + t[v + v + 1];
    }
}

int get(int v, int tl, int tr, int l, int r) {
    if (r < tl || l > tr) {
        return 0;
    } else if (tl >= l && tr <= r) {
        return t[v];
    } else {
        int tm = (tl + tr) >> 1;
        return get(v + v, tl, tm, l, r) + get(v + v + 1, tm + 1, tr, l, r);
    }
}

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.precision(20);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int lg = -1, rg = 1000 * 1000 * 1000 + 7;
    ll tot = 1ll * n * (n + 1) / 2;
    tot = tot - (tot / 2 + 1);

    while (rg - lg > 1) {
        int mg = (lg + rg) >> 1;
        for (int i = 0; i < n; i++) {
            if (a[i] >= mg) {
                b[i] = 1;
            } else {
                b[i] = -1;
            }
        }
        memset(t, 0, sizeof(t));
        add(1, 0, n + n, n);
        int cps = 0;
        ll sm = 0;
        for (int i = 0; i < n; i++) {
            cps += b[i];
            sm += get(1, 0, n + n, 0, cps + n);
            add(1, 0, n + n, cps + n);
        }
        if (sm > tot) {
            lg = mg;
        } else {
            rg = mg;
        }
    }
    cout << lg << "\n";
}


Measured memory_bytes: 7296
from sys import stdin, stdout # only need for big input

max_honest = 0
testomonies = []
state = []

def dfs(person):
    global max_honest
    if person >= len(state):
        correctState = True
        for p in range(len(state)):
            if state[p] == 1:
                for t in testomonies[p]:
                    x, y = t
                    if state[x] != y:
                        correctState = False
                        break
        if correctState:
            sum = 0
            for s in state:
                sum += s
            max_honest = max(max_honest, sum)
        return

    state[person] = 0
    dfs(person + 1)

    state[person] = 1 
    dfs(person + 1)
    

def solve():
    global state
    n = int(input())
    for _ in range(n):
        a = int(input())
        t = []
        for _ in range(a):
            x, y = [int(inp) for inp in input().split()]
            t.append((x - 1,y))
        testomonies.append(t)
    # print(testomonies)
    state = [-1] * n
    dfs(0)
    print(max_honest)


def main():
    solve()


if __name__ == "__main__":
    main()

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

int main(){
  string s,t;
  cin >> s >> t;
  int slen = s.size(), tlen = t.size();
  vector<vector<int>> dp(3001, vector<int>(3001));
  for (int i=0; i<=slen; i++){
    for (int j=0; j<=tlen; j++){
      if (i==0||j==0) dp[i][j] = 0;
      else if (s[i-1]==t[j-1]) {
        dp[i][j] = dp[i-1][j-1] + 1;
      }
      else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    }
  }
  string ans = "";
  while (slen>0&&tlen>0){
    if (dp[slen][tlen]==dp[slen-1][tlen]) slen--;
    else if (dp[slen][tlen]==dp[slen][tlen-1]) tlen--;
    else {
      slen--; tlen--;
      ans = s[slen] + ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 35584
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		vi nums;
		nums.reserve(10000);
		reep(i, 1, n)
			nums.push_back((i*i)%n);
		int half = (n-1) / 2;

		sort(nums.begin(), nums.end());
		int size = distance(nums.begin(), unique(nums.begin(), nums.end()));

		vi ans(half+1, 0);
		rep(i, size){
			rep(j, i+1){
				int p = abs(nums[i]-nums[j]);
				if(p>half) p = n - p;
				++ans[p];
			}
		}
		reep(i, 1, half+1)
			printf("%d\n", ans[i]*2);
	}

	return 0;
}

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

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

int main(){
	int n;
	int code;
	int num;
	char key[11][7] = {
			{},
			{'.',',','!','?',' '},
			{'a','b','c'},
			{'d','e','f'},
			{'g','h','i'},
			{'j','k','l'},
			{'m','n','o'},
			{'p','q','r','s'},
			{'t','u','v'},
			{'w','x','y','z'},
	};

	std::cin >> n;
	std::string str;

	rep(i,n){
		code = 0;
		num = 0;
		std::cin >> str;
		rep(j,(int)str.size()){
			if(str[j] != '0'){
				num++;
			}else{
				if(j > 0 && str[j-1] != '0'){
					code = str[j-1]-'0';
					if(code == 1){
						std::cout << key[code][(num-1)%5] << std::flush;
					}else if(code == 7 || code == 9){
						std::cout << key[code][(num-1)%4] << std::flush;
					}else{
						std::cout << key[code][(num-1)%3] << std::flush;
					}
					code = 0;
					num = 0;
				}
			}
		}
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 0
/**        بِسْمِ اللهِ الرَّحْمٰنِ الرَّحِيْمِ (In the name of God, the Most Gracious, the Most Merciful.)              */
/*
      Institution : Hajee Mohammad Danesh Science and Technology University,Dinajpur,Bangladesh.
      Name        : Ashikur Rahman Bhuyain (Asif)
      Email       : asifurr087@gmail.com
*/


#include <bits/stdc++.h>
using namespace std;
#define FasterIO    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define TIME        clock()*1.0/CLOCKS_PER_SEC
#define pi          acos(-1.0)
///Library
#define mem(a,b)    memset(a,b,sizeof(a))
#define all(a)      a.begin(),a.end()
#define Sort(x)     sort(x.begin(),x.end())
#define Reverse(x)  reverse(x.begin(),x.end())
#define SortA(ar,s) sort(ar,ar+s)
#define SortD(ar,s) sort(ar,ar+s,greater<int>())
#define gcd(a,b)    __gcd(a,b)
#define lcm(a,b)    (a*(b/gcd(a,b)))
#define sq(x)       (x)*(x)
#define CEIL(a,b)   ((a/b)+((a%b)!=0))


#define POSL(x,v)          (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v)          (upper_bound(x.begin(),x.end(),v)-x.begin())
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min(b,min(c,d)))
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max(b,max(c,d)))
#define ABS(x)             ((x)<0?-(x):(x))
#define pb                 push_back
#define mod                1000000007
#define nl                 printf("\n")

#define oh cout<<"Problem ta ki?  "<<endl;

///data type
#define ll long long int
#define SIZ 1000005

void solve()
{

   int a,b,c,k;
   cin>>a>>b>>c>>k;
   int op=0;
   while(a>=b){
    b*=2;
    op++;
   }
   while(b>=c){
    c*=2;
    op++;
   }
   if(op<=k){
    cout<<"Yes\n";
   }
   else {
    cout<<"No\n";
   }
    return;
}

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

    return 0;
}


 /*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/



Measured memory_bytes: 3672
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int[][] map = { { 0, 300, 500, 600, 700, 1350, 1650 },
				{ 6, 0, 350, 450, 600, 1150, 1500 },
				{ 13, 7, 0, 250, 400, 1000, 1350 },
				{ 18, 12, 5, 0, 250, 850, 1300 },
				{ 23, 17, 10, 5, 0, 600, 1150 },
				{ 43, 37, 30, 25, 20, 0, 500 }, { 58, 52, 45, 40, 35, 15, 0 } };
		while (true) {
			int n = scanner.nextInt() - 1;
			if (n == -1)
				break;
			int a = scanner.nextInt() * 100 + scanner.nextInt();
			int m = scanner.nextInt() - 1;
			int b = scanner.nextInt() * 100 + scanner.nextInt();
			int ans = map[n][m];
			if (map[m][n] <= 40) {
				if ((1730 <= a && a <= 1930) || (1730 <= b && b <= 1930)) {
					if (map[n][m] % 20 != 0) {
						ans += 50;
					}
					ans /= 2;

				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 20464
N = gets.to_i
f = []
p = []
N.times {|i| f[i] = gets.split.join.to_i(2) }
N.times {|i| p[i] = gets.split.map(&:to_i) }

max_profit = - 10 ** 9

1.upto(2 ** 10 - 1) do |i|
  tmp_profit = 0

  f.each_with_index do |j, index|
    tmp_profit += p[index][(i & j).to_s(2).split('').count {|e| e == '1' }]
  end

  max_profit = tmp_profit if max_profit < tmp_profit
end

puts max_profit

Measured memory_bytes: 2940
import java.util.Scanner;

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

        int minP = 0;
        int maxP = (int) 1E9;
        for (int i = 0; i < n; i++)
            w[i] = sc.nextInt();

        // f(p) が初めてn以上になるpを求める
        int midP = 0;
        while (maxP > minP) {
            midP = (maxP + minP) / 2;
            int m = f(midP);
            
            if (m >= n) 
                maxP = midP;
            else
                minP = midP + 1;
        }
        System.out.println(maxP);
    }
    
    // 最大積載量pのトラックk台に載せられるwの要素の個数
    static int f(int p) {
        int i = 0;
        for (int iK = 0; iK < k; iK++) {
            int pK = 0;
            while (pK + w[i] <= p) {
                pK += w[i];
                i++;
                if (i == n)
                    return n;
            }
        }
        return i;
    }
}


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

struct UnionFind
{
  vector<int> par; //par[i]:iの親の番号

  //最初は全てが根であるとする。-1のときに根である。
  UnionFind(int N) : par(N, -1) {}

  // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
  int root(int x)
  {
    if (par[x] < 0)
      return x;
    else
      return par[x] = root(par[x]);
  }

  //xとyが同じ集合に属するか
  bool issame(int x, int y)
  {
    return root(x) == root(y);
  }

  bool merge(int x, int y)
  {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (par[x] > par[y])
      swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  int size(int x)
  {
    return -par[root(x)];
  }
};

int main() {
  int n, m;
  int ans = 0;
  cin >> n >> m;
  vector<int> H(n);
  rep(i,n) cin >> H[i];
  vector<int> A[n];
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    A[a].emplace_back(b);
    A[b].emplace_back(a);
  }
  rep(i,n){
    bool cond = true;
    if(A[i].size() == 0){
      ans++;
    }else {
      int mx = H[i];
      rep(j,A[i].size()){
        if(mx <= H[A[i][j]]){
          cond = false;
        }
      }
      if(cond)ans++;
    }
  }
  cout << ans << endl;
}

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

int main(){
  string S;
  cin >> S;
  
  int len = S.length();
  int cnt = 0;
  for (int n=0;n<len/2 ;n++){
    if(S.at(n) != S.at(len-1-n))
      cnt++;
  }
  cout << cnt << endl;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    READ(0);
    int n;cin>>n;
    string s,t;cin>>s>>t;
    for(int i=0;i<n;++i){
        cout << s[i] << t[i];
    }

    return 0;
}



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

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

  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<vector<P>> dp(n + 1, vector<P>(2, {0, 0}));
  dp[0][0] = {0, 1000};
  dp[0][1] = {0, 1000};
  for (int i = 0; i < n; i++) {
    // 株を最大化
    ll s = dp[i][1].first;
    ll y = dp[i][1].second;
    s += y / a[i];
    y -= (y / a[i]) * a[i];

    dp[i + 1][0] = max(make_pair(s, y), dp[i][0]);
    // 金を最大化
    s = dp[i][0].first;
    y = dp[i][0].second;
    y += s * a[i];
    s = 0;
    dp[i + 1][1] = max(make_pair(s, y), dp[i][1]);
  }
  cout << dp[n][1].second << endl;
}


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

struct fenwick {
  int N;
  vector<int> bit;

  fenwick(int n = 1e5) {
    N = n + 5;
    bit.assign(N, 0);
  }

  void resize(int n) {
    N = n + 5;
    bit.assign(N, 0);
  }

  void update(int x, int val) {
    while (x < N) {
      bit[x] += val;
      x += x&-x;
    }
  }

  int query(int x) {
    int ret=0;
    while (x > 0) {
      ret += bit[x];
      x -= x&-x;
    }
    return ret;
  }
};

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int n, q;
  string s;

  cin >> n >> s >> q;
  fenwick bit[26];
  for (int i = 0; i < 26; ++i) 
    bit[i].resize(5e5);

  for (int i = 0; i < n; ++i) 
    bit[s[i]-'a'].update(i+1, 1);

  while (q--) {
    int c, l;
    cin >> c >> l;

    if (c == 1) {
     char r;
     cin >> r;
     int d = s[l-1] - 'a';
     bit[d].update(l, -1);
     bit[r-'a'].update(l, 1);
     s[l-1] = r;
    } else {
      int r;
      cin >> r;
      int cnt = 0;
      for (int i = 0; i < 26; ++i)  {
        int cur = bit[i].query(r) - bit[i].query(l-1);
        if (cur > 0)  cnt++;
      }
      cout << cnt << '\n';
    }
  }
}

Measured memory_bytes: 52180
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
typedef pair<int, int> P;
typedef int64_t ll;
const int MAX_N = 10000;
const int INF = 1000000000;


int main() {
	Graph A(3, vector<int>(3));
	rep(i, 3)rep(j, 3) {
		cin >> A.at(i).at(j);
	}
	int N;
	cin >> N;
	vector<int> B(N);
	rep(k, N) {
		cin >> B.at(k);
	}
	rep(k, N) {
		rep(i, 3)rep(j, 3) {
			if (B.at(k) == A.at(i).at(j))A.at(i).at(j) = 0;
		}
	}
	
	rep(i, 3) {
		int cntR = 0;
		int cntC = 0;
		rep(j, 3) {
			if (A.at(i).at(j) == 0)cntR++;
			if (A.at(j).at(i) == 0)cntC++;
		}
		if (cntR == 3|| cntC==3) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	if (A[0][0]==0&& A[1][1] == 0 && A[2][2] == 0)
	{
		cout << "Yes" << endl;
		return 0;
	}
	if (A[0][2] == 0 && A[1][1] == 0 && A[2][0] == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3632
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=(int)1e9;
map<int,map<int,int> > Pic;
int r,c,n;
ll tot[10];
int main()
{
	scanf("%d%d%d",&r,&c,&n);
	tot[0]=(r-2ll)*(c-2ll);
	for(int i=0;i<n;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		for(int p=-1;p<=1;p++)
			for(int q=-1;q<=1;q++)
			{
				int X=x+p,Y=y+q;
				if(X<=1 || Y<=1 || X>r-1 || Y>c-1) continue;
				tot[Pic[X][Y]++]--;
				tot[Pic[X][Y]]++;
			}
	}
	for(int i=0;i<10;i++)
		printf("%lld\n",tot[i]);
	return 0;
}


Measured memory_bytes: 70528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll, ll, ll>>>;

// MOD確認

ll A[5];

int main(){
   ll N;
   cin >> N;
   string S;
   rep(i,N){
      cin >> S;
      if(S == "AC") A[0]++;
      if(S == "WA") A[1]++;
      if(S == "TLE") A[2]++;
      if(S == "RE") A[3]++;
   }
   cout << "AC x " << A[0] << endl;
   cout << "WA x " << A[1] << endl;
   cout << "TLE x " << A[2] << endl;
   cout << "RE x " << A[3] << endl;
}

Measured memory_bytes: 3628
loop do
    h, w = gets.chomp.split.map(&:to_i)
    if h == 0 && w == 0
        break
    end
    puts "#{"#" * w}"
    (h - 2).times do |line|
        line = "#" + "." * (w - 2) + "#"
        puts "#{line}"
    end
    puts "#{"#" * w}"
    puts ""
end

Measured memory_bytes: 8804
n = int(input())
a_list = list(map(int,input().split()))
cntn = 0
cnt2 = 0
cnt4 = 0
for i in a_list:
    if i%4 == 0:
        cnt4 += 1
    elif i%2 == 0:
        cnt2 += 1
    else:
        cntn += 1
        
flag = True

if cnt4+ 1 >= cntn :
    flag = True

else:
    flag = False

if cnt2 >= 1:
    if cnt4 >= cntn :
        flag = True
    else:
        flag = False

if flag:
    print('Yes')

else:
    print('No')

Measured memory_bytes: 15020
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        for (int i = 0; i < N; i++)
        {
            var array = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            //2回で元に戻る
            if (array[0] - array[1] - array[2] < 0 || (array[0] - array[1] - array[2]) % 2 != 0)
            {
                Console.WriteLine("No");
                return;
            }
        }
        Console.WriteLine("Yes");
    }
}


Measured memory_bytes: 15400
N=int(input())
b=list(map(int,input().split()))
a=[0]
a.extend(b)
a[0]=a[1]
#print(a)



F=[0]*(N+1)
#F[1]=a[1]-a[0]


for i in range(2,N+1):
  F[i]= min(F[i-1]+abs(a[i]-a[i-1]), F[i-2]+abs(a[i]-a[i-2]))
  
print (F[N])


Measured memory_bytes: 13980
#include <iostream>
using namespace std;
#define INF 2000000001
#define MAX_V 100
int d[MAX_V][MAX_V];

int main(void){
  int v,e;
  cin>>v>>e;
  for(int i=0;i<v;i++){
      for(int j=0;j<v;j++){
          d[i][j]=INF;
          if(i==j)d[i][j]=0;
      }
  }
  for(int i=0;i<e;i++){
      int s,t,c;
      cin>>s>>t>>c;
      d[s][t]=c;
  }
    for(int k=0;k<v;k++){
        for(int i=0;i<v;i++){
            for(int j=0;j<v;j++){
                if(d[i][k]<INF&&d[k][j]<INF)
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    for(int i=0;i<v;i++){
        if(d[i][i]<0){
            cout<<"NEGATIVE CYCLE"<<endl;
            return 0;
        }
    }
    for(int i=0;i<v;i++){
        for(int j=0;j<v;j++){
            if(d[i][j]==INF)cout<<"INF";
            else cout<<d[i][j];
            
            if(j!=v-1)cout<<" ";
        
        }
        cout<<endl;
    }
}

Measured memory_bytes: 3104
n, a, b = map(int, input().split())

NumberOfRotations = n//(a+b)
surplus = n%(a+b)

ans = 0

if NumberOfRotations == 0:
    if a > n:
        print(surplus)
    else:
        print(a)
else:
    ans = a*NumberOfRotations
    if a > n - ((a+b)*NumberOfRotations):
        print(ans+surplus)
    else:
        print(ans+a)

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<vector>
using namespace std;

#define ll long long

#define debug_message 0
#define debug if (debug_message)

#define sz(x) (int)x.size()

ll i,t,j;
ll k,s,a,b,c,cnt;

int main(){
	scanf("%lld%lld",&k,&s);
	
	for (i=0; i<=k; ++i){
		for (t=0; t<=min(k,s-i); ++t){
			if (s-i-t<=k) ++cnt;
		}
	}
	
	printf("%lld\n",cnt);
	
	return 0;
}
/*

*/

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
using Graph = vector<vector<ll>>;
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);


int main(){
    ll n, l; cin >> n >> l;
    vector<string> v(n);
    rep(i, n) cin >> v[i];
    sort(all(v));
    rep(i, n){
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3592
import math
import statistics
from decimal import Decimal, ROUND_HALF_UP
a = int(input())
b = list(map(int, input().split()))
c = statistics.mean(b)
d = Decimal(c).quantize(Decimal('1'), ROUND_HALF_UP)
ans = 0
for i in range(a):
  ans += (d - b[i])**2
print(ans)


Measured memory_bytes: 11004
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int k = sc.nextInt();

    int[] num = new int[3];
    num[0] = a;
    num[1] = b;
    num[2] = c;
    Arrays.sort(num);

    for (int i = 0; i < k; i++) {
      num[2] = num[2] * 2;
    }

    System.out.println(num[0] + num[1] + num[2]);
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);
// priority_queue<ll, vector<ll>, greater<ll>> pq;


map<ll,ll> prime_factor(ll n){
    map<ll,ll> res;
    for(ll i=2; i*i<=n; i++){
        while(n%i == 0){
            ++res[i];
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}


int main(){
    ll n, p; cin >> n >> p;
    auto mp = prime_factor(p);
    ll ans = 1;
    for(auto p: mp){
        // オーバーフロー対策
        // if(p.second >= n) rep(i, p.second/n) ans *= p.first;
        if(p.second >= n) ans *= pow(p.first, p.second/n);
    }
    cout << ans << endl;
}


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

using namespace std;

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

  int64_t a, b, k;
  cin >> a >> b >> k;
  for (int i = 0; i < k; ++i) {
    if (i % 2 == 0) {
      a &= ~1LLU;
      a /= 2;
      b += a;
    } else {
      b &= ~1LLU;
      b /= 2;
      a += b;
    }
  }
  cout << a << " " << b << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int n,a[100],i,j,temp,Alice,Bob;
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&a[i]);
  }

  for(i = 0;i <= n;i++){
    for(j = 1;j < n-i;j++){
      if(a[j-1] < a[j]){
        temp = a[j-1];
        a[j-1] = a[j];
        a[j] = temp;
      }
    }
  }

  Alice = 0;
  Bob = 0;

  for(i = 0;i < n;i+=2){
    Alice += a[i];
    if(i+1 < n){
      Bob += a[i+1];
    }
  }

  printf("%d\n",Alice-Bob);

  return(0);

}


Measured memory_bytes: 128