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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

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

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    double sum = 0;
    for (int i = 0; i < n; ++i) {
      double x;
      string s;
      cin >> x >> s;
      if (s == "JPY") {
        sum += x;
      } else {
        sum += x * 380000.0;
      }
    }
    printf("%.10lf\n", sum);
  }
  
  return 0;
}


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

struct Node{
    long long int sum;
    int x, y, z;

    bool operator < (const Node &node) const{
        return sum < node.sum;
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x, y, z, k;
    cin >> x >> y >> z >> k;

    long long int a[2000], b[2000], c[2000];
    for (int i = 0; i < x; i++)
        cin >> a[i];

    for (int i = 0; i < y; i++)
        cin >> b[i];

    for (int i = 0; i < z; i++)
        cin >> c[i];

    sort(a, a + x);
    sort(b, b + y);
    sort(c, c + z);
    
    priority_queue<Node> pq;
    set<pair<int, pair<int,int>> > s;
    pq.push({a[x - 1] + b[y - 1] + c[z - 1], x - 1, y - 1, z - 1});
    s.insert({x - 1, {y - 1, z - 1}});
    
    for (int i = 0; i < k; i++){
        Node n = pq.top(); pq.pop();
        cout << n.sum << '\n';

        if (n.x > 0){
            if (s.find({n.x - 1, {n.y, n.z}}) == s.end()){
                pq.push({a[n.x - 1] + b[n.y] + c[n.z], n.x - 1, n.y, n.z});
                s.insert({n.x - 1, {n.y, n.z}});
            }
        }
        if (n.y > 0){
            if (s.find({n.x, {n.y - 1, n.z}}) == s.end()){
                pq.push({a[n.x] + b[n.y - 1] + c[n.z], n.x, n.y - 1, n.z});
                s.insert({n.x, {n.y - 1, n.z}});
            }
        }
        if (n.z > 0){
            if (s.find({n.x, {n.y, n.z - 1}}) == s.end()){
                pq.push({a[n.x] + b[n.y] + c[n.z - 1], n.x, n.y, n.z - 1});
                s.insert({n.x, {n.y, n.z - 1}});
            }
        }
    }

    return 0;
}


Measured memory_bytes: 896
A, B, C = map(int, input().split())

def gcd(m, n):
    if m < n:
        return gcd(n, m)
    if n == 0:
        return m
    return gcd(n, m % n)

if C %  gcd(A, B) == (A % B) % gcd(A, B):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int N; cin >> N;
    vector<int> a(N); rep(i, N) cin >> a[i];
    int maxv = -INF, maxv_i, minv = INF, minv_i;
    rep(i, N) {
        if(maxv < a[i]) {
            maxv = a[i];
            maxv_i = i + 1;
        }
        if(minv > a[i]) {
            minv = a[i];
            minv_i = i + 1;
        }
    }
    if((maxv >= 0 && minv >= 0) || (maxv <= 0 && minv <= 0)) {
        cout << N - 1 << endl;
        if(0 <= minv) {
            rep(i, N - 1) {
                cout << i + 1 << ' ' << i + 2 << endl;
            }
        }else {
            rnr(i, N - 1, 1) {
                cout << i + 1 << ' ' << i << endl;
            }
        }
    } else {
        cout << 2 * N - 1 << endl;
        if(abs(maxv) >= abs(minv)) {
            rep(i, N) {
                cout << maxv_i << ' ' << i + 1 << endl;
            }
            rep(i, N - 1) {
                cout << i + 1 << ' ' << i + 2 << endl;
            }
        }else {
            rep(i, N) {
                cout << minv_i << ' ' << i + 1 << endl;
            }
            rnr(i, N - 1, 1) {
                cout << i + 1 << ' ' << i << endl;
            }
        }
    }
}


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

