akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

int popcount(int a){
    return __builtin_popcount(a);
}

vector<int> solve(int n, int a, int b){
    if(n==1){
        return {a,b};
    }
    int bit = (1 << (n-1));
    if((a & bit) != (b & bit)){
        vector<int> s1, s2;
        s1 = solve(n-1, a, a ^ 1);
        s2 = solve(n-1, (a ^ 1) ^ bit, b);
        for(auto p : s2)
            s1.push_back(p);
        return s1;
    }
    else{
        vector<int> s1, s2;
        s1 = solve(n-1, a, b);
        s2 = solve(n-1, a ^ bit, (s1[1] ^ bit));
        vector<int> vv = {s1[0]};
        for(auto x : s2) vv.push_back(x);
        for(int i = 1; i < s1.size(); i ++ ) vv.push_back(s1[i]);
        return vv;
    }
}

int main(){
    fastIO;
    int n, a, b;
    cin >> n >> a >> b;
    if(popcount(a) % 2 == popcount(b) % 2){
        cout << "NO\n";
        return 0;
    }
    cout << "YES\n";
    vector<int> res = solve(n, a, b);
    for(auto x : res)
        cout << x << " ";
    return 0;
}

Measured memory_bytes: 1896
s = input()
t = input()
ss = sorted(s)
tt = sorted(t,reverse=True)
for n, w in zip(ss,tt):
  if n < w:
    print("Yes")
    exit()
  elif n > w:
    print("No")
    exit()
if len(ss) >= len(tt):
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif


using namespace std;
#define M 1000000001
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repb(i,a,b) for(int i=a;i>=b;--i)
#define repv(arr)  for(auto it=arr[i].begin();it!=arr[i].end();++it)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define vc vector<char>
#define sz(a) (int)a.size()
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define ssortB(arr)   stable_sort(arr.begin(),arr.end(),greater<int>());
#define pii pair<int,int>
#define pli pair<long long,int>
#define pll pair<long long,long long>
#define fi first
#define se second
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define mp make_pair
#define endl "\n" 
#define LCM(a,b) boost::math::lcm(a,b)
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    vi arr(n+1);
    rep(i,1,n+1){
        cin>>arr[i];
    }
    int a=1;
    rep(i,k+1,n+1){
        if(arr[i]>arr[a]){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
        ++a;
    }
}

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

int main(){
 double r,a,b,pi = 3.141592653589;

 cin >> r;

 a = pi * r * r;
 b = 2 * pi *r;

 printf("%f %f\n" ,a,b);

 return 0;
}

Measured memory_bytes: 1232
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean jud = true;
        for(int i = 0;i < 3;i++){
            if(s.charAt(i) == s.charAt(i+1)){
                jud = false;
            }
        }

        if(jud == true){
            System.out.println("Good");
        }else{
            System.out.println("Bad");
        }
    }
}

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

struct UnionFind{
    vector<int> p;
    vector<int> r;

    UnionFind(int n){
        p.resize(n, -1);
        r.resize(n, 1);
    }

    int find(int x){
        if(p[x] == -1) return x;
        else return p[x] = find(p[x]);
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);

        if(x == y) return;
        if(r[x] > r[y]) swap(x, y);
        if(r[x] == r[y]) ++r[y];

