akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=1e9+7;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
vector<int> e[MAXN];
int a[MAXN],b[MAXN],ans=0,num=0;
int compare(int x,int y){ return x>y; }
void dfs(int x,int father)
{
	b[x]=a[++num];
	for (auto v:e[x]) if (v!=father) dfs(v,x);
}
int main()
{
    int n=read();
    for (int i=1;i<n;i++) 
    {
    	int u=read(),v=read();
    	e[u].PB(v);
    	e[v].PB(u);
	}
	for (int i=1;i<=n;i++) a[i]=read(),ans+=a[i];
	sort(a+1,a+n+1,compare);
	printf("%d\n",ans-a[1]);
	dfs(1,0);
	for (int i=1;i<=n;i++) printf("%d ",b[i]);
	return 0;
}

Measured memory_bytes: 17792
use std::io::stdin;

fn main() {
    let mo:i64 = 1000000007;
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let n = st.trim().parse::<i32>().unwrap();
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let a:Vec<_> = st.trim().split(" ").map(|x| x.parse::<i32>().unwrap()).collect();
    let mut r:Vec<i32> = [-1,-1,-1].to_vec();
    let mut result:i64 = 1;
    let mut c:i64 = 0;
    let mut num = 0;
    for i in 0..n {
        for j in 0..3 {
            let s = i as usize;
            let t = j as usize;
            if a[s] == r[t]+1 {
                c += 1;
                num = t;
            }
        }
        r[num] += 1;
        result *= c;
        result %= mo;
        c = 0;
        num = 0;
    };
    println!("{}", result);
}

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

using namespace std;
int main()
{

 long long  int  a,b,c,d;
 cin>>a>>b>>c>>d;
 long long int arr[4];
 arr[0]=a*c;
 arr[1]=a*d;
 arr[2]=b*c;
 arr[3]=b*d;
 sort(arr,arr+4);
 cout<<arr[3]<<endl;



}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <complex>

#include <string>
#include <sstream>
using namespace std;

typedef complex<double> P;

namespace std {
  bool operator < (const P &a, const P &b) {
    if(a.real() != b.real()) return a.real() < b.real();
    return a.imag() < b.imag();
  }
}

struct C {
  P p;
  double r;
  C(P p, double r) : p(p), r(r) {}
};

const double eps = 1e-10;
const double pi = acos(-1);


double equals(double a, double b) { return fabs(a-b) < eps; }

double dot(P a, P b) { return a.real()*b.real() + a.imag()*b.imag(); }
double norm(P a) { return dot(a,a); }
double abs(P a) { return sqrt(norm(a)); }

bool isIn(P p, C c) {
  double d = norm(p-c.p);
  double rr = c.r*c.r;
  return equals(d, rr) || d < rr;
}

P getRotateP(P a, double rad) {
  return P(a.real()*cos(rad) - a.imag()*sin(rad),
	   a.real()*sin(rad) + a.imag()*cos(rad));
}

int isIntersect(C a, C b) {
  double d = norm(a.p-b.p);
  double rpr = a.r + b.r;
  double rmr = a.r - b.r;
  rpr *= rpr; rmr *= rmr;
  if(equals(d,rpr)) return 1;//circumscribed
  if(equals(d,rmr)) return 1;//inscribed
  if(d > rpr) return 0;
  if(d < rmr) return 0;
  return 2;
}

vector<P> getCrossP(C a, C b) {
  vector<P> v;
  int num = isIntersect(a,b);
  P base = b.p - a.p;
  if(num == 1) {
    v.push_back(a.p + base*a.r/abs(b.p - a.p));
  } else if(num == 2) {
    double drad = acos((norm(base) + a.r*a.r - b.r*b.r)/(2.0*abs(base)*a.r));
    v.push_back(a.p + getRotateP(base, drad)*a.r/abs(base));
    v.push_back(a.p + getRotateP(base, drad)*a.r/abs(base));
  }
  return v;
}

vector<C> seal;
vector<P> ps;

void makePs() {
  ps.clear();
  for(int i = 0; i < seal.size(); ++i) {
    for(int j = i+1; j < seal.size(); ++j) {
      vector<P> v = getCrossP(seal[i], seal[j]);
      for(int k = 0; k < v.size(); ++k) ps.push_back(v[k]);
    }
  }

  for(int i = 0; i < seal.size(); ++i)
    ps.push_back(seal[i].p);

  sort(ps.begin(), ps.end());
  ps.erase(unique(ps.begin(), ps.end()), ps.end());
}

int count() {
  int res = 1;
  for(int i = 0; i < ps.size(); ++i) {
    int cnt = 0;
    for(int j = 0; j < seal.size(); ++j) {
      if(isIn(ps[i], seal[j])) ++cnt;
    }
    res = max(res, cnt);
  }
  return res;
}

int solve() {
  makePs();
  return count();
}