signed main() {
  string s; cin >> s;
  int day = s.length();

  int cnt = 0;
  for(int i = 0; i < day; i++) {
    if(s[i] == 'o') cnt++;
  }
  bool flag = false;
  if(15 - day + cnt >= 8) flag = true;

  cout << (flag ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 998244353
inf = float('INF')

#A
def A():
    n = II()
    n -= 1
    print(n // 2)
    return

#B
def combination_mod(n, k, mod=mod):
    """ power_funcを用いて(nCk) mod p を求める """ 
    """ nCk = n!/((n-k)!k!)を使用 """

    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    a = factorial(n) % mod
    b = factorial(k) % mod
    c = factorial(n - k) % mod
    return (a * pow(b, mod - 2, mod) * pow(c, mod - 2, mod)) % mod
    

def B():
    n = II()
    d = LI()
    dic = defaultdict(int)
    if d[0] != 0:
        print(0)
        return
    for di in d[1:]:
        dic[di] += 1
    ans = 1
    di = list(dic.items())
    di.sort()
    if di[0][0] != 1:
        print(0)
        return
    for i in range(len(di) - 1):
        if di[i][0] != di[i + 1][0] - 1:
            print(0)
            return
    be = 1
    for _, b in di:
        ans *= pow(be, b, mod)
        be = b
        ans %= mod
    print(ans)
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

struct SegTree {
  int size;
  vector<ll> pos;
  SegTree(ll N) { size = 1; while(size<N) size<<=1; pos.resize(2*size,0); }
  ll operator[](const ll &x) const { return pos[x+size]; }

  void build() { per(i,size) operate(i); }
  void set(ll x, const ll v) { pos[x+size] = v; }
  void update(ll x, const ll v) { set(x,v); x+=size; while (x>>=1) operate(x); }
  ll query(ll a, ll b) {
    ll L = 0, R = 0;
    for (a+=size, b+=size; a<b; a>>=1, b>>=1) {
      if (a&1) { L = q(L,pos[a]); a++; }
      if (b&1) { b--; R = q(pos[b],R); }
    }
    return q(L,R);
  }
  void operate(ll i) { pos[i] = max(pos[i*2],pos[i*2+1]); }
  ll q(ll x, ll y) { return max(x,y); }
};

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

int main() {
  ll N, Q; cin >> N >> Q;
  ll A[N]; rep(i,N) cin >> A[i];

  SegTree st(N); rep(i,N) st.update(i,A[i]);
  rep(_,Q) {
    ll t, x, y; cin >> t >> x >> y; x--;
    if (t==1) st.update(x,y);
    else if (t==2) cout << st.query(x,y) << endl;
    else if (t==3) {
      ll l = x+1, r = N+1;
      while (l!=r) {
        ll mid = (l+r)/2;
        if (st.query(x,mid)>=y) r = mid;
        else l = mid+1;
      }
      cout << l << endl;
    }
  }
  // cout << result << endl;
  return 0;
}

Measured memory_bytes: 9048
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:String,
    }
    let a=a.chars().collect_vec();
    if a.len()==2{println!("{}{}",a[0],a[1])}
    if a.len()==3{println!("{}{}{}",a[2],a[1],a[0])}
}

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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define pb push_back

const long long MOD = 1000000007;
const long long INF = 1LL<<60;


int main(){
    cout << fixed << setprecision(12);
    double a, b, x;
    cin >> a >> b >> x;

    if(a*a*b > 2*x) {
        cout << atan(a * b * b / 2.0 / x) * (180.0 / 3.141592653589793238463) << endl;
    }else {
        cout << atan(2.0 * (a * a * b - x) / (a * a * a)) * (180.0 / 3.141592653589793238463) << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back

vector<vector<int>> E;
//Eは頂点数＋１をとっておく

int diameter(int x){//頂点数を入れる
    int ans=0,en=x;
    queue<int> q;
    vector<int> dis(x+1,0);//何マスで訪れたか
    dis.at(x)=-1;
    q.push(x);
    
    while(q.size()!=0){
        int s=q.front();
        q.pop();
        for(int i=0;i < E.at(s).size();i++)
        {
            if(dis.at(E.at(s).at(i))==0){
                dis.at(E.at(s).at(i))+=max(dis.at(s)+1,1);
                q.push(E.at(s).at(i));
                if(ans<dis.at(E.at(s).at(i))){
                    en = E.at(s).at(i);
                }
                ans=max(ans,dis.at(E.at(s).at(i)));
            }
        }
    }

    dis.assign(x+1,0);
    dis.at(en)=-1;
    q.push(en);
    while(q.size()!=0){
        int s=q.front();
        q.pop();
        for(int i=0;i < E.at(s).size();i++)
        {
            if(dis.at(E.at(s).at(i))==0){
                dis.at(E.at(s).at(i))+=max(dis.at(s)+1,1);
                q.push(E.at(s).at(i));
                ans=max(ans,dis.at(E.at(s).at(i)));
                
            }
        }
    }
    return ans;
}



int main(){
    int n,d;
    cin >> n;
    E.assign(n+1,vector<int>());
    for(int i=0;i < n-1;i++)
    {
        int a,b;
        cin >> a >> b;
        E.at(a).pb(b);
        E.at(b).pb(a);//Edge
    }
    d=diameter(n);
    d++;
    if(d%3==2){
        cout << "Second" << endl;
    }else{
        cout << "First" << endl;
    }
}


Measured memory_bytes: 13556
#include <bits/stdc++.h>
#define rep(i,n1) for(int i=0;i<n1;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
#define PI 3.141592653589793
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const ll inf=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vector<Pii> v[100001];
ll dp2[300000][60]={};
ll calc(ll n1,int k1){
	if(n1<k1||k1==0)return 0;
	if(k1==1)return 9*n1;
	if(k1==2)return (9*9*(n1-1)*n1)/2;
	if(k1==3)return (9*9*9*n1*(n1-1)*(n1-2))/6;
}
int main() {
	string s;
	int k;
	cin>>s>>k;
	int n=s.size();
	ll r=0;
	int p=0;
	while(k>0&&p<n){
		int i=(int)s[p]-48;
		if(i>0){
			r+=calc(n-p-1,k);//0
			r+=(i-1)*calc(n-p-1,k-1);
			if(k==1)r+=i;
			k--;
		}
		p++;
	}
	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 3968
times=[]
for i in range(5):
  times.append(int(input()))
rem=9
sum=0
count=False
for i in range(5):
  if times[i]%10==0:
    sum+= times[i]
  else:
    sum+= (times[i]//10)*10+10
    rem=min(rem,times[i]%10)
    count=True
if count:
  rem-=10
else:
  rem=0
print(sum+rem)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] lArr = new int[n];
        for (int i = 0; i< n; i++) {
            lArr[i] = sc.nextInt();
        }

        int current = 0;
        int count = 1;
        for (int l : lArr) {
            current = current + l;
            if (current > x) break;
            count++;
        }
        System.out.println(count);
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


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

int main(){
	string s;
	int a=0;
  	cin>>s;
	for(int i=0;i<4;i++){
		if(s[i]=='+'){
			a++;
		}else{
			a--;
		}
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
	int R[MAX], n;

	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> R[i];

	int maxv = -2000000000;
	int minv = R[0];

	for(int i = 1; i < n; i++){
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}

	cout << maxv << endl;

	return 0;
}

Measured memory_bytes: 1940
from collections import Counter

n = int(input())
A = list(map(int, input().split()))

# 書かれた番号の頻度
Freq = dict(sorted(Counter(A).items(), key=lambda x: x[1], reverse=True))

# 答えの最大値
ans_max = 0
for kv in Freq.items():
  ans_max += kv[1] * (kv[1] - 1) // 2

for a in A:
  # 1個しか存在しない番号は、取り除いても答えに影響しない
  if Freq.get(a) == 1:
    print(ans_max)
    continue

  # x個の場合と、x-1個の場合と、の差分
  x = Freq.get(a)
  diff = (x * (x-1) // 2) - ((x-1) * (x-2) // 2)

  # そのぶんだけ、答えの最大値から減らす
  ans = ans_max - diff
  print(ans)

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

using namespace std;

const int MOD = 998244353;

int addm(int a, int b)
{
	return (0LL + a + b) % MOD;
}

int& incm(int& a, int b)
{
	return a = addm(a, b);
}

int subm(int a, int b)
{
	return addm(a, (MOD - b) % MOD);
}

int& decm(int& a, int b)
{
	return a = subm(a, b);
}

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> L(K), R(K);
	for (int j = 0; j < K; ++j) {
		cin >> L[j] >> R[j];
	}

	vector<int> a(2 * N + 10, 0);
	vector<int> b(2 * N + 19, 0);
	a[0] = 1;
	b[0] = 1;
	b[1] = subm(0, 1);
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < K; ++j) {
			incm(b[i + L[j]], a[i]);
			decm(b[i + R[j] + 1], a[i]);
		}
		a[i + 1] = addm(a[i], b[i + 1]);
	}
	cout << a[N - 1] << endl;
}


Measured memory_bytes: 6428
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define endl '\n'
const int mod=1e9+7,u=1e5+5;

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

    int n,k,t=0;
    cin>>n>>k;
    int w[n+1],val[n+1];
    for(int i=1;i<=n;i++){
        cin>>w[i]>>val[i];
        t+=val[i];
    }   

    int dp[n+1][t+1];
    for(int i=1;i<=t;i++){
        dp[0][i]=1e18;
    }
    for(int i=0;i<=n;i++){
        dp[i][0]=0;
    }

    for(int i=1;i<=n;i++){
        for(int j=1;j<=t;j++){
            dp[i][j]=dp[i-1][j];
            if(val[i]<=j){
                dp[i][j]=min(dp[i-1][j-val[i]]+w[i],dp[i][j]);
            }
        }
    }

    int ans=0;
    for(int i=1;i<=t;i++){
        if(dp[n][i] and dp[n][i]<=k){
            ans=i;
        }
    }
    cout<<ans;

    return 0;
}

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

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

}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
using namespace std;

int main(){
    int N,P;
    cin>>N;
    string s;
    pair<pair<string,int>,int> p[110];

    for(int i=0;i<N;i++){
        cin>>s>>P;
        p[i]=make_pair(make_pair(s,-P),i+1);
    }
    sort(p,p+N);

    for(int i=0;i<N;i++){
        cout<<p[i].second<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
L = $<.map{_1.split.map &:to_i}
N,A,Q = L.shift[0],L.shift,L.shift[0]
T = [0]*(10**5+1)
s = A.inject(0) {|s,i| T[i]+=1; s+i}
L[0,Q].each {|b,c|
  p s += (c-b)*T[b]
  T[c] += T[b]
  T[b] = 0
}

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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

typedef vector<LL> V;
typedef vector<V> VV;
int main() {
	int N, K;
	cin >> N >> K;
	V a(N);
	cin >> a;
	LL ret = 1e18;
	for (int bit : range(1 << N)) {
		bitset<16> b(bit);
		if (b.count() < K)continue;
		LL h = 0;
		LL cost = 0;
		for (int i : range(N)) {
			if (b[i]) {
				if (a[i] <= h) {
					cost += h + 1 - a[i];
					h++;
				}
			}
			chmax(h, a[i]);
		}
		chmin(ret, cost);
	}
	cout << ret << endl;
	return 0;
}


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

int main(int argc,char* argv[]){
  
  for(;;){
    int x,h;
    double S,len,side;

    scanf("%d",&x);
    scanf("%d",&h);

    if(x == 0 && h == 0){
      break;
    }

    S = x*x;
    len = sqrt((double)(x*x)/4 + h*h);
    side = len*x*2;
    printf("%.6lf\n",S + side);
    
  }
  
  return 0;
  
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define mx 3005
using namespace std;

string s, t, ans;
int dp[mx][mx], u, w;

int main(){
	cin >> s >> t;
	u = s.length();
	w = t.length();
	s = "." + s;
	t = "," + t;
	for(int i = 1; i <= u; i++){
		for(int j = 1; j <= w; j++){
			dp[i][j] = max(max(dp[i-1][j], dp[i][j-1]), dp[i-1][j-1] + (s[i] == t[j]));
		}
	}
	while(dp[u][w]){
		if(dp[u][w] == dp[u][w-1]) w--;
		else if(dp[u][w] == dp[u-1][w]) u--;
		else{
			ans = s[u] + ans;
			w--;
			u--;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 35456
#include <iostream>
#define SIZE 100

using namespace std;

void product(int, int, int, long int (*a)[SIZE], long int (*b)[SIZE], long int (*c)[SIZE]);

int main(void) {
	int n, m, l;
	long int a[SIZE][SIZE], b[SIZE][SIZE], c[SIZE][SIZE];
	cin >> n >> m >> l;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < l; j++) {
			cin >> b[i][j];
		}
	}

	product(n, m, l, a, b, c);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			cout << c[i][j];
			if (j != l-1) {
				cout << " ";
			}
		}
		cout << "\n";
	}

	int k;
	cin >> k;

	return 0;
}

void product(int n, int m, int l, long int (*a)[SIZE], long int (*b)[SIZE], long int (*c)[SIZE]) {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			c[i][j] = 0;
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < m; k++) {
				c[i][j] += a[i][k] * b[k][j];
			}
		}
	}
}