        p[x] = y;
    }
};

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

    int n, m;
    cin >> n >> m;

    vector<pair<int, pair<int, int>>> d;
    rep(_, m){
        int a, b, c;
        cin >> a >> b >> c;

        d.push_back(make_pair(c, make_pair(a, b)));
    }

    sort(d.begin(), d.end());

    UnionFind uf(n);

    int res = 0;
    for(auto edge: d){
        int cost = edge.first;
        int from = edge.second.first;
        int to = edge.second.second;

        if(uf.find(from) != uf.find(to)){
            res += cost;
            uf.unite(from, to);
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 4532
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);



int main() {

    int n,q;
    cin>>n>>q;
    vector<tuple<int,int,int>> stx(n);
    rep(i,n){
        cin>>get<1>(stx[i])>>get<2>(stx[i])>>get<0>(stx[i]);
    }
    sort(stx.begin(),stx.end());

    set<pair<int,int>> d;
    rep(i,q){
        int x;cin>>x;
        d.insert({x,i});
        //d.emplace(x,i);
    }
    vector<ll> tm(q,-1);
    rep(i,n){
        auto first = d.lower_bound(make_pair(get<1>(stx[i])-get<0>(stx[i]),0));
        auto end = d.upper_bound(make_pair(get<2>(stx[i])-get<0>(stx[i])-1,q));
        for(auto itr=first;itr!=end;itr++)tm[itr->second]=get<0>(stx[i]);
d.erase(first,end);




    }
    rep(i,q)cout<<tm[i]<<endl;






    return 0;
}


Measured memory_bytes: 15104
#A = 1
#B = 0
#
#while True:
#    print(A,B)
#    print(A**5 - B**5)
#    A += 10
#    B += 10
#    if A**5 - B**5 >= 10**10:
#        eAit()
#上記コードで検証したところ
# 10**9は大体A=120で超える。
#マイナスを加味しても、A:240通り、B:240通り程度と考え240*240=57600通り程度。全探索余裕。

x = int(input())

for a in range(-120,121):
    for b in range(-121,120):
        if a**5 - b**5 == x:
            print(f"{a} {b}")
            exit()


Measured memory_bytes: 63868
#include <stdio.h>

int main(){

    char greet[4];
    scanf("%s", greet);
    char creet[4];
    scanf("%s", creet);

    if(greet[0] == creet[2] && 
    greet[1] == creet[1] &&
    greet[2] == creet[0])
    printf("YES\n");

    else
    printf("NO\n");
}

Measured memory_bytes: 128
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

//-----------------------ここから-----------


int main(void){
    int n;

    cin >> n;

    int ans = 0;
    for(int i = 1; i <= n; i += 2){
        int counter = 0;
        for(int j = 1; j <= n; j++){
            if(i % j == 0){
                counter++;
            }
        }
        if(counter == 8){
            ans++;
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int calc(int x, int t){
	if(x%t==0) return x/t*(t+1)-1;
	else return x/t*(t+1)+(x%t);
}
void solve(int a, int b, int c, int d){
	if(a==b){
		for(int i=c; i<=d; i++){
			if(i&1) cout<<'A';
			else cout<<'B';
		}
		cout<<endl;
		return;
	}
	int t;
	if(a>b) t=(a+b)/(b+1);
	else t=(a+b)/(a+1);
	int x1=0, x2=a;
	while(x1!=x2){
		int x=(x1+x2+1)/2;
		int xn=calc(x, t);
		int b0=b-xn/(t+1), a0=a-(xn-xn/(t+1));
		if(a0<0 || b0<0 || (ll)b0>(ll)t*(ll)(a0+1)) x2=x-1;
		else x1=x;
	}
	x1=calc(x1, t);
	int b0=b-x1/(t+1), a0=a-(x1-x1/(t+1));
	for(int i=c; i<=d; i++){
		if(i<=x1){
			if(i%(t+1)==0) cout<<'B';
			else cout<<'A';
		}else if(i<=x1+(b0-a0*t)){
			cout<<'B';
		}else{
			if((i-x1-(b0-a0*t)-1)%(t+1)==0) cout<<'A';
			else cout<<'B';
		}
	}
	cout<<endl;
}
int main()
{
	int q; cin>>q;
	for(int i=0; i<q; i++){
		int a, b, c, d;
		cin>>a>>b>>c>>d;
		solve(a, b, c, d);
	}
	return 0;
}

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

int main() {
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    int a=0;
    for(int j=0;j<s.size();j++){
      if(s.at(i)==s.at(j)){
        a++;
      }
    }
    if(a%2==1){
      cout<<"No"<< endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}


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

int main()
{
    int n,k;
    cin >> n >> k;
    int d[100];
    int a[100][100];
    for (int i = 0; i < k; i++)
    {
        cin >> d[i];
        for (int j = 0; j < d[i]; j++)
        {
            cin >> a[i][j];
            a[i][j]--;
        }
    }


    bool judge[n];
    for (int i = 0; i < n; i++)
    {
        judge[i] = false;
    }
    for (int i = 0; i < k; i++)
    {
        for (int j = 0; j < d[i]; j++)
        {
            for(int p = 0; p < n; p++)
            {
                if(a[i][j] == p)
                {
                    judge[p] = true;
                }
            }
        }
    }
    int count = 0 ;
    for (int i = 0; i <n; i++)
    {
        if(judge[i] == false) count++;
    }
    cout << count << endl;

}

Measured memory_bytes: 3644
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int h,w;
vector<string> f, ans;

int main(){
  cin >> h >> w;
  f.resize(h); ans.resize(h);
  
  rep(i,h){
    cin >> f[i];
  }
  ans = f;
  
  rep(i,h){
    rep(j,w){
      if(f[i][j] == '#'){
        ans[i][j] = '#';
        continue;
      }
      int count = 0;
      //左上
      if(i-1 >= 0 && j-1 >= 0){
        if(f[i-1][j-1] == '#') count++;
      }
      //上
      if(i-1 >= 0){
        if(f[i-1][j] == '#') count++;
      }
      //右上
      if(i-1 >= 0 && j+1 < w){
        if(f[i-1][j+1] == '#') count++;
      }
      //左
      if(j-1 >= 0){
        if(f[i][j-1] == '#') count++;
      }
      //右
      if(j+1 < w){
        if(f[i][j+1] == '#') count++;
      }
      //左下
      if(i+1 < h && j-1 >= 0){
        if(f[i+1][j-1] == '#') count++;
      }
      //下
      if(i+1 < h){
        if(f[i+1][j] == '#') count++;
      }
      //右下
      if(i+1 < h && j+1 < w){
        if(f[i+1][j+1] == '#') count++;
      }
      ans[i][j] = char(count + '0');
    }
  }
  
  for (auto s:ans){
    cout << s << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
#define REP(i, n) for (i64 (i) = 0; (i) < (n); ++(i))
#define FOR(i, a, b) for (i64 (i) = (a); (i) < (b); ++(i))

signed main() {

    int N, M;
    cin >> N >> M;
    vector<bool> used(N, false);
    vector<int> Q(M);
    REP(i, M) { cin >> Q[M - 1 - i]; Q[M - 1 - i]--; }

    vector<int> res;
    REP(i, M) {
        if (used[Q[i]]) continue;
        used[Q[i]] = true;
        res.emplace_back(Q[i]);
    }
    REP(i, N) {
        if (used[i]) continue;
        res.emplace_back(i);
    }

    REP(i, N) cout << res[i] + 1 << endl;

}


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

#define int long long
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()

const int mod = 1e9+7;
const int inf = 2e18;

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

	int n,m;
	cin>>n>>m;

	int x ;
	int sum = 0;
	for(int i=0;i<m;i++)
	{	cin>>x;
		sum+=x;
	}

	if(sum>n)cout<<-1<<'\n';
	else
		cout<<n-sum<<'\n';
	return 0;
}	

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.C_Challenge
{
    class ABC_054
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long n = long.Parse(input[0]);
            long m = long.Parse(input[1]);
            long allCnt = 0;
            if (n * 2 > m)
            {
                allCnt = m / 2;
            }
            else
            {
                allCnt = n;
                allCnt += (m - n * 2) / 4;
            }
            Console.WriteLine(allCnt);
        }
    }
}


Measured memory_bytes: 13140
//#define NDEBUG

#include <bits/stdc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define F first
#define S second
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}
#define pii pair<int, int>
#define pll pair<ll, ll>
#define modadd(a, b) (((a % MOD) + (b % MOD)) % MOD)
#define modtimes(a, b) (((a % MOD) * (b % MOD)) % MOD)

//#define TEST

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

int main(){
    StarBurstStream

    int n, m;
    cin >> n >> m;

    priority_queue<int> q;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        q.push(a);
    }

    while(m-- && q.top() > 0){
        int t = q.top();
        q.pop();
        q.push(t >> 1);
    }

    ll ans = 0;
    while(q.size()){
        ans += q.top();
        q.pop();
    }

    cout << ans << "\n";


    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(vecto) vecto.begin(),vecto.end()
typedef long long ll;

int main(){
    int r;
    cin >> r;
    if(r<1200){
        cout << "ABC" << endl;
    }
    else if(r<2800){
        cout << "ARC" << endl;
    }
    else
        cout << "AGC" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


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

    int N, M, L, Q;
    cin >> N >> M >> L;
    int A[N][N], B[N][N];
    rep(i,N){
        rep(j,N){
            A[i][j] = INF;
            B[i][j] = INF;
        }
    }
    int a, b, c;
    rep(i,M){
        cin >> a >> b >> c;
        --a; --b;
        A[a][b] = c;
        A[b][a] = c;
    }
    rep(k,N){
        rep(i,N){
            rep(j,N){
                A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
            }
        }
    }
    rep(i,N){
        rep(j,N){
            if(A[i][j] <= L) B[i][j] = 1;
        }
    }

    rep(k,N){
        rep(i,N){
            rep(j,N){
                B[i][j] = min(B[i][j], B[i][k] + B[k][j]);
            }
        }
    }

    cin >> Q;
    rep(i,Q){
        int s, t;
        cin >> s >> t;
        --s; --t;
        if(B[s][t] == INF) cout << -1 << endl;
        else cout << B[s][t]-1 << endl;
    }


}

Measured memory_bytes: 1920
#include <cstdio>
#include <random>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <chrono>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
// #define int int


using namespace std;
typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const int M = 1331;

int qpow(int a, int p, int n){ //a ^ p % n
	int res = 1;
	for(; p; a = a * a % n, p >>= 1) {
		if(p & 1) {
			res = res * a % n;
		}
	}
	return res;
}
inline int inv(int a, int n){
	return qpow(a, n - 2, n);
}
int n;
string s;
bool run(int i) {
	if(i == 0) return 1;
	int x = 0;
		std::vector<int> v[1332];
		int t = qpow(26, i - 1, M);
		for(int j = 0; j < i; ++j) {
			x = x * 26 + s[j] - 'a';
			x %= M;
		}
		v[x].eb(0);
		for(int j = i, k = 0; j < n; ++j, ++k) {
			x = (x - (s[k] - 'a') * t % M + M) * 26  + s[j] - 'a';
			x %= M;
			for(auto bgn : v[x]) {
				if(k + 1 - bgn >= i && s.substr(bgn, i) == s.substr(k + 1, i)) {
					return 1;
				}
			}
			v[x].eb(k + 1);
		}
	return 0;

}


#include <unordered_map>
signed main()
{
	cin >> n >> s;
	int l = 0, r = n / 2, res = 0;
	while(l <= r) {
		int mid = (l + r) >> 1;
		if(run(mid)) {
			l = mid + 1;
			res = mid;
		} else {
			r = mid - 1;
		}
	}
	cout << res << endl;
	return 0;
}


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

int main() {

    int N; cin >> N;
    double X = (double)N / 1.08;

    double X_up   = ceil(X);
    double X_down = floor(X);

    if ((int)floor(X_up*1.08) == N)        cout << (int)X_up << endl;
    else if ((int)floor(X_down*1.08) == N) cout << (int)X_down << endl;
    else                                   cout << ":(" << endl;

}

Measured memory_bytes: 256
use std::io::Read;

fn main(){
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s);
    let mut splits = s.trim().split_whitespace();

    let a = splits.next().unwrap().parse::<usize>().unwrap();
    let s = splits.next().unwrap().parse::<String>().unwrap();

    if  a>=3200 {
        println!("{}", s);
    }else {
        println!("red");
    }
}

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

vector<int> stoa(string const& s){
  vector<int> a(s.size());
  for(int i=(s[0]=='-'?1:0);i<s.size();++i){
    a[i] = s[i]-'0';
  }
  return a;
}
string atos(vector<int> const& a){
  string s;
  for(auto ai:a)s+=(ai+'0');
  return s;
}

string product(string const& lhs,string const& rhs){
  if(lhs=="0"||rhs=="0")return "0";
  string sign = (lhs[0]=='-'^rhs[0]=='-'?"-":"");
  auto a = stoa(lhs);
  reverse(a.begin(),a.end());
  auto b = stoa(rhs);
  reverse(b.begin(),b.end());
  int n = a.size();
  int m = b.size();
  vector<vector<int>> tmp(m,vector<int>(n+m));
  for(int i=0;i<n;++i){
    for(int j=0;j<m;++j){
      tmp[j][i+j] += a[i]*b[j]%10;
      tmp[j][i+j+1] += a[i]*b[j]/10;
    }
  }
  vector<int> res(n+m+1);
  for(int i=0;i<n+m;++i){
    for(int j=0;j<m;++j){
      res[i] += tmp[j][i];
      res[i+1] += res[i]/10;
      res[i] %= 10;
    }
  }
  while(res.size()>1&&res.back()==0)res.pop_back();
  reverse(res.begin(),res.end());
  return sign+atos(res);
}

signed main(){

  string a,b;
  cin>>a>>b;

  cout<<product(a,b)<<endl;

}


Measured memory_bytes: 10796
#include<bits/stdc++.h>
#define mod 1000000007
#define MOD(x) ((x)%mod)
#define pii pair<int,int>
#define mp(a,b) make_pair(a,b)
using namespace std;
int n;
int dp[100005][4];
int ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a;
		dp[i][2]=max(dp[i-1][1],dp[i-1][3])+b;
		dp[i][3]=max(dp[i-1][1],dp[i-1][2])+c;
	}
	ans=max(ans,dp[n][1]);
	ans=max(ans,dp[n][2]);
	ans=max(ans,dp[n][3]);
	printf("%d",ans);
	return 0;
}