int main() {
  int n;
  while(cin >> n && n) {
    getchar();
    seal.clear();
    for(int i = 0; i < n; ++i) {
      string line;
      stringstream ss;
      getline(cin, line);
      replace(line.begin(), line.end(), ',', ' ');
      ss << line;
      P p;
      ss >> p.real() >> p.imag();
      seal.push_back(C(p, 1.0));
    }
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<math.h>
int main()
{
    double x1,y1,x2,y2,result,distance;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);

    result=(((x2-x1)*(x2-x1))+((y2-y1)*(y2-y1)));
    distance=sqrt(result);
    printf("%lf\n",distance);

    return 0;



}


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

#ifdef DEBUG
#include "../.inc/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    int K, X;
    cin >> K >> X;

    for (int i=max(X-K+1, -1000000); i<=min(X+K-1, 1000000); ++i) {
        cout << i << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	const ll p = 1e9 + 7;
	//const ll p = 998244353;

	string s;
	cin >> s;
	ll n = s.size();

	vector<bool> v(n);
	for (ll i = 0; i < n; i++) {
		v[i] = (s[i] ^ '0');
	}

	vector<vll> dp(2, vll(n));
	dp[0][0] = 1;
	dp[1][0] = 2;
	for (ll i = 1; i < n; i++) {
		if (s[i] == '1') {
			dp[0][i] = (dp[0][i - 1] * 3 % p + dp[1][i - 1]) % p;
			dp[1][i] = dp[1][i - 1] * 2 % p;
		}
		else {
			dp[0][i] = dp[0][i - 1] * 3 % p;
			dp[1][i] = dp[1][i - 1];
		}
	}
	cout << (dp[0][n - 1] + dp[1][n - 1]) % p << endl;
}


Measured memory_bytes: 2896
#include<bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;

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




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


bool check=1;

int n;
cin>>n;

for(int i=0;i<n;i++)
{
  int x;
  cin>>x;
  if(x%2==0)
  {
    if(x%3!=0&&x%5!=0)
    {
      check=0; break;
    }
  }
}

if(check)cout<<"APPROVED\n";
else cout<<"DENIED\n";

  
}



Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
    int[,] matrix = new int[n,n-1];//行列
    long answer = 0;
    for(int i = 0; i < n; i++)//それぞれの行
    {
    	int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    	for(int j = 0; j < n-1; j++) matrix[i,j] = nums[j]-1;//行の全ての成分
    }
    int[] checkedCount = new int[n];
    bool[] looked = new bool[n];
    int lookedSum = 0;
    bool todayChecked = false;

    while(true)
    {
      todayChecked = false;
      for(int i = 0; i < n; i++)
      {
        looked[i] = false;
      }
      
      for(int i = 0; i < n; i++)
      {
        if(checkedCount[i] == n-1 || looked[i]) continue;
        looked[i] = true;

        int partnerNum = matrix[i,checkedCount[i]];
        if(checkedCount[partnerNum] == n-1) continue;
        
        if(matrix[partnerNum,checkedCount[partnerNum]] == i && !looked[partnerNum])
        {
          looked[partnerNum] = true;
          checkedCount[i]++;
          checkedCount[partnerNum]++;
          todayChecked = true;
          lookedSum++;
          //Console.WriteLine(i+" "+answer+" "+partnerNum);
        }
      }

      if(!todayChecked || answer > 100000) break;
      answer++;
    }

		if(lookedSum == n*(n-1)/2) Console.WriteLine(answer);
    else if(answer == 100001) Console.WriteLine(499500);
    else Console.WriteLine(-1);
	}
}