Measured memory_bytes: 3336
#include<bits/stdc++.h>
using namespace std;
/*
#ifndef ONLINE_JUDGE
    #define cin f
    #define cout g
    ifstream cin("a.in");
    ofstream cout("a.out");
#endif
*/
int n,k=2,v[1<<17],dp[1<<17];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;++i) cin>>v[i];
    for(int i=2;i<=n;++i)
    {
        int ans=1e9;
        for(int j=max(i-k,1);j<i;++j) ans=min(ans,dp[j]+abs(v[i]-v[j]));
        dp[i]=ans;
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 1024
import java.util.*

fun main(args:Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val q = PriorityQueue<Long>()
    var ans = 0L
    readLine()!!.split(" ").map { it.toLong() }.forEach {
        ans += it
        q.add(it)
    }
    val sousa = (1..m).map { readLine()!!.split(" ").map { it.toLong() } }.sortedByDescending { it[1] }
    (0 until m).forEach {
        val (b, c) = sousa[it]
        for(i in (1 .. b)) {
            if(q.peek() >= c) {
                break
            }
            val num = q.poll()
            ans += c-num
            q.add(c)
        }
    }
    println(ans)
}



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

using namespace std;

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


int main() {
	int n, m;
	cin >> n >> m;
	vector <int> a (n);
	for (int &t : a) cin >> t;

	vector <pair <int,int> > cb (m);
	for (auto &t : cb) {
		int &c = t.first, &b = t.second;
		cin >> b >> c;
	}
	sort(rbegin(cb), rend(cb));

	vector <int> cur;
	for (auto t : cb) {
		int c = t.first, b = t.second;
		while (sz(cur) < n && b--) cur.push_back(c);
	}
	while (sz(cur) < n) cur.push_back(0);
	sort(begin(a), end(a));

	long long ans = 0;
	for (int i = 0; i < n; i++) ans += max(cur[i], a[i]);
	cout << ans << endl;
}


Measured memory_bytes: 2044
n=int(input())
x=[[0]*3 for i in range(n)]

for i in range(n):
    a,b,c=map(int,input().split())
    if i==0:
        x[i][0]=a 
        x[i][1]=b
        x[i][2]=c 
    else:
        x[i][0]=max(x[i-1][1],x[i-1][2])+a
        x[i][1]=max(x[i-1][0],x[i-1][2])+b
        x[i][2]=max(x[i-1][0],x[i-1][1])+c
    
print(max(x[n-1]))

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

namespace ABC173
{

  class B_JudgeStatusSummary
  {
  public:
    B_JudgeStatusSummary() = default;
    ~B_JudgeStatusSummary() = default;


    void Run()
    {
      int N = {};
      std::cin >> N;

      int count[4] = {};
      enum A
      {
        AC,
        WA,
        TLE,
        RE,
      };

      for (int i = 0; i < N; ++i)
      {
        std::string str;
        std::cin >> str;

        if (str == "AC") { count[AC]++; }
        else if (str == "WA") { count[WA]++; }
        else if (str == "TLE") { count[TLE]++; }
        else if (str == "RE") { count[RE]++; }
      }

      std::cout << "AC x " << count[AC] << std::endl;
      std::cout << "WA x " << count[WA] << std::endl;
      std::cout << "TLE x " << count[TLE] << std::endl;
      std::cout << "RE x " << count[RE] << std::endl;
    }
  };

}

int main()
{

  ABC173::B_JudgeStatusSummary prob;
  prob.Run();

  return 0;
}



Measured memory_bytes: 3156
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <cstring>

using namespace std;
int n;
long long int a[200002];
long long int sum=0,sum2=0;
int main(){
  cin >> n;
  for(long long int i=0;i<n;i++){cin >> a[i];a[i]-=(i+1);}
  sort(a,a+n);
  if(n%2==1){
    long long int b=a[n/2];
    for(int i=0;i<n;i++){
      sum+=abs(a[i]-b);
    }
    cout << sum << endl;
  }
  else{
    long long int b=a[n/2];
    for(int i=0;i<n;i++){
      sum+=abs(a[i]-b);
    }
    b=a[n/2-1];
    for(int i=0;i<n;i++){
      sum2+=abs(a[i]-b);
    }
    cout << min(sum,sum2) << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
inline int read(){
	int x=0,f=1;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return x*f;
}
const int N=2010,INF=0x3f3f3f3f;
int a[N],b[N],tmp[N],lt,c[N],lc;
bool is[N];
int main(){
	int n=read(),k=read(),q=read(),ans=INF;
	for (int i=1;i<=n;++i) a[i]=b[i]=read();
	sort(b+1,b+n+1);
	is[n+1]=1;
	for (int i=1;i<=n;++i){
		for (int j=1;j<=n;++j) if (a[j]<b[i]) is[j]=1;
		lt=lc=0;
		for (int j=1;j<=n+1;++j){
			if (is[j]){
				if (lt>=k){
					sort(tmp+1,tmp+lt+1);
					for (int x=1;x<=lt-k+1;++x) c[++lc]=tmp[x];
				}
				lt=0;
			}
			else tmp[++lt]=a[j];
		}
		if (lc>=q){
			sort(c+1,c+lc+1);
			ans=min(ans,c[q]-b[i]);
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int n,w;
int dp[105][100005];
int values[100005];
int weigths[100005];

int solve(int index,int taken){
    if(index==n) return 0;
    if(dp[index][taken]!=-1) return dp[index][taken];
    int &ans=dp[index][taken];
    ans=0;
    if(taken+weigths[index]<=w){
        ans=max(values[index]+solve(index+1,taken+weigths[index]),solve(index+1,taken));
    }
    else{
        ans=solve(index+1,taken);
    }
    return ans;
}

int32_t main(){
    cin>>n>>w;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++){
        cin>>weigths[i]>>values[i];
    }
    cout<<solve(0,0)<<"\n";
    return 0;
}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll n;
    cin>>n;
    vector<ll> a(n+1);
    repA(i,1,n) cin>>a[i];
    sort(a.begin()+1,a.begin()+n+1);
    ll ans=a[n];
    ll idx1=n-1;
    ll idx2=n-2;
    while(idx2>=1)
    {
      ans+=a[idx1];
      idx2--;
      if(idx2<1) break;
      ans+=a[idx1];
      idx2--;
      idx1--;
    }
    cout<<ans<<'\n';
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 4764
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int n;
vector<int> v;
vector<bool> sieve(1000009);

void prime_factorize(int n, vector<int> &res) {
    if (n <= 1) return;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res.push_back(i);
            n /= i;
        }
    }
    if (n != 1) {
        res.push_back(n);
    }
}

int main() {
    cin >> n;
    v.resize(n);
    rep(i, n) scanf("%d", &v[i]);
    sort(all(v));
    bool is_pc = true;
    for (int i : v) {
        if (sieve[i]) {
            is_pc = false;
            break;
        }
        vector<int> pf;
        prime_factorize(i, pf);
        for (int p : pf) {
            sieve[p] = true;
            for (int j = p * 2; j <= 1000000; j += p) {
                if (!sieve[j]) {
                    sieve[j] = true;
                }
            }
        }
        if (!is_pc) break;
    }
    if (is_pc) {
        cout << "pairwise coprime" << endl;
    } else {
        if (accumulate(v.begin(), v.end(), 0, [](int m, int n) { return __gcd(m, n); }) == 1) {
            cout << "setwise coprime" << endl;
        } else {
            cout << "not coprime" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 7200
using System;

class Atcoder118
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c;

        if (a > b)
        {
            c = a - 1;
            Console.WriteLine(a + Math.Max(b, c));
        }
        else
        {
            c = b - 1;
            Console.WriteLine(b + Math.Max(a, c));
        }
    }
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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






int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int i,m,n,cnt=0;
    cin >> n >> m;
    V<int>ans;
    for(i=1;i<=n;i++)ans.emplace_back(i);
    for(i=1;i<=n/2;i++)
    {
        cout << i << ' ' << ans.back() << '\n';
        ++cnt;
        if(n%2 == 0  &&  cnt == (m+1)/2)ans.pop_back();
        ans.pop_back();
        if(cnt == m)break;
    }
    return 0;
}


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

int d[12][11][11][11][55]; //d[curh][curw][l][r][oxy]

int main(){
  int w,h;
  while(cin >> w >> h, w){
    int f, m, o;
    cin >> f >> m >> o;

    vector<vi> c(h, vi(w,0));
    rep(i,h)rep(j,w)cin >> c[i][j];

    if(o<=1){
      cout << "NA" << endl;
      continue;
    }

    memset(d,-1,sizeof(d));
    priority_queue< vi, vector<vi>, greater<vi> > q;

    rep(i,w){
      int no = o-1, nv = 0;
      if(c[0][i] > 0){
	no = min(m, no+c[0][i]);
      }else{
	nv = -c[0][i];
      }
      d[0][i][i][i][no] = nv;
      q.push( {nv,0,i,i,i,no} );
    }

    int ans = 1e9;
    while(q.size()){
      vi s = q.top(); q.pop();
      int v = s[0], y = s[1], x = s[2], l = s[3], r = s[4], o = s[5];
      if(y==h-1){
	ans = v;
	break;
      }
      if(o<=1)continue;

      if(x-1>=0){
	int nx = x-1, ny = y, nl = l, nr = r, no = o-1, nv = v;
	if(nx < nl){
	  nl--;
	  if(c[ny][nx] > 0){
	    no = min(m, no+c[ny][nx]);
	  }else{
	    nv -= c[ny][nx];
	  }
	}
	if(d[ny][nx][nl][nr][no] < 0 || d[ny][nx][nl][nr][no] > nv){
	  d[ny][nx][nl][nr][no] = nv;
	  q.push( {nv,ny,nx,nl,nr,no} );
	}
      }

      if(x+1<w){
	int nx = x+1, ny = y, nl = l, nr = r, no = o-1, nv = v;
	if(nx > nr){
	  nr++;
	  if(c[ny][nx] > 0){
	    no = min(m, no+c[ny][nx]);
	  }else{
	    nv -= c[ny][nx];
	  }
	}
	if(d[ny][nx][nl][nr][no] < 0 || d[ny][nx][nl][nr][no] > nv){
	  d[ny][nx][nl][nr][no] = nv;
	  q.push( {nv,ny,nx,nl,nr,no} );
	}
      }

      if(y+1<h){
	int nx = x, ny = y+1, nl = x, nr = x, no = o-1, nv = v;
	if(c[ny][nx] > 0){
	  no = min(m, no+c[ny][nx]);
	}else{
	  nv -= c[ny][nx];
	}

	if(d[ny][nx][nl][nr][no] < 0 || d[ny][nx][nl][nr][no] > nv){
	  d[ny][nx][nl][nr][no] = nv;
	  q.push( {nv,ny,nx,nl,nr,no} );
	}
      }
    }

    if(ans > f){
      cout << "NA" << endl;
    }else{
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 6712
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	int a,b;
	scanf("%d %d", &a, &b);
	int ans = 0;
	for(int i=a;i<=b;i++){
		if(i/10000==i%10 && (i/1000)%10==(i/10)%10) ans++;
	}

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


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define INF 1000000001
typedef struct vertice
{
  int cost;
  int status;
  int numOfAdj;
  int *adjList;
  int *costList;
} ver;
ver *v;
int n;//the number of vertices
void init();
void setArray(int);
void dijkstra(void);
int main(void)
{
  int i,j;//counter
  int key;
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++)
    {
      scanf("%d",&key);
      scanf("%d",&v[key].numOfAdj);
      setArray(key);
      for(j=0;j<v[key].numOfAdj;j++) scanf("%d%d",&v[key].adjList[j],&v[key].costList[j]);
    }
  dijkstra();
  free(v);
  return 0;
}
void init(void)
{
  int i;//counter
  v=(ver*)malloc(sizeof(ver)*n);
  for(i=0;i<n;i++)
    {
      v[i].numOfAdj=0;
      v[i].status=0;
      v[i].cost=INF;
    }
}
void setArray(int key)
{
  v[key].adjList=(int*)malloc(sizeof(int)*v[key].numOfAdj);
  v[key].costList=(int*)malloc(sizeof(int)*v[key].numOfAdj);
}
void dijkstra(void)
{
  int i;//count
  int current=0;
  int viewing;
  int next;
  int minCost;
  v[0].cost=0;
  for(;;)
    {
      v[current].status=1;
      minCost=INF;
      for(i=0;i<v[current].numOfAdj;i++)
        {
          viewing=v[current].adjList[i];
          if(v[viewing].status==0)
            {
              if(v[current].cost+v[current].costList[i]<v[viewing].cost)
                {
                  v[viewing].cost=v[current].cost+v[current].costList[i];
                  //printf("v[%d].cost=%d\n",viewing,v[viewing].cost);
                }
            }
        }
      for(viewing=0;viewing<n;viewing++)
        {
          if(v[viewing].status==0&&v[viewing].cost<minCost)
            {
              minCost=v[viewing].cost;
              next=viewing;
            }
        }
      if(minCost==INF) break;
      //printf("next->%d\n",next);
      current=next;
    }
  for(i=0;i<n;i++) printf("%d %d\n",i,v[i].cost);
}


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

int main() {
    string a;
    int b = 0;
    int ans = 0;
    cin >> a;
    for (int i = 0; i < 4; i++) {
        


        if (a[i] == b) {
            ans += 1;
        }
        b = a[i];
    }

    if (ans != 0) {
        cout << "Bad" << endl;
    }
    else {
        cout << "Good" << endl;
    }
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int on; cin >> on;
  int s = 0, n = on;
  while (n != 0) {
    s += n - (n / 10) * 10;
    n /= 10;
  }
  if (on % s == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 888
/*
    Author : Ritesh Singh
*/
 
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional>
// using namespace __gnu_pbds; 
using namespace std;
#define lct long long int t;cin>>t;while(t--)
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define el '\n'
#define IOS ios_base::sync_with_stdio(false), cin.tie(NULL)
const int mod = 1e9+7;
typedef long long ll;
 
// typedef tree<string, null_type, less<string>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//     new_data_set; 
 
int32_t main()
{
 	IOS;
 	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#else
	// online submission
	#endif
  	ll a, b, c, d; cin>>a>>b>>c>>d;
  	cout<<max({a*c, a*d, b*c, b*d});	
}

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

int main(){
    
    for(ll b; cin >> b, b;){
        ll X, Y;
        for(ll y = 1; y < 45000; y++){
            ll tmp = b - y * (y - 1) / 2;
            if(tmp <= 0)continue;
            if(tmp % y == 0){
                X = tmp / y;
                Y = y;
            }
        }
        cout << X << " " << Y << endl;
    }

    return 0;
}



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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> A(m);
  
  for (auto &i : A) {
    cin >> i;
  }
  
  int i = 0;
  while (i < A.size()) {	
   	n = n-A[i++];
  }
  if (n < 0) {
    cout << "-1" << endl;
  } else {
  cout << n;
  }
  return 0;
}


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

#define y1 aklsdja
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define pb push_back
#define t top()
#define fr front()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , x) for(int i = 0 ; i < x ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define oo 1e17 + 5
#define ll long long
#define int long long
#define pow poww

const int N = 1e3 + 5;
int n , m , mod = 1e9 + 7;
int dp[N][N];
char f[N][N];

int add(int a , int b)
{
    return (a + b) % mod;
}

main()
{
    //freopen("H.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    FOR(i , 1 , n)
        FOR(j , 1 , m)
            cin >> f[i][j];
    dp[1][1] = 1;
    FOR(i , 1 , n)
        FOR(j , 1 , m)
            if(i != 1 || j != 1 && f[i][j] != '#')
            {
                if(f[i - 1][j] != '#')
                    dp[i][j] = add(dp[i][j] , dp[i - 1][j]);
                if(f[i][j - 1] != '#')
                    dp[i][j] = add(dp[i][j] , dp[i][j - 1]);
            }
    cout << dp[n][m];
}


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

using namespace std;

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

  int x, y;
  cin >> x >> y;

  string ans = "No";
  for (int i = 0; i <= x; ++i) {
    if (y == (i * 2) + ((x - i) * 4)) {
      ans = "Yes";
      break;
    }
  }
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3644
#include <utility>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#define INTINF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
pair<int, char>  L[100000/2+2];
pair<int, char>  R[100000/2+2];

void merge(std::vector<pair<int, char> > &A, int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  for (size_t i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }
  for (size_t i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }
  L[n1].first = INTINF;
  R[n2].first = INTINF;
  int i=0;
  int j=0;
  for (size_t k = left; k < right; k++) {
    if (L[i].first <= R[j].first) {
      A[k] = L[i];
      i++;
    }else{
      A[k] = R[j];
      j++;
    }
  }
}

void mergesort(std::vector<pair<int, char> > &A, int left, int right){
  if (left+1 < right) {
    int mid = (left + right)/2;
    mergesort(A, left, mid);
    mergesort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int partition(std::vector<pair<int, char> > &A, int first, int last){
  int x = A[last].first;
  int i = first-1;
  for (size_t j = first; j < last; j++) {
    if (A[j].first<=x) {
      i++;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1], A[last]);
  return i+1;
}

void quicksort(std::vector<pair<int, char> > &A, int first, int last){
  if(first<last){
    int q = partition(A, first, last);
    quicksort(A, first, q-1);
    quicksort(A, q+1, last);
  }
}


int main(int argc, char const *argv[]) {
  int n; scanf("%d\n", &n);

  char text; int num;
  pair<int, char> card;
  std::vector<pair<int, char> > A;
  A.reserve(100000);
  std::vector<pair<int, char> > B;
  B.reserve(100000);

  for (size_t i = 0; i < n; i++) {
    std::cin >> text >> num;
    card = make_pair(num, text);
    A.push_back(card);
    B.push_back(card);
  }

  quicksort(A, 0, n-1);
  mergesort(B,0,n);

  bool stable = true;
  for (size_t i = 0; i < n; i++) {
    if (A[i].second!=B[i].second) {
      stable=false;
    }
  }

  if (stable) {
    std::cout << "Stable" << '\n';
  }else{
    std::cout << "Not stable" << '\n';
  }



  for (size_t i = 0; i < n; i++) {
    std::cout << A[i].second << " " << A[i].first << '\n';
  }

  return 0;
}



Measured memory_bytes: 5212
#include <stdio.h>

int is_square(int j) {
  for (int i = 1; i * i <= j; ++i) {
    if (i * i == j) {
      return 1;
    } else {
      continue;
    }
  }
  
  return 0;
}

int main(void) {
  int a, b, c;
  scanf("%d %d", &a, &b);

  if (b < 10) {
    c = a * 10 + b;
  } else if (b < 100) {
    c = a * 100 + b;
  } else {
    c = a * 1000 + b;
  }

  if (is_square(c)) {
    printf("Yes");
  } else {
    printf("No");
  }
  
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

ll Pow(ll a, ll n){
    if(n == 0) return 1;
    ll half = Pow(a,n/2);
    ll res = half * half;
    if(n & 1) res = res * a;
    return res;
}


int main(){
    ll N,P; cin >> N >> P;
    if(N == 1){
        cout << P << endl;
        return 0;
    }
    set<ll> s;
    for(ll i = 1; i*i <= P; i++){
        if(P % i == 0){
            s.insert(i);
            s.insert(P/i);
        }
    }
    ll ans = 0;
    for(ll u : s){
        for(ll i = 1; i*i <= u; i++){
            if(Pow(i,N) == u){
                ans = max(ans,i);
                break;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
using namespace std;
int compare_int(const void *a, const void *b)
{
    return *(int *)a - *(int *)b;
}
int a, b, c;
int main()
{
    cin >> a >> b >> c;
    int x[] = {a, b, c};
    qsort(x, 3, sizeof(int), compare_int);
    if (x[0] == x[1] && x[2] != x[1])
    {
        cout << "Yes" << endl;
    }
    else if (x[1] == x[2] && x[0] != x[1])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  long long s,cnt=0;
  vector<int> a(n+2);
  for(int j=1;j<n+1;j++){
    cin >> a.at(j);
    cnt += max(a.at(j-1)-a.at(j),a.at(j)-a.at(j-1));
  }
  cnt += max(a.at(n+1)-a.at(n),a.at(n)-a.at(n+1));
  
  for(int j=1;j<n+1;j++){
    s =  max(a.at(j-1)-a.at(j),a.at(j)-a.at(j-1));
    s += max(a.at(j+1)-a.at(j),a.at(j)-a.at(j+1));
    s -= max(a.at(j-1)-a.at(j+1),a.at(j+1)-a.at(j-1));
    cout << cnt -s << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1664