Measured memory_bytes: 1792
import math
from itertools import permutations

N = int(input())
positions = [tuple(map(int, input().split(' '))) for _ in range(N)]


def distance(p1, p2):
    x1, y1 = p1
    x2, y2 = p2
    return math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)


s_distance = 0
n_routes = 0
for route in permutations(positions):
    s_distance += sum([distance(p1, p2) for p1, p2 in zip(route, route[1:])])
    n_routes += 1

print(s_distance / n_routes)


Measured memory_bytes: 3064
import math
A,B,H,M = map(int, input().split())
rate = M / 60
HM = H*5 + 5*rate
theta = abs(HM-M) * 6
if theta > 180:
    theta = 360-theta
rad = math.radians(theta)
cos = (math.cos(rad))
L = math.sqrt(A*A + B*B - 2*A*B*cos)
print("{:.19f}".format(L))

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

using namespace std;

int main() {
  
  int N; cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++) cin >> a[i];
  int Q; cin >> Q;
  vector<int> b(Q);
  for(int i=0; i<Q; i++) cin >> b[i];
  vector<bool> c(Q);
  int ans = 0;
  for(int i=0; i<N; i++) {
    for(int j=0; j<Q; j++) {
      if(a[i] == b[j] && !c[j]) c[j] = true, ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 200020
using namespace std;
int n,pos[maxn],ans;
void init(){
	ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		int ai;
		scanf("%d",&ai);
		pos[ai]=i;
	}
}
void solve(){
	int tmp=1;
	for(int i=2;i<=n;++i){
		if(pos[i]<pos[i-1]){
			ans=max(ans,tmp);
			tmp=0;
		}
		++tmp;
	}
	ans=n-max(ans,tmp);
	printf("%d\n",ans);
}
int main(){
	init();
	solve();
	return 0;
}


Measured memory_bytes: 1024
/***************************************************
 * Problem Name : A.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2020-04-19
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.rbegin(), v.rend())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define PI acos(-1.0)
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm ( ll a, ll b ) {
    return ( a / __gcd ( a, b ) ) * b;
}
/************************************ Code Start Here ******************************************************/
int main () {
    //~ __FastIO;
    cout << setprecision (10) << fixed;
    int n;
    cin >> n;
    cout << 2.0*n*PI << "\n";
    return 0;
}


Measured memory_bytes: 3784
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>

using namespace std;


int main()
{
	long long A,B,C,D;

	cin >> A >> B >> C >> D;	

	long long cnt_c = 0;
	long long cnt_d = 0;
	long long cnt_cd = 0;

	cnt_c = B / C - (A-1) / C;
	cnt_d = B / D - (A-1) / D;

	long long a = C;
	long long b = D;
	long long x = a * b;

	/* 自然数 a > b を確認・入替 */
	if(a<b){
		long long tmp = a;
		a = b;
		b = tmp;
	}
	
	/* ユークリッドの互除法 */
	long long r = a % b;
	while(r!=0){
		a = b;
		b = r;
		r = a % b;
	}

	long long lcm_cd = x / b;

	cnt_cd = B / lcm_cd - (A-1) / lcm_cd;

	long long ans = B - A + 1 - cnt_c -cnt_d + cnt_cd;


	printf("%lld",ans);

	return 0;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = [A[i] - 1 - i for i in range(N)]
B.sort()
if N % 2 == 0:
    med = int((B[int(N / 2) - 1] + B[int(N / 2)]) / 2)
else:
    med = B[int((N + 1) / 2) - 1]
S = 0
for i in range(N):
    S += abs(B[i] - med)
print(S)


Measured memory_bytes: 26180
#include<bits/stdc++.h>
using namespace std;
int main(){
	// #ifndef ONLINE_JUDGE   
 //    freopen("input.txt", "r", stdin); 
 //    freopen("output.txt", "w", stdout);    
 //    #endif 
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

   string str;
   cin>>str;
   int count=0;

   for(int i=0;i<str.size();i++)
   	count+=(int)str[i]-48;

   if(count%9==0)
   	cout<<"Yes";
   else
   	cout<<"No";




}

Measured memory_bytes: 3764
import sys

MOD = 10 ** 9 + 7

def make_table(size=10**6, p=MOD):
    fac = [None] * (size + 1)
    fac[0] = 1
    for i in range(size):
        fac[i+1] = fac[i] * (i + 1) % p
    ifac = [None] * (size + 1)
    ifac[size] = pow(fac[size], p-2, p)
    for i in range(size, 0, -1):
        ifac[i-1] = ifac[i] * i % p
    icumsum = [None] * (size + 1)
    icumsum[1] = 1
    for i in range(1, size):
        icumsum[i+1] = (icumsum[i] + fac[i] * ifac[i+1]) % p
    return fac, ifac, icumsum

fac, ifac, icumsum = make_table(10**5)

n, *x = map(int, sys.stdin.read().split())

def main():
    d = [x[i+1] - x[i] for i in range(n-1)]

    res = 0
    for i in range(n-1):
        res += d[i] * icumsum[i+1]
        res %= MOD

    return res * fac[n-1] % MOD

if __name__ == '__main__':
    ans = main()
    print(ans)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int n,m; cin >> n >> m;
    ll sum = 0;
    rep(i,m){
        int a; cin >> a;
        sum += a;
    }
    if(n - sum >= 0){
        cout << n - sum << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3580
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,a,b,c;
    cin>>n;
    long long dp[n][3];
    for(i=0;i<n;i++)
    {
        cin>>a>>b>>c;
        if(i==0)
        {
            dp[0][0]=a;
            dp[0][1]=b;
            dp[0][2]=c;
        }
        else
        {
            dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a;
            dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b;
            dp[i][2] = max(dp[i-1][0],dp[i-1][1])+c;
        }
    }
    cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2])<<endl;
    return 0;
}