Measured memory_bytes: 35616
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int elements = sc.nextInt();
        int[] value = new int[elements];
        int[] cost  = new int[elements];
        
        for(int i=0; i<elements; i++){
            value[i] = sc.nextInt();
        }
        for(int i=0; i<elements; i++){
            cost[i] = sc.nextInt();
        }
        int max = 0;
        int profit = 0;
        for(int i=0; i<elements; i++){
            profit = value[i] - cost[i];
            if(profit>0){
                max += profit;
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>

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

int main(){
    ll n;
    ll ans=INF; 
    cin >> n;
    VL a(n,0),sum(n+1,0);
    rep(i,0,n){
        cin >> a[i];
        sum[i+1] = sum[i] + a[i];
    }
    rep(i,0,n){
        ans = min(abs(sum[i+1]-(sum[n]-sum[i+1])),ans);
    }
    cout << ans << endl;
}


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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main(){
  FAST();

  int n, m;
  cin >> n >> m;
  int c = 0, p = 0;
  set<int> qs;
  map<int, int> attempted_but_wrong;
  while(m--){
    int x;
    string str;
    cin >> x >> str;

    if(str == "AC" && qs.find(x) == qs.end()){
        qs.insert(x);
        c++;
        if(attempted_but_wrong.find(x) != attempted_but_wrong.end())
            p += attempted_but_wrong[x];
    }
    else if(str == "WA"){
        attempted_but_wrong[x]++;
    }

  }
  cout << c << " " << p << endl;

  return 0;
}












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

int main(){
  
  int h,n,a,d=0;
  cin >> h >> n;
  
  rep(i,n){
    cin >> a;
    d+=a;
  }
  if(d>=h) cout << "Yes";
  else cout << "No";
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
using namespace std;
using ll = long long;

signed main() {
    IO;
	// freopen("input", "r", stdin);
	// freopen("output", "w", stdout);
    int tests = 1;
    // cin >> tests;
    // for(int test = 1; test <= tests; ++test) {
        
    // }
    int x; cin >> x;
    if(x <= 599) {
    	cout << 8;
    }
    else if(x <= 799) {
    	cout << 7;
    }
    else if(x <= 999) {
    	cout << 6;
    }
    else if(x <= 1199) {
    	cout << 5;
    }
    else if(x <= 1399) {
    	cout << 4;
    }
    else if(x <= 1599) {
    	cout << 3;
    }
    else if(x <= 1799) {
    	cout << 2;
    }
    else if(x <= 1999) {
    	cout << 1;
    }
    return 0;
}

Measured memory_bytes: 3648
n = int(input())
a = []
for _ in range(n):
    s = int(input())
    a.append(s-1)

vis = [False for _ in range(n)]

ans = 0
now = 0
while True:
    if vis[now]:
        ans = -1
        break

    vis[now] = True
    ans += 1
    now = a[now]
    if now == 1:
        break

print(ans)


Measured memory_bytes: 7984
#include <iostream>
#include <map>
using namespace std;
#define int long long
 main() {
 int n;
  cin>>n;
  int a[n];
  map<int,int> freq;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    freq[a[i]]++;
    
  }

  int answer=0;
  for(auto i=freq.begin();i!=freq.end();++i)
  {
    int count = i->second;
      answer+=(count*(count-1))/2;
  }
  for(int i=0;i<n;i++)
  {

      cout<<answer-freq[a[i]]+1<<endl;
  
  }
  
	return 0;
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
                                        #include<iostream>
                                        #include<cstdio>
                                        #include<vector>
                                        #include<queue>
                                        #include<map>
                                        #include<cstring>
                                        #include<string>
                                        #include <math.h>
                                        #include<algorithm>
                                    //    #include <boost/multiprecision/cpp_int.hpp>
                                        #include<functional>
                           //     #define int long long
                                        #define inf  1000000007
                                        #define pa pair<int,int>
                                        #define ll long long
                                        #define pal pair<double,pa>
                                        #define ppa pair<int,int>
                                        #define ppap pair<pa,pa>
                                        #define ssa pair<string,int>
                                        #define  mp make_pair
                                        #define  pb push_back
                                        #define EPS (1e-10)
                                        #define equals(a,b) (fabs((a)-(b))<EPS)
                                  #define VI vector<int>
                                        using namespace std;
                                        
                                  class pas{
                                    	public:
                                    	int x,y;
                                    	pas(int x=0,int y=0):x(x),y(y) {}
                                    	pas operator + (pas p) {return pas(x+p.x,y+p.y);}
                                    	pas operator - (pas p) {return pas(x-p.x,y-p.y);}
                                    	pas operator * (int a) {return pas(x*a,y*a);}
                                    	pas operator / (int a) {return pas(x/a,y/a);}
                                    //	double absv() {return sqrt(norm());}
                                    	int norm() {return x*x+y*y;}
                                    	bool operator < (const pas &p) const{
                                    		return x != p.x ? x<p.x: y<p.y;
                                    	}
                                    	bool operator == (const pas &p) const{
                                    		return x==p.x && y==p.y;
                                    	}
                                    };
int a[60]={0};
           signed main(){
      int n,m;
           	cin>>n>>m;
           	cout<<(n+m+1)/2<<endl;
           	
           }
             

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int lli;
const long long int MaxN=500005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	lli arr[MaxN];
	void solve(){
		lli N,C,K,i,j,res=0,llevo=0,inicio;
		cin>>N>>C>>K;
		for(i=0;i<N;i++){
			cin>>arr[i];
		}
		sort(arr,arr+N);
		inicio=arr[0];
		for(i=0;i<N;i++){
			if(llevo==C){
				res+=1;
				llevo=1;
				inicio=arr[i];
			}
			else {
				if(inicio+K>=arr[i]){
					llevo+=1;
				}
				else {
					res+=1;
					llevo=1;
					inicio=arr[i];
				}
			}
			//cout<<llevo<<" "<<res<<" "<<inicio+K<<"\n";
		}
		res+=1;
		cout<<res;
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int a,b,x;
    cin >> a >> b >> x;
    bool hantei=true;

    if(a+b<x || a>x) hantei =false;
    if(hantei) cout << "YES" << endl;
    else        cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP1(i,n) for(int i = 1; i < n+1 ;i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    ll a,b,c;
    cin >> a>>b>>c;
    if (c-a-b<0) cout << "No" << endl;
    else {
    if((c-a-b)*(c-a-b)>4*a*b)cout << "Yes" << endl;
    else cout <<"No" << endl;
    }
}

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

using namespace std;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline int stoi(const string& s)
{
  int x = 0;
  for (int i = 0; i < s.size(); i++){
    x *= 10;
    x += s[i] - '0';
  }
  return x;
}

map<int, int> ans;
struct Solver {
  Solver(){};
  void build(){
    set<int> vis;
    queue<string> Q;
    ans[1234567] = 0;
    Q.push("01234567");

    int turn = 0;
    while (!Q.empty()){
      queue<string> nQ;
      while (!Q.empty()){
        string state = Q.front();
        Q.pop();

        for (int i = 0; i < 4; i++){
          string next_state;
          if (!slide(state, i, next_state)) continue;
          int visv = stoi(next_state);
          if (ans.find(visv) != ans.end()) continue;
          ans[visv] = turn + 1;
          nQ.push(next_state);
        }
      }
      swap(Q, nQ);
      turn++;
    }
  }
  bool slide(const string& src, int dir, string& dst){
    const int width = 4;
    const int up = 0, down = 1, right = 2, left = 3;
    const int zero_pos = src.find('0');
    dst = src;
    if (dir == up){
      if (zero_pos < width) return false;
      swap(dst[zero_pos], dst[zero_pos - width]);
    }
    else if (dir == down){
      if (zero_pos >= width) return false;
      swap(dst[zero_pos], dst[zero_pos + width]);
    }
    else if (dir == right){
      if (zero_pos == width - 1 || zero_pos == 2 * width - 1) return false;
      swap(dst[zero_pos], dst[zero_pos + 1]);
    }
    else {
      if (zero_pos == 0 || zero_pos == width) return false;
      swap(dst[zero_pos], dst[zero_pos - 1]);
    }
    return true;
  }
};

int main()
{
  Solver solver;
  solver.build();
  string s;
  while (getline(cin, s)){
    s.erase(remove(s.begin(), s.end(), ' '), s.end());
    printf("%d\n", ans[stoi(s)]);
  }

  return 0;
}

Measured memory_bytes: 2200
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int n;
  cin >> n;
  vector<int> vec(n + 1);
  vec[0] = 0;
  vector<int> a(100001, 0);
  long long sum = 0;
  for (int i = 1; i <= n; i++)
  {
    cin >> vec[i];
    a[vec[i]]++;
    sum += vec[i];
  }
  
  
  int q;
  cin >> q;
  for (int i = 1; i <= q;i++){
    vector<int> totori(2);
    cin >> totori[0] >> totori[1];
    sum = sum + a[totori[0]] * (totori[1] - totori[0]);
    a[totori[1]] += a[totori[0]];
    a[totori[0]] = 0;
    cout << sum << endl;

  }
}

Measured memory_bytes: 4000
n = int(input())
a = [0 for i in range(26)]
b = [0 for i in range(26)]
S = input()
for i in S:
    a[ord(i) - 97] += 1
for i in range(n-1):
    T = input()
    for j in T:
        b[ord(j) - 97] += 1
    for j in range(26):
        a[j] = min(a[j],b[j])
    b = [0 for i in range(26)]
U = ""
for i in range(26):
    if a[i] != 0:
        U += chr(97+i)*a[i]
print(U)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int dp[3400][3400];
int main() 
{
    string s,t;
    getline(cin,s);
    getline(cin,t);

    if(s.size() < t.size())
    	s.swap(t);


    for (int i = 0; i < s.size()+1; ++i)
    {
    	for (int j = 0; j < t.size()+1; ++j)
    	{
    		if(i == 0 || j == 0)
    		{
    			dp[i][j] = 0;
    		}
    		else
    		{
    			if(s[i-1] == t[j-1])
    				dp[i][j] = 1 + dp[i-1][j-1];
    			else
    				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    		}
    	}
    }

    int a = s.size();
    int b = t.size();
    string ans;
    while(1)
    {
    	if(a == 0 || b == 0)
    		break;
    	if(s[a-1] == t[b-1])
    	{
    		ans = ans +  s[a-1];
    		a = a-1;
    		b = b-1;
    	}
    	else
    	{
    		if(dp[a-1][b] == dp[a][b])
    			a = a-1;
    		else
    			b = b-1;
    	}
    }

    reverse(ans.begin(),ans.end());
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 41216
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval<newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int N=in();
  vi p(N);
  rep(i,N) p[i] = in();
  int m=0; int t=0;
  for(int q : p){
    if(m<q) m=q;
    t+=q;
  }
  cout << t - m/2 << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
a_sort = sorted(a)
#print(N, a, a_sort)
x = 0
p = 'YES'
for i in range(N):
  if a[i] != a_sort[i]:
    x += 1
    if x > 2:
      p = 'NO'
      break

print(p)
    

Measured memory_bytes: 2940
N, M = map(int, input().split())
A = [int(i) for i in input().split()]

sum_A = [0] * (N+1)

d = dict()
d[0] = 1
for i in range(N):
    sum_A[i+1] = sum_A[i] + A[i]
    sum_A[i+1] = sum_A[i+1] % M
    if sum_A[i+1] in d:
        d[sum_A[i+1]] += 1
    else:
        d[sum_A[i+1]] = 1

answer = 0


for i in d.keys():
    answer += d[i] * (d[i]-1) // 2


print(answer)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
    #ifdef DGC
        //freopen("a.txt", "r", stdin);
        //freopen("b.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0), cin.tie(0);

    string s;
    cin >> s;
    for (int i = 1; i < s.length(); ++i)
    	if (s[i-1] == s[i])
    	{
    		cout << "Bad\n";
    		return 0;
    	}

    cout << "Good\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n,p[20],s[1<<20],s1[1<<10];

int main(){
	while(cin>>n){
		if(!n)return 0;
		int n2=n/2;
		fill(s1,s1+(1<<n2),0);
		int sum=0,dif=1e+9;
		for(int i=0;i<n;i++){cin>>p[i];sum+=p[i];}
		if(n<11){
			fill(s,s+(1<<n),0);
			for(int i=0;i<1<<n;i++){
				int sss=0;
				for(int j=0;j<n;j++)if((i/(1<<j))%2)sss+=p[j];
				dif=min(dif,abs(sss*2-sum));
			}
			cout<<dif<<endl;
		}
		else{
		for(int i=0;i<1<<n2;i++){
			for(int j=0;j<n2;j++)if(i>>j&1)s1[i]+=p[j];
		}
		sort(s1,s1+(1<<n2));
		int ans=1e+9;
		for(int i=0;i<1<<(n-n2);i++){
			int ss=0;
			for(int j=0;j<n-n2;j++)if(i>>j&1)ss+=p[j+n2];
			ans=min(ans,min(abs((*lower_bound(s1,s1+(1<<n2),(sum)/2-ss)+ss)*2-sum),abs((*(lower_bound(s1,s1+(1<<n2),(sum)/2-ss)-1)+ss)*2-sum)));
			ans=min(ans,min(abs((*(lower_bound(s1,s1+(1<<n2),(sum)/2-ss)+1)+ss)*2-sum),abs((*(lower_bound(s1,s1+(1<<n2),(sum)/2-ss)-2)+ss)*2-sum)));
		}
		/*for(int i=0;i<1<<n;i++){
			for(int j=0;j<n;j++)if((i/(1<<j))%2)s[i]+=p[j];
			dif=min(dif,abs(s[i]*2-sum));
		}*/
		cout<<ans<<endl;
		}
		//sort(s,s+(1<<n));
		//for(int i=0;i<1<<n;i++)s[i]=s[i]*2-sum;
		/*int lb=0,ub=1<<n-1,prv=0;
		while(ub-lb>1){
			int mid=(lb+ub)/2;
			if(s[mid]==prv)break;
			if(s[mid]>=0)ub=mid;
			else lb=mid;
			prv=s[mid];
		}
		cout<<abs(s[ub])<<endl;*/
		//cout<<min(*lower_bound(s,s+(1<<n),0),abs(*(lower_bound(s,s+(1<<n),0)-1)))<<endl;
	}
}

Measured memory_bytes: 0
// Bismillahir Rahmanir Rahim
// Mr_Emrul

#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;

typedef long long int ll;
typedef pair <ll, ll> pll;
typedef pair <ll, pll> plp;
typedef pair <int, int> pii;
typedef pair <int, pii> pip;
const ll MX = 1000005;

#define LCM(a,b)        (a / __gcd(a,b) ) *-b
#define gcd(a,b)        __gcd(a,b)
#define all(x)          (x).begin(), (x).end()
#define mem(a, n)       memset(a,n,sizeof(a))
#define for1(i, n)      for(i=1; i<=n; i++)
#define for0(i, n)      for(i=0; i<n; i++)
#define rof0(i, n)      for(i=n-1; i>=0; i--)
#define rof1(i, n)      for(i=n; i>=1; i--)
#define forab(i, a, b)  for(i=a; i<=b; i++)
#define rofab(i, a, b)  for(i=b; i>=a; i--)
#define pb              push_back
#define pbb             pop_back
#define YES             cout << "YES" << endl
#define NO              cout << "NO" << endl
#define sin(s)          getline(cin, s)
#define scf(a)          cin >> a
#define scf2(a, b)      cin >> a >> b
#define scf3(a, b, c)   cin >> a >> b >> c
#define scf4(a,b,c,d)   cin >> a >> b >> c >> d
#define pnf(a)          cout << (a) << endl
#define pnf2(a, b)      cout << (a) << " " << (b) << endl
#define pnf3(a, b, c)   cout << (a) << " " << (b) << " " << (c) << endl
#define pnfa(a)         cout << (a) << " "
#define pf(a)           cout << (a)
#define sp              cout << " "
#define nl              cout << endl
#define sz(n)           n.size()
#define clear(v)        v.clear()
#define bug(n)          cout << ">> " << n << " <<" << endl
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in              freopen("in.txt", "r", stdin)
#define out             freopen("out.txt", "w", stdout)
#define fast            {ios_base::sync_with_stdio(false); cin.tie(0);}
#define F               first
#define S               second
#define mpp             make_pair

int main()
{
    ll n, m, t, i, j, cnt=0;
    string a, b, c;
    scf3(a, b, c);
    if(a[a.size()-1] == b[0] && b[sz(b)-1] == c[0])
        YES;
    else
        NO;
}


Measured memory_bytes: 764
import sys

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def nC2(n):
    return n * (n-1) // 2

n,k = get_nums_l()
aaa = get_nums_l()

negatives = []
zeros = 0
positives = []

for a in aaa:
    if a == 0:
        zeros += 1
    elif a > 0:
        positives.append(a)
    else:
        negatives.append(a)

# 絶対値小さい順
positives.sort()
negatives.sort(reverse=True)

len_positives = len(positives)
len_negatives = len(negatives)

# 要素の個数から、ペアの積を負,0,正に分けた場合の個数を数える
p_zeros = zeros*(len_negatives+len_positives) + nC2(zeros)
p_positives = nC2(len_positives) + nC2(len_negatives)
p_negatives = len_positives * len_negatives

if p_negatives < k <= (p_negatives+p_zeros):
    # ゼロの場合
    print(0)
    exit()

if k <= p_negatives:
    # 負の場合
    nokori = k

    left = -1 * ((10**9)**2 + 1)
    right = -1

    # 積がcenter未満になるペアがnokori個未満になる最大のcenterを探す
    while left < right:
        center = (left+right+1) // 2

        left2 = len_positives-1
        right2 = len_negatives-1

        count = 0

        # 正の数と負の数を掛けてcenter未満になる個数を数える
        while right2 > 0 and positives[left2] * negatives[right2] < center:
            right2 -= 1

        while 0<=left2<len_positives and 0<=right2<len_negatives:
            if positives[left2] * negatives[right2] < center:
                count += len_negatives - right2
                left2 -= 1
            else:
                right2 += 1

        if count < nokori:
            left = center
        else:
            right = center - 1
    print(left)
    exit()

# 正の場合
nokori = k - p_negatives - p_zeros

left = 1
right = (10**9)**2 + 1

# 積がcenter未満になるペアがnokori個未満になる最大のcenterを探す
while left < right:
    center = (left+right+1) // 2

    left2 = 0
    right2 = len_positives-1

    count = 0

    # 正の数同士で掛けてcenter未満になる個数を数える
    while left2 < right2:
        if positives[left2] * positives[right2] < center:
            count += right2 - left2
            left2 += 1
        else:
            right2 -= 1

    left2 = 0
    right2 = len_negatives-1

    # 負の数同士で掛けてcenter未満になる個数を数える
    while left2 < right2:
        if negatives[left2] * negatives[right2] < center:
            count += right2 - left2
            left2 += 1
        else:
            right2 -= 1

    if count < nokori:
        left = center
    else:
        right = center-1
print(left)

Measured memory_bytes: 95664
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int a, p; cin >> a >> p;
  cout << (3 * a + p) / 2 << '\n';
}

Measured memory_bytes: 256
#include <iostream>
using namespace std; 
int main() 
{
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  long long tot=a*c;
  if(a>b)
  {
  tot=tot-(a-b)*(c-d);
  }
  printf("%lld\n",tot);
}

Measured memory_bytes: 256
#include <stdio.h>
#include"stdlib.h"
int main(void){
    int N,M;
    scanf("%d %d",&N,&M);
    int a[N],b[N];
    int ans[N];
    for(int i=0;i<N;i++)scanf("%d %d",&a[i],&b[i]);
    int c[M],d[M];
    for(int i=0;i<M;i++)scanf("%d %d",&c[i],&d[i]);
    for(int i=0;i<N;i++){
        int minkyori=500000000;
        for(int j=0;j<M;j++){
            if(abs(a[i]-c[j])+abs(b[i]-d[j])<minkyori){ans[i]=j;minkyori=abs(a[i]-c[j])+abs(b[i]-d[j]);}
        }
    }
    for(int i=0;i<N;i++)printf("%d\n",ans[i]+1);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int A,B;
	scanf("%d %d",&A,&B);

	printf("%d\n",max(A*B,max(A+B,A-B)));

	return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define SYOU(x) setprecision(x)
#define abs(x,y) max(x,y)-min(x,y)
using namespace std;
long long i[1000000];
long long u[11111110];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=2,e=0,f=0;
  string s;
  cin >>a;
  b=a;
  for(int n=2;n<b;n++){
    a=a*n;
    a=a%inf;
  }
  a=a%inf;
  cout <<a<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
using namespace std;

struct node {
	long prev;
	long next;
	int val;
};

queue<int> merge(queue<int> q1, queue<int> q2){
	queue<int> ma;
	while(q1.size() || q2.size()){
		if(!q2.size() || (q1.size() && q1.front() < q2.front())){
			ma.push(q1.front());
			q1.pop();
		}else{
			ma.push(q2.front());
			q2.pop();
		}
	}
	return ma;
}
queue<int> sort(queue<int> q){
	queue<int> nq;
	while(q.size() - nq.size() > 1){
		nq.push(q.front());
		q.pop();
	}
	if(!nq.size()) return q;
	return merge(sort(nq), sort(q));
}

int main() {
	int n;
	cin >> n;
	
	int wholeMin = INT_MAX;
	int v[n];
	queue<int> q;
	for(int i = 0; i < n; i++){
		cin >> v[i];
		q.push(v[i]);
		wholeMin = min(wholeMin, v[i]);
	}
	
	queue<node> nodes;
	q = sort(q);
	while(q.size()){
		for(int i = 0; i < n; i++){
			if(q.front() == v[i]){
				node no;
				no.prev = i;
				no.next = n - q.size();
				no.val = v[i];
				nodes.push(no);
				break;
			}
		}
		q.pop();
	}
	
	vector<vector<node> > groups;
	vector<node> sub;
	while(nodes.size()){
		sub.clear();
		node topNode = nodes.front();
		nodes.pop();
		sub.push_back(topNode);
		
		node curNode = topNode;
		while(curNode.prev != curNode.next){
			if(curNode.next == nodes.front().prev){
				curNode = nodes.front();
				nodes.pop();
				sub.push_back(curNode);
				if(curNode.next == topNode.prev) break;
			}else{
				nodes.push(nodes.front());
				nodes.pop();
			}
		}
		
		groups.push_back(sub);
	}
	
	long cost = 0;
	for(int i = 0; i < groups.size(); i++){
		if(groups[i].size() == 1) continue;
		else if(groups[i].size() == 2) cost += groups[i][0].val + groups[i][1].val;
		else{
			int min = INT_MAX;
			long total = 0;
			for(int k = 0; k < groups[i].size(); k++){
				min = min < groups[i][k].val ? min : groups[i][k].val;
				total += groups[i][k].val;
			}
			
			total -= min;
			long costInternal = total + min * (groups[i].size() - 1);
			long costExternal = total + wholeMin * (groups[i].size() - 1) + (min + wholeMin) * 2;
			cost += costInternal > costExternal ? costExternal : costInternal;
		}
	}
	cout << cost << endl;
	
	return 0;
}

Measured memory_bytes: 1328
W,H,x,y,r = map(int,input().split())
x1 = x + r
x2 = x - r
y1 = y + r
y2 = y - r

if x1 <= W and y1 <= H and 0 <= x2 and 0 <= y2:
    print("Yes")
else:
    print("No")


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

ll solve1(ll N, ll a, ll b) {
	ll ans = N / a;
	ans *= b;
	return ans + N % a;
}

ll solve2(ll N, ll a, ll b, ll c, ll d) {
	//a→b,c→d
	ll e = N / a;
	ll f, cnt = 0;
	while (e >= 0) {
		f = N - a * e;
		cnt = max(solve1(f, c, d) + b * e, cnt);
		e--;
	}
	return cnt;
}

ll solve3(ll N, ll a, ll b, ll c, ll d, ll e, ll f) {
	ll g = N / a;
	ll rem, r, cnt = 0;
	while (g >= 0) {
		rem = N - g * a;
		r = solve2(rem, c, d, e, f);
		cnt = max(cnt, r + g * b);
		g--;
	}
	return cnt;
}

int main() {
	ll N, a, b, c, d, e, f;
	cin >> N;
	cin >> a >> c >> e;
	cin >> b >> d >> f;
	if (a < b) {
		if (c < d) {
			if (e < f) {
				N = solve3(N, a, b, c, d, e, f);
			}
			else {
				N = solve2(N, a, b, c, d);
				N = solve1(N, f, e);
			}
		}
		else {
			if (e < f) {
				N = solve2(N, a, b, e, f);
				N = solve1(N, d, c);
			}
			else {
				N = solve1(N, a, b);
				N = solve2(N, d, c, f, e);
			}
		}
	}
	else {
		if (c < d) {
			if (e < f) {
				N = solve2(N, c, d, e, f);
				N = solve1(N, b, a);
			}
			else {
				N = solve1(N, c, d);
				N = solve2(N, b, a, f, e);
			}
		}
		else {
			if (e < f) {
				N = solve1(N, e, f);
				N = solve2(N, b, a, d, c);
			}
			else {
				N = solve3(N, f, e, d, c, b, a);
			}
		}
	}
	cout << N << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		String buff= "";
		int count=0;

		int[][] array = new int[h][w];

		for(int i=0;i<h;i++) {
			buff=sc.next();
			for(int j=0;j<w;j++) {
				if(buff.substring(j,j+1).equals("#")) {
					array[i][j]=1;
				}else {
					array[i][j]=0;
				}
			}
		}
		for(int i=0;i<h;i++) {
			for(int j=0;j<w;j++) {
				count+=array[i][j];
			}
			if(count==0) {
				for(int k=i;k<h-1;k++) {
					for(int l=0;l<w;l++) {
						array[k][l]=array[k+1][l];
					}
				}
				h--;
				i--;
			}
			count=0;
		}
		for(int i=0;i<w;i++) {
			for(int j=0;j<h;j++) {
				count+=array[j][i];
			}
			if(count==0) {
				for(int k=i;k<w-1;k++) {
					for(int l=0;l<h;l++) {
						array[l][k]=array[l][k+1];
					}
				}
				w--;
				i--;
			}
			count=0;
		}

		for(int i=0;i<h;i++) {
			for(int j=0;j<w;j++) {
				if(array[i][j]==1) {
					System.out.print("#");
				}else {
					System.out.print(".");
				}
			}
			System.out.println();
		}
	}
}




Measured memory_bytes: 25224
s='abcdefghijklmnopqrstuvwxyz'
n=int(input())
res=[]
n=n-1
while n>=0:
    res.append(n%26)
    n=n//26
    n=n-1
    #print(n,res[-1])
ans=''
for j in range(len(res)-1,-1,-1):
    ans=ans+s[res[j]]
print(ans)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
//long long int countt[200003];
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set, multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds; //necessary for the GNU based Policy based data structures.
typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define int long long
#define endl "\n"

signed main()
{
    FAST;
    
    int i=0,j=0,k=0,n=0,m=0,count=0,temp=0;
    int temp1=0,temp2=0,temp3=0,x=0,l=0,y=0,sum=0;
    int left=0,up=0,down=0,start=0,end=0,r=0,q=0,total=0;
    int maxx=0,minn=0,curr=0,ans=0,places=0,zeroes=0,low=0,high=0;
    int prev=0,mid=0,z=0,d=0,val=0,pos=0,shift=0,h=0,right=0,var=0;
    
    cin>>x>>y;
    cout<<x*y<<endl;
    
    
    
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, temp;
    bool flag = true;
    cin >> n;
    unordered_set<int> s;
    for (int i = 0; i < n; ++i) {
        cin >> temp;
        if (s.count(temp) == 0)
            s.insert(temp);
        else {
            flag = false;
            break;
        }
    }
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 8060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int a,b;
    cin>>a>>b;
    a--,b--;
    char ans[100][100];
    rep(j,100)ans[0][j] = '#';
    for(int i=1;i<99;i++){
        rep(j,100){
            if(j%2==0)ans[i][j] = '.';
            else ans[i][j] = '#';
        }
    }
    rep(j,100)ans[99][j] = '.';
    
    pii bl = pii(2,50);
    pii wh = pii(97,1);

    rep(i,a){
        assert(ans[bl.first][bl.second]=='.');
        ans[bl.first][bl.second] = '#';
        if(bl.first+2>=99){
            bl.first = 2;
            bl.second +=2;
        }else{
            bl.first+=2;
        }
    }

    rep(i,b){
        assert(ans[wh.first][wh.second]=='#');
        ans[wh.first][wh.second] = '.';
        if(wh.first-2<=0){
            wh.first = 97;
            wh.second +=2;
        }else{
            wh.first-=2;
        }
    }
    
    cout<<100<<" "<<100<<endl;
    rep(i,100){
        rep(j,100){
            cout<<ans[i][j];
        }
        cout<<endl;
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;

ll A,V,B,W,T;

int main(){
    cin>>A>>V>>B>>W>>T;

    if(V*T>=W*T+abs(A-B)){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 3636
N = gets.chomp.to_i
h = gets.chomp.split.map(&:to_i)
dp = [0] * (N + 1)

(1..N).each do |i|
  if i == 1
    dp[i] = 0
  elsif i == 2
    dp[i] = dp[0] + (h[1].to_i - h[0].to_i).abs
  else
    dp[i] = [ dp[i-1] + (h[i-1].to_i - h[i-2].to_i).abs, dp[i-2] + (h[i-1].to_i - h[i-3].to_i).abs ].min
  end
end

puts dp[N]

Measured memory_bytes: 11788
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 
#define mp make_pair
#define pb push_back
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)  ((a)*((b)/gcd(a,b)))
#define pi 3.14159265358979323846
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;
	
//	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//	#endif
	
	string s,t;
	cin>>s>>t;
	int l1=s.length();
	int l2=t.length();
	vector<int> v;
	int mini=INT_MAX;
	int c=0;
	for(int i=0;i<l1-l2+1;i++)
	{
		c=0;
		for(int j=0;j<l2;j++)
		{
			if(t[j]!=s[j+i])
			{
				c++;
			}
		}
		
		if(c<mini)
		{
			mini=c;
		}
	}
	//sort(v.begin(),v.end());
	cout<<mini<<endl;
	
	return 0;
}

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

typedef long long ll;
using namespace std;

int main() {
 	ll x;
 	cin>>x;
 	ll num = x/500;
 	ll rest = x%500;
 	ll ans = rest/5;
 	cout << (num*1000*1ll) + (ans*5*1ll);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int K; cin >> K;
    int oddCount = 0;
    int evenCount = 0;

    for (int i=0;i<K;i++){
        if (i%2 == 0) {
            evenCount++;
        } else {
            oddCount++;
        }
    }

    cout << evenCount * oddCount << endl;
	return 0;
}

Measured memory_bytes: 256
n, m, x, y = map(int, input().split())
x_city=list(map(int, input().split()))
y_city=list(map(int, input().split()))
x_city.append(x)
y_city.append(y)
x_city.sort()
y_city.sort()
if x_city[-1]<y_city[0]:
    print('No War')
else:
    print('War')

Measured memory_bytes: 3064
// In the Name of Allah. Ya Ali!
#include<bits/stdc++.h>
typedef long long ll;
const ll MAX_N = 3000+5;
const ll MOD = 1e9+7;
using namespace std;

double dp1[MAX_N];
double dp2[MAX_N];
double a[MAX_N];
int n;

int main()
{
    cin >> n;
    for(int i = 1;i<=n;++i)
        cin >> a[i];
    dp1[0] = 1;
    for(int i = 1;i<=n;++i)
    {
        for(int j = 0;j<=i;++j)
        {
            dp2[j] = dp1[j]*(1-a[i]);
            if (j)
                dp2[j] += dp1[j-1]*a[i];
        }
        memcpy(dp1 , dp2 , sizeof dp1);
    }
    cout << fixed << setprecision(12);
    double ans = 0;
    for(int i = n/2;i<=n;++i)
    {
        if (i>n-i)
            ans += dp1[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
A, B, N = map(int, input().split())
answer = 0
if B > N:
    mae = (A*N)//B
    usiro = A*(N//B)
    l = mae-usiro
else:
    i = (B-1)
    mae = (A*i)//B
    usiro = A*(i//B)
    l = mae-usiro
print(l)

Measured memory_bytes: 9188
#include <stdio.h>
#include <iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    char t[100];
	int a=0,b=0,i=0;
    while(i!=n){
       cin>>t[i];
       if(t[i]=='(') b++;
       else{
           if(b) b--;
           else a++;
        }
        i++;
    }
    for(i=0;i<a;i++) cout<<"(";
    for(i=0;i<n;i++) cout<<t[i];
    for(i=0;i<b;i++) cout<<")";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

int main(){
    int n;
    cin >> n;
    int ans = 0;
    REP(i, n){
        ll tmp;
        cin >> tmp;
        while(tmp % 2 == 0){
            tmp /= 2;
            ans++;
        }
    }
    cout << ans << endl;
}


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

using C = complex<double>;
double pi = acos(-1.0);

void FFT(vector<C>& A, bool inv) {
    int N = A.size();
    for (int i = 0, j = 0; j < N; j++) {
        if (i < j) swap(A[i], A[j]);
        for (int k = N >> 1; k > (i ^= k); k >>= 1);
    }
    for (int i = 1; i < N; i <<= 1) {
        C q = C(cos(pi / i), sin(pi / i) * (inv ? 1.0 : -1.0));
        C qj = C(1.0, 0.0);
        rep(j, i){
            for (int k = j; k < N; k += i * 2) {
                C l = A[k], r = A[k + i] * qj;
                A[k] = (l + r);
                A[k + i] = (l - r);
            }
            qj = qj * q;
        }
    }
    if (inv) rep(i, N) A[i] /= N;
}

// trinitrotoluene EXPLODING!!
vector<C> CONV(const vector<C>& A, const vector<C>& B) {
    int Z = 1; while (Z < A.size() + B.size()) Z <<= 1;
    vector<C> ans(Z), Ax(Z), Bx(Z);
    rep(i, Z) Ax[i] = Bx[i] = 0;
    rep(i, A.size()) Ax[i] = A[i];
    rep(i, B.size()) Bx[i] = B[i];
    FFT(Ax, false);
    FFT(Bx, false);
    rep(i, Z) ans[i] = Ax[i] * Bx[i];
    FFT(ans, true);
    return move(ans);
}

const ULL M = 200003;
int N;
ULL I[M];
vector<C> A;
vector<C> V;

int main() {
    scanf("%d", &N);
    for (int i = 0, j = 1; i < M - 1; i++, j = j * 2 % M) I[j] = i;
    A.resize(M - 1);

    ULL sq = 0;
    rep(i, N) {
        int a; scanf("%d", &a);
        if (a) A[I[a]] += C(1.0, 0.0);
        sq += (ULL)a * a % M;
    }
    V = CONV(A, A);

    ULL ans = 0;
    for (int i = 0, j = 1; i < V.size(); i++, j = j * 2 % M)
        ans += (ULL)(V[i].real() + 0.5) * j;
    ans = (ans - sq) / 2;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 32580