Measured memory_bytes: 5948
<?php
list($n, $d, $a) = ints();
for ($i = 0; $i < $n; ++$i) list($x[], $h[]) = ints();
array_multisort($x, SORT_ASC, $h);
$cusum = array_fill(0, $n + 1, 0);
$cnt = 0;
for ($i = 0; $i < $n; ++$i) {
    $cusum[$i + 1] += $cusum[$i];
    $h[$i] -= $cusum[$i + 1];
    if ($h[$i] <= 0) continue;

    // この座標での爆発回数計算
    $tcnt = intdiv($h[$i], $a) + min(1, $h[$i] % $a);

    // 二分探索で爆発が届く最も右の座標を検索
    $ok = $i;
    $ng = $n;
    while (abs($ok - $ng) > 1) {
        $mid = intdiv($ok + $ng, 2);
        if ($x[$mid] - $x[$i] <= 2 * $d) $ok = $mid;
        else $ng = $mid;
    }
    if ($ok !== $i) {
        // imos法
        $cusum[$i + 1] += $a * $tcnt;
        if ($ok + 2 <= $n) $cusum[$ok + 2] -= $a * $tcnt;
    }

    $cnt += $tcnt;
}
echo $cnt;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 55308
// ?????¬???????????¬??????

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N;
double x[1010], y[1010];
double dp[1010][1010];

double dist(int s, int t) {
    double dfx = x[s] - x[t];
    double dfy = y[s] - y[t];
    return sqrt(dfx*dfx + dfy*dfy);
}

void solve() {
    rep(i,0,1010) rep(j,0,1010) dp[i][j] = INF;
    dp[0][0] = 0;

    queue<pii> q;
    q.push(pii(0, 0));
    while(!q.empty()) {
        pii cur = q.front(); q.pop();
        int s = max(cur.first, cur.second), t = min(cur.first, cur.second);
        if(s == N-1) continue;
        int nx = s+1;
        double d1 = dist(t, nx), d2 = dist(s, nx);
        // t -> nx
        if(dp[nx][s] > dp[s][t] + d1) {
            dp[nx][s] = dp[s][t] + d1;
            q.push(pii(nx, s));
        }
        // s -> nx;
        if(dp[nx][t] > dp[s][t] + d2) {
            dp[nx][t] = dp[s][t] + d2;
            q.push(pii(nx, t));
        }
    }
}

signed main() {
    cin >> N;
    rep(i,0,N) cin >> x[i] >> y[i];
    solve();

    double ans = INF;
    rep(i,0,N-1) {
        // printf("dp[N-1][%lld] = %.12f\n", i, dp[N-1][i]);
        chmin(ans, dp[N-1][i] + dist(N-1, i));
    }
    printf("%.12f\n", ans);
    return 0;
}

Measured memory_bytes: 11324
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int K;
    cin >> K;

    // a[i] = (a[i-1] * 10 + 7) % K
    // a[i] == 0 <=> 77...7(i個) % K == 0
    // Kで割ったあまりは {0, ..., K - 1}のK通り
    // 鳩ノ巣原理よりK回調べれば全部のあまりを網羅できる
    // K+1回目は必ず同じあまりが出てくるのでそれ以降はループする
    int sevens = 7 % K;
    for (int i = 1; i <= K; i++) {
        if (sevens == 0) {
            cout << i << '\n';
            return 0;
        }
        sevens = (sevens * 10 + 7) % K;
    }
    cout << -1 << '\n';
}


Measured memory_bytes: 3640
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 998244353
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
int n; string s; int p[1 << 19];
int dp[19][1 << 19];
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    cin>>n>>s;
    for(ll i=0;i<pow(2,n);i++)cin>>p[i];
    for(ll i=0;i<pow(2,n);i++)p[i+(1<<n)]=p[i];
    //double link
    for(ll i=0;i<pow(2,n+1);i++){
        dp[0][i]=p[i];
    }
    for(ll p=0;p<n;p++){
        for(ll left=0;left<pow(2,n+1);left++){
            int right=left+(1<<p);
            if(right>=pow(2,n+1))continue;

            int x=dp[p][left];
            int y=dp[p][right];
            if(x>y)swap(x,y);
            if(s[y-x-1]=='0')dp[p+1][left]=x;
            else dp[p+1][left]=y;
        }
    }
    for(int i=0;i<pow(2,n);i++){
        cout<<dp[n][i]<<endl;
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------



































Measured memory_bytes: 43584
#include<bits/stdc++.h>
using namespace std;
const int N = 3e3 + 10;
int dp[N][N],n,m;
char a[N],b[N];
int main(){
  scanf("%s%s",a+1,b+1);
  n = strlen(a+1), m = strlen(b+1);
  for(int i = 1; i <= n; ++i){
  	for(int j = 1; j <= m; ++j){
    	if(a[i]==b[j])dp[i][j] = 1+dp[i-1][j-1];
        else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
    }
  }
  vector<char> ans;
  int i = n, j = m;
  while(i > 0 && j > 0){
  	if(a[i] == b[j])ans.emplace_back(a[i--]),j--;
    else if(dp[i-1][j] > dp[i][j-1])i--;
    else j--;
  }
  reverse(ans.begin(),ans.end());
  for(char &i: ans)printf("%c",i);
  return 0;
}

Measured memory_bytes: 35584
N = int(input())
money = []
type = []
for i in range(N):
    m, t = input().split()
    money.append(float(m))
    type.append(t)
    
sum = 0
for i in range(N):
    if type[i] == 'JPY':
        sum += money[i]
    else :
        sum += money[i]*3.8*10**5
print(sum)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
typedef long long ll;

int main(){
    double l; cin>>l;
    double ans=0;
    double r=(10*l/3)/10.0;
    double s=l-r*2;
    ans=r*r*s;
    printf("%.20f\n",ans);

}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  n %= 10;
  if (n == 3) {
    cout << "bon\n";
  } else if (n == 0 or n == 1 or n == 6 or n == 8) {
    cout << "pon\n";
  } else {
    cout << "hon\n";
  }
}


Measured memory_bytes: 3652
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var cnt=1;
while(true){
   var W=Arr.shift()-0;
   if(W==0)break;
   var N=Arr.shift()-0;
   var dp=[];
   for(var y=0;y<N+1;y++){
      dp[y]=[];
      for(var x=0;x<=W;x++){
         dp[y][x]=0;
      }
   }
   var v=[];
   var w=[];
   for(var i=0;i<N;i++){
      var arr=(Arr.shift()).split(",").map(Number);
      v.push(arr[0]);
      w.push(arr[1]);
   }
   for(var y=0;y<N;y++){
      for(var x=0;x<=W;x++){
         if(x-w[y]>=0)dp[y+1][x]=Math.max(dp[y][x],dp[y][x-w[y]]+v[y]);
         else dp[y+1][x]=dp[y][x];
      }
   }
   console.log("Case "+cnt+":");
   cnt++;
   console.log(dp[N][W]);
   var maxValue=dp[N][W];
   while(maxValue==dp[N][W-1])W--;
   console.log(W);
}

Measured memory_bytes: 33468
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int L, R, d; cin >> L >> R >> d;
    int cnt = 0;
    for (int i = L; i <= R; i++) {
        if (i % d == 0) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int t, n, m, k, a1[110],a2[110], q, l, r;

int32_t main(){
INIT
cin>>n; for(int i=1; i<=n; i++){cin>>a1[i]>>a2[i];}


    for(int j=1; j<=(n-2); j++){
        if( ( (a1[j]==a2[j]) ) && ( (a1[j+1]==a2[j+1]) ) && ( (a1[j+2]==a2[j+2]) ) ){
            cout<<"Yes"; return 0;
        }
    }

cout<<"No";

return 0;
}





Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int maxn = 2010;
const int oo = 1e9;

int n,a[2*maxn],c[2*maxn],f[maxn][maxn],num[3][maxn][2*maxn],pos[3][maxn];

int main() {
    //freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for (int i=1;i<=2*n;i++) {
        char colo;
        cin>>colo>>a[i];
        c[i] = (colo=='B');
        pos[c[i]][a[i]]=i;
    }

    for (int col=0;col<=1;col++) {
        for (int i=0;i<=n;i++)
            for (int j=1;j<=2*n;j++)
                num[col][i][j] += num[col][i][j-1] + (c[j]==col && a[j]>i);
    }
    /**
    for (int i=1;i<=n;i++) {
        cout<<i<<endl;
        for (int j=1;j<=2*n;j++) cout<<num[0][i][j]<<" ";
        cout<<endl;
        for (int j=1;j<=2*n;j++) cout<<num[1][i][j]<<" ";
        cout<<endl;
    }
    */
    for (int i=0;i<=n;i++)
        for (int j=0;j<=n;j++) f[i][j] = oo;
    f[0][0]=0;
    for (int i=0;i<=n;i++)
        for (int j=0;j<=n;j++) {
            if (i>0) {
                int idB = pos[1][i];
                f[i][j] = min(f[i][j],f[i-1][j] + num[1][i][idB] + num[0][j][idB]);
            }
            if (j>0) {
                int idW = pos[0][j];
                f[i][j] = min(f[i][j],f[i][j-1] + num[0][j][idW] + num[1][i][idW]);
            }
        }
    //for (int i=0;i<=n;i++)
       // for (int j=0;j<=n;j++) cout<<i<<" "<<j<<" "<<f[i][j]<<endl;
    cout<<f[n][n];

}



Measured memory_bytes: 80000
#include<stdio.h>
int main(void){
    int a,b,d,e,f,g,h,i,j,k,l,n,o;
    o=0;
    scanf("%d %d",&a,&b);
    int c[a][b];
    int m[b];
    for(d=0; d<a; d++){
        for(e=0; e<b; e++){
            scanf("%d",&c[d][e]);
        }
    }
    for(f=0; f<a; f++){
        i=0;
        for(g=0; g<b; g++){
         printf("%d ",c[f][g]);
        }
        for(h=0; h<b; h++){
            i=i+c[f][h];
        }
        printf("%d\n", i);
    }
    for(j=o; j<b; j++){
        k=0;
    for(l=0; l<a; l++){
        k=k+c[l][j];
    }
    printf("%d ", k);
    m[j]=k;
    }
    for(n=0; n<b; n++){
        o=o+m[n];
    }
    printf("%d\n", o);
    
    return 0;
}



Measured memory_bytes: 2084
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

        Console.WriteLine((a[0] + a[1] == a[2] || a[0] + a[2] == a[1] || a[1] + a[2] == a[0]) ? "Yes" : "No");
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int a, b;
    cin>>a>>b;
    int ans = 0, tap = 1;

    while (1) {
        if (tap >= b) {
            cout<<ans<<endl;
            return 0;
        }

        tap += a - 1;
        ans++;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
int a[110];
bool w[100010];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline int find(int n) {
    cout<<n<<endl;
    fflush(stdout);
    char s[10];
cin>>s;
    if(s[0]=='V') exit(0);
    else return s[0]=='M';
}
inline bool check(int l,int r) {
    return ((r-l+1)&1)^w[l]^w[r];
}
int main() {
    int n;
    cin>>n;
    int l=0,r=n/2;
    w[l]=find(l),w[r]=find(r);
    if(check(l,r)) l=r,r=n-1,w[r]=find(r);
    while(1) {
	int mid=(l+r)>>1;
	w[mid]=find(mid);
	if(check(l,mid)) l=mid;
	else r=mid;
    }
    return 0;
}

Measured memory_bytes: 852
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  ve<int> A(3);
  rep(i, 3){
    ci(A.at(i));
  }
  sort all(A);
  A.at(0) == 5 && A.at(1) == 5 && A.at(2) == 7 ? co("YES") : co("NO");
}

Measured memory_bytes: 256
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String ret = "APPROVED";
    for (int i = 0; i < N; i++) {
      int t = sc.nextInt();
      if (t%2==0) {
        if (t%3 != 0 && t%5!=0) {
          ret = "DENIED";
          break;
        }
      }
    }
    System.out.println(ret);
  }
}

Measured memory_bytes: 23764
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<sstream>
#include<numeric>
#include<iostream>
#include<algorithm>
#include<functional>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> Vi;
typedef pair<int,int> pii;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=200000*4+19;
const int p=924844033;

int Pow(int a,int b){
	int res=1;
	for (;b;b>>=1,a=1ll*a*a%p) if (b&1) res=1ll*res*a%p;
	return res;
}

int W[2][N],rev[N],c;
void Prepare(int n){
	int pw=1,pi=1,w0=Pow(5,(p-1)/n),i0=Pow(w0,p-2);
	For(i,0,n){
		W[0][i]=pw,pw=1ll*pw*w0%p;
		W[1][i]=pi,pi=1ll*pi*i0%p;
		rev[i]=0;
		for (int x=i,&y=rev[i],k=1;k<n;k<<=1,x>>=1) y=(y<<1)|(x&1);
	}
}
void FFT(int *A,int n,int f){
	For(i,0,n) if (i<rev[i]) swap(A[i],A[rev[i]]);
	for (int i=1;i<n;i<<=1)
		for (int j=0,t=n/(i<<1);j<n;j+=i<<1)
			for (int k=j,l=0;k<j+i;k++,l+=t){
				int x=A[k],y=1ll*W[f][l]*A[k+i]%p;
				A[k]=(x+y)%p;A[k+i]=(x-y+p)%p;
			}
	if (f){
		int tmp=Pow(n,p-2);
		For(i,0,n) A[i]=1ll*A[i]*tmp%p;
	}
}

struct Edge{
	int y,nxt;
} E[N*2];
int fac[N],inv[N],las[N],sz[N],A[N],F[N],B[N];
int n,cnt;

int C(int n,int m){
	if (n<m) return 0;
	return 1ll*fac[n]*inv[m]%p*inv[n-m]%p;
}
void Link(int x,int y){
	E[cnt]=(Edge){y,las[x]};las[x]=cnt++;
	E[cnt]=(Edge){x,las[y]};las[y]=cnt++;
}
void dfs(int x,int fa){
	sz[x]=1;
	for (int i=las[x],y;~i;i=E[i].nxt)
		if ((y=E[i].y)!=fa){
			dfs(y,x);
			sz[x]+=sz[y];
			A[sz[y]]++;
		}
	A[n-sz[x]]++;
}

int main(){
	memset(las,-1,sizeof(las));
	fac[0]=1;
	For(i,1,N) fac[i]=1ll*fac[i-1]*i%p;
	inv[N-1]=Pow(fac[N-1],p-2);
	for (int i=N-1;i;i--) inv[i-1]=1ll*inv[i]*i%p;
	n=IN();
	For(i,1,n) Link(IN(),IN());
	dfs(1,-1);
	For(i,1,n+1) A[i]=1ll*A[i]*fac[i]%p;
	For(i,0,n) B[n-i]=inv[i];
	
	for (c=1;c<=n;c<<=1);c<<=1;
	Prepare(c);
	FFT(A,c,0);FFT(B,c,0);
	For(i,0,c) A[i]=1ll*A[i]*B[i]%p;
	FFT(A,c,1);
	
	For(k,1,n+1){
		F[k]=(1ll*(p-1)*inv[k]%p*A[k+n])%p;
		F[k]=(F[k]+1ll*C(n,k)*k+1ll*C(n-1,k)*n)%p;
	}
	For(i,1,n+1) printf("%d\n",F[i]);
}

Measured memory_bytes: 42880
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int l = sc.nextInt();
      String[] s = new String[n];
      for(int i = 0;i < n;i++)s[i]=sc.next();
      Arrays.sort(s);
      String res  = "";
      for(int i = 0;i < n;i++)res += s[i];
      System.out.println(res);
    }
}

Measured memory_bytes: 23124