akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;

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

    ll n,m,x;
    cin>>n>>m>>x;
    ll c[n];
    ll ar[n][m];
    for(ll i=0;i<n;++i){
        cin>>c[i];
        for(ll j=0;j<m;++j){
            cin>>ar[i][j];
        }
    }
    ll ans=INT_MAX;
    for(ll mask=0;mask<(1<<n);++mask)
    {
        ll level[m]={0};
        ll cost=0;
        for(ll i=0;i<n;++i){
            if((mask&(1<<i))!=0){
                cost+=c[i];
                for(ll j=0;j<m;++j){
                    level[j]+=ar[i][j];
                }
            }
        }
        int f=1;
        for(ll j=0;j<m;++j){
            if(level[j]<x){f=0;}
        }
        if(f){
            ans=min(ans,cost);
        }
    }
    if(ans==INT_MAX){
        ans=-1;
    }
    cout<<ans;

    return (0);
}


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

int n;
double q=0;
cin >> n;
vector<int> x(n);

for(int i = 0;i < n;i++)cin >> x.at(i);
for(int i = 0;i < n;i++)q = q+x.at(i);

int ans = 0;
q = q/n;
int v = round(q);



for(int i=0;i<n;i++){
    ans += (x.at(i) - v)*(x.at(i) - v);
}

cout << ans << endl;

    return 0;
}

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

string s1,s2,s3;

int main(){

cin>>s1>>s2>>s3;

char S1=toupper(s1[0]),S2=toupper(s2[0]),S3=toupper(s3[0]);
string S=""; 
S+=S1;
S+=S2;
S+=S3;

cout<<S<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int area = a * b;
		int length = 2 * a + 2 * b;
		System.out.println(area + " " + length);
	}
}

Measured memory_bytes: 25844
#include <iostream>
#include <list>
#include <string>
using namespace std;
int main(){

  int n,x,i;
  list <int> a;
  list<int>::iterator it;
  string com;

  cin>>n;
  for(i=0;i<n;i++){
    cin>>com;
    if(com=="deleteFirst") a.pop_front();
    else if(com=="deleteLast") a.pop_back();
    else{
      cin>>x;
      if(com=="insert") a.push_front(x);
      else for(it=a.begin();it!=a.end();it++) if(*it==x){
            a.erase(it);
            break;
          }
    }
  }
  i=0;
  for(it=a.begin();it!=a.end();it++){
    if(i++) cout<<" ";
    cout<<*it;
  }
  cout<<endl;

  return 0;

}


Measured memory_bytes: 34400
#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <cstring>
#include <algorithm>
#include <set>
 
using namespace std;
 
typedef long long int64;
typedef pair<int, int> ii;
 
const int mod = 1e9 + 7;
 
class Solution {
private:
    
public:
    int64 solve(int n, string& s) {
        // int64 a = 0, b = 0, c = 0, ret = 1;
        // for(const auto& cc : s) {
        //     if(cc == 'R') ++a;
        //     else if(cc == 'G') ++b;
        //     else if(cc == 'B') ++c;
        // }
        // ret = a * b * c;
        // cout << "multiply: " << ret << endl;
        int64 ret = n > 0;
        // int64 ret2 = 1;
        unordered_map<char, int64> cs;
        for(const auto& cc : s) {
            ++cs[cc];
        }
        ret = cs['R'] * cs['G'] * cs['B'];
        //for(const auto&[k, v] : cs) ret *= v;
        // cout << "dic:      " << ret2 << endl;
        
        for(int i = 0; i < n; ++i) {
            char& a = s[i];
            for(int j = i + 1; j < n; ++j) {
                char& b = s[j];
                if(a == b) continue;
                int cIdx = 2 * j - i;
                if(cIdx < n && s[cIdx] != a && s[cIdx] != b) --ret;
            }
        }
        return ret;
    }
};
 
int main() {
    int n;
    string s;
    cin >> n >> s;
    Solution sol;
    auto ret = sol.solve(n, s);
    cout << ret << endl;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int w,h;
    cin >> w >> h;
    if(w==0) return 0;
    vector<string> f(h);
    for(int i=0;i<h;i++){
      cin >> f[i];
    }
    vector<vector<string>> dp(h+1,vector<string>(w+1,""));
    string s="";
    for(int i=1;i<=h;i++){
      for(int j=1;j<=w;j++){
        if('0'<=f[i-1][j-1]&&f[i-1][j-1]<='9'){
          if(dp[i-1][j].length()>dp[i][j-1].length()){
            dp[i][j]=dp[i-1][j]+string(1,f[i-1][j-1]);
          }else if(dp[i-1][j].length()<dp[i][j-1].length()){
            dp[i][j]=dp[i][j-1]+string(1,f[i-1][j-1]);
          }else{
            if(f[i-1][j-1]=='0'&&dp[i-1][j]=="") continue;
            if(dp[i-1][j]>dp[i][j-1]){
              dp[i][j]=dp[i-1][j]+string(1,f[i-1][j-1]);
            }else{
              dp[i][j]=dp[i][j-1]+string(1,f[i-1][j-1]);
            }
          }
        }
        if(dp[i][j].length()>s.length()||(dp[i][j].length()==s.length()&&dp[i][j]>s)){
          s=dp[i][j];
        }
      }
    }
    cout << s << endl;
  }
  return 0;
}



Measured memory_bytes: 3276
def frog(list):
    n=len(list)
    dp = [0 for i in range(n)]
    dp[0]=0
    dp[1]=abs(list[1]-list[0]);
    for i in range(2,n):
        dp[i]=min((dp[i-1]+abs(list[i]-list[i-1])),dp[i-2]+abs(list[i]-list[i-2]))

    return dp[n-1]








n=int(input())
L=list(map(int,input().split()))
x=frog(L)
print(x)



Measured memory_bytes: 13928
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	arr := scanArrayInt()
	a, b := float64(arr[0]), float64(arr[1])
	fmt.Println(round((a + b) / 2))
}
func round(f float64) float64 {
	return math.Floor(f + .5)
}
func scanArrayInt() []int {
	var ret = []int{}
	stdin.Scan()
	for _, s := range strings.Split(stdin.Text(), " ") {
		i, _ := strconv.Atoi(s)
		ret = append(ret, i)
	}
	return ret
}



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

int n;
vector<vector<int>> edge;
int dfs(int p){
    if(edge[p].size()==0){
        return 0;
    }
    else{
        int v[edge[p].size()];
        for(int i=0; i<edge[p].size(); i++){
            v[i] = dfs(edge[p][i]);
        }
        sort(v,v+edge[p].size(),greater<int>());
        int ret = -1;
        for(int i=0; i<edge[p].size(); i++){
            ret = max(ret,v[i]+i+1);
        }
        return ret;
    }
}

int main(){
    cin >> n; 
    int a[n];
    for(int i=1; i<n; i++){
        cin >> a[i];
        a[i]--;
    }
    edge.resize(n);
    for(int i=1; i<n; i++){
        edge[a[i]].push_back(i);
    }
    cout << dfs(0) << endl;
    return 0;
}


Measured memory_bytes: 15488
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = Integer.parseInt(scanner.next());
        int B = Integer.parseInt(scanner.next());
        int C = Integer.parseInt(scanner.next());

        scanner.close();
        
        if (C >= A && C<= B) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

using namespace std;

#define ll long long 
#define Fastest ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"


int main()
{
	int t;
	string ch;
	map<string, ll>m;
	
	cin >> t;
	
	while(t--)
	{
		cin >> ch;
		sort(ch.begin(), ch.end());
		m[ch]++;
	}

    ll sum = 0;

    for(auto it : m)
    {
		//cout << it.first << " " << it.second << endl;
		sum += ((it.second*(it.second-1)) /2);
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 11136
#include<stdio.h>
#define MAX 100000

int parent (int i) {return i / 2;}
int left (int i) {return 2 * i;}
int right (int i) {return 2 * i +1;}

int main(void){
  int n, i, A[MAX+1];

  scanf("%d", &n);
  for(i = 1; i <= n; i++) scanf("%d", &A[i]);

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ", i, A[i]);
    if(parent(i)>=1) printf("parent key = %d, ", A[parent(i)]);
    if(left(i)<=n) printf("left key = %d, ", A[left(i)]);
    if(right(i)<=n) printf("right key = %d, ", A[right(i)]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2052
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;

#define lim 100005

ll a[lim];

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n,ans=1;
    sfl(n);
    FOR(i,n){
        sfl(a[i]);
    }
    sort(a+1,a+n+1);
    for(ll i=1;i<=n;i++){
        if(a[i]==0){
            printf("0\n");
            return 0;
        }
        else{
            if(ans<= 1000000000000000000/a[i]){
                ans = ans * a[i];
            }
            else{
                ans = INF;
            }
        }
    }

    if( ans <= 1000000000000000000 ){
        pfl(ans);
    }
    else{
        printminusone;
    }
    return 0;
}

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

int main() {

    int n, k;
    int h[200000];
    cin >> n >> k;
    for (int i = 0;i<n;++i) {
        cin >> h[i];
    }

    sort(h,h + n,greater<int>());

    long ans = 0;
    for (int i = 0;i<n;++i) {
        if ( k > 0 ) {
            --k;
        }
        else {
            ans += h[i];
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1656
import java.util.Scanner;

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

        int[] length = new int[n];
        for (int i = 0; i < n; ++i) {
            length[i] = scanner.nextInt();
        }
        int res = dfs(length, 0, a, b, c, 0, 0, 0);
        System.out.println(res);

    }

    static int dfs(int [] length, int current, int a, int b, int c, int sumA, int sumB, int sumC) {
        if (current == length.length) {
            if (sumA != 0 && sumB != 0 && sumC != 0) {
                return Math.abs(a - sumA) + Math.abs(b - sumB) + Math.abs(c - sumC) - 30;
            }
            return 1000000;
        }
        int res1 = dfs(length, current + 1, a, b, c, sumA, sumB, sumC);
        int res2 = dfs(length, current + 1, a, b ,c,sumA + length[current], sumB, sumC) + 10;
        int res3 = dfs(length, current + 1, a, b, c, sumA,sumB + length[current], sumC) + 10;
        int res4 = dfs(length, current + 1, a, b, c, sumA, sumB, sumC + length[current]) + 10;
        return Math.min(Math.min(res1, res2), Math.min(res3, res4));
    }
}


Measured memory_bytes: 23636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ITP1
{
    class ITP1_1_B
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            Console.WriteLine(Math.Pow(x, 3));
        }
    }
}



Measured memory_bytes: 15960
#include<bits/stdc++.h>
#define PB push_back
#define SZ(x) (int)x.size()
#define MP make_pair
#define F first
#define S second
using namespace std;

typedef pair<int,int> pii;
typedef pair<pii,int> piii;

const int maxn=1e5+5;

struct Edge {int from,to,type;};
map<int,set<int> > G[maxn];

map<int,int> d[maxn];
int done[maxn],Mind[maxn];
int n;
const int INF=0x3f3f3f3f;
int dijkstra(const int& st,const int& ed)
{
    priority_queue<piii,vector<piii>,greater<piii> > pq;
    for(int i=0;i<n;i++) d[i].clear(),done[i]=0,Mind[i]=INF;
    pq.push(MP(MP(0,st),-1));
    Mind[st]=0;
    while(!pq.empty())
    {
        piii x=pq.top();pq.pop();
        int now=x.F.S,lasttype=x.S,noww=x.F.F;
        for(const int& to:G[now][lasttype])
        {
            int type=lasttype;
                if(Mind[to]+1>noww+(lasttype==type?0:1) &&
                    (!(d[to].count(type)) || d[to][type]>noww+(lasttype == type?0:1)))
                {
                    d[to][type]=noww+(lasttype == type?0:1);
                    Mind[to]=min(Mind[to],noww+(lasttype== type?0:1));
                    pq.push(MP(MP(noww+(lasttype == type?0:1),to),type));
                }
                if(type==lasttype) G[now][type].erase(to),G[to][type].erase(now);
        }
        if(done[now]) continue;
        done[now]=1;

        for(const auto& it:G[now])
        {
            int type=it.F;
            for(const int& to:it.S)
            {
                if(Mind[to]+1>noww+(lasttype==type?0:1) &&
                    (!(d[to].count(type)) || d[to][type]>noww+(lasttype == type?0:1)))
                {
                    d[to][type]=noww+(lasttype == type?0:1);
                    Mind[to]=min(Mind[to],noww+(lasttype== type?0:1));
                    pq.push(MP(MP(noww+(lasttype == type?0:1),to),type));
                }
                if(type==lasttype) G[now][type].erase(to),G[to][type].erase(now);
            }
        }
    }
    int ans=INF;
    for(auto&& it:d[ed]) ans=min(ans,it.S);
    return ans == INF ? -1 : ans;
}
int main()
{
    int m;
    scanf("%d%d",&n,&m);
    for(int i=0,a,b,c;i<m;i++)
    {
        scanf("%d%d%d",&a,&b,&c);a--,b--;
        G[a][c].insert(b);
        G[b][c].insert(a);
    }
    printf("%d\n",dijkstra(0,n-1));
}



Measured memory_bytes: 71988
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <iomanip>


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

using namespace std;

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

  cout << N * N*N << endl;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    cout << fixed << setprecision(15);
    ll X;
    cin >> X;
    ll ans = 0;
    while(X >= 500){
        X -= 500;
        ans += 1000;
    }
    while(X >= 5){
        X -= 5;
        ans += 5;
    }
    cout << ans << endl;
    return 0;
}

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

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

constexpr ll N_MAX = 100000;
constexpr ll A_I_MAX = 1000000000;
constexpr ll B_I_MAX = 1000000000;

ll N;


signed main() {
	cin>>N;
	vector<ll> A(N+1,0);
	vector<ll> B(N,0);
	rep(i, N+1)cin>>A[i];
	rep(i, N) cin>>B[i];

	ll ans = 0;
	ll t;
	rep(i,N){

		t=min(A[i],B[i]);
		ans+=t;
		A[i]-=t;
		B[i]-=t;

		t=min(A[i+1],B[i]);
		ans+=t;
		A[i+1]-=t;
		B[i]-=t;
	}


	cout<<ans<<endl;




	return 0;
}


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

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, long.Parse);
         line = Console.ReadLine().Trim().Split(' ');
        var b = Array.ConvertAll(line, long.Parse);
        if (a.Sum() < b.Sum()) { Console.WriteLine(-1); goto exit; }
        var c = new List<long>();
        var b1 = 0L;  var b1c = 0;
        for (int i = 0; i < n; i++)
        {
            var w = a[i] - b[i];
            if (w < 0) { b1c++; b1 += -w; }
            else c.Add(w);
        }
        if (b1c == 0) { Console.WriteLine(0); goto exit; }
        if (b1 > c.Sum()) { Console.WriteLine(-1); goto exit; }
        var c1 = c.OrderByDescending(x => x).ToArray();
        var ans = getAns(c1, b1, n);
        Console.WriteLine(ans + b1c);
        exit:;
    }
    static int getAns (long[] c , long a , int n)
    {
        for (int i = 0; i < c.Length; i++)
        {
            a -= c[i];
            if (a <= 0) return i + 1;
        }
        return -1;
    }
}

Measured memory_bytes: 37980
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut av = vec![0usize; n];
    for i in 0..n - 1 {
        av[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    av[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');
    let mut bv = vec![0i32; n];
    for i in 0..n - 1 {
        bv[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    bv[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');
    let mut cv = vec![0i32; n - 1];
    for i in 0..n - 2 {
        cv[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    cv[n - 2] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut ans = 0;
    for i in 0..n - 1 {
        let curr = av[i] - 1;
        let next = av[i + 1] - 1;
        ans += bv[curr] + if next == curr + 1 { cv[curr] } else { 0 };
    }
    ans += bv[av[n - 1] - 1];
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main() {
    int h,w;
    cin>>h>>w;
    vector<string>s(h);
    for(int i=0;i<h;i++){
        cin>>s.at(i);
    }
    // cout<<"AAA"<<endl;
    vector<vector<char> >ans(h, vector<char>(w));
    vector<int>dx={1,1,1,0,0,-1,-1,-1};
    vector<int>dy={1,0,-1,1,-1,1,0,-1};
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s.at(i).at(j)=='#'){
                ans.at(i).at(j)='#';
            }
            else{
                int cnt=0;
                for(int k=0;k<8;k++){
                    if(i+dy.at(k)>=0 and i+dy.at(k)<h and j+dx.at(k)>=0 and j+dx.at(k)<w){
                        if(s.at(i+dy.at(k)).at(j+dx.at(k))=='#'){
                            cnt++;
                        }
                    }
                }
                ans.at(i).at(j)=cnt+'0';
            }
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<ans.at(i).at(j);
        }
        cout<<endl;
    }





    return 0;
}


Measured memory_bytes: 256
import math

def resolve():
    a,b,x=map(int,input().split())
    xx=x/a
    
    if x==b*a**2:
        print(0)
    elif xx<a*b/2:
        ts=b**2/(xx)/2
        print(math.degrees(math.atan(ts)))
        
    elif xx==a*b/2:
        print(45)
    else:
        ts=a**2/(a*b-xx)/2
        print(90-math.degrees(math.atan(ts)))
if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3064
//Program.cpp
//Author : Aaryan Srivastava 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#define pb push_back
#define popb pop_back
#define ull unsigned long long  
#define beg begin
#define mp make_pair
#define pii pair<int, int>
#define piii pair<pii,int>
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second 
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using ll = long long;
#define int ll
const int N = 2*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace std;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#define AaryanS 0 
#endif


void solve()
{
    int n,k ;
    string s ;
    cin >> n >> k >> s ;
    rep(i,n){
        if(i == k-1 && s[i] <= 'Z' && s[i] >= 'A') s[i] = s[i] - 'A' + 'a' ;
    }
    cout << s ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
int main(){
	string a;
	int b[3];
	for(int i=0;i<3;i++){
		cin>>a[i];
		if(a[i]=='a'){
			b[0]=1;
		} 
		if(a[i]=='b'){
			b[1]=1;
		}
		if(a[i]=='c'){
			b[2]=1;
		}
	}
	for(int i=0;i<3;i++){
		if(b[i]!=1){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int jiku_x,jiku_y;
	int kouji_x,kouji_y;
	int kouji;
	int cut_i,cut_j;
	int tuugakuro[17][17];

	while(1){
		scanf("%d%d",&jiku_x,&jiku_y);

		if((jiku_x == 0) && (jiku_y==0)){
			break;
		}

		for(cut_i=0;cut_i<jiku_x+1;cut_i++){//初期化
			for(cut_j=0;cut_j<jiku_y+1;cut_j++){
				tuugakuro[cut_i][cut_j]=1; 
			}
		}
		scanf("%d",&kouji);
		
		for(cut_i=0;cut_i<kouji;cut_i++){//工事中のマスを0に
			scanf("%d%d",&kouji_x,&kouji_y);
			tuugakuro[kouji_x][kouji_y]=0;
		}

		for(cut_i=2;cut_i<jiku_x+1;cut_i++){//ｘ軸部分
			if(tuugakuro[cut_i][1] != 0){
				tuugakuro[cut_i][1]=tuugakuro[cut_i -1][1];
			}
		}

		for(cut_i=2;cut_i<jiku_y+1;cut_i++){//ｙ軸部分
			if(tuugakuro[1][cut_i] != 0){
				tuugakuro[1][cut_i]=tuugakuro[1][cut_i -1];
			}
		}

		for(cut_i=2;cut_i<jiku_x+1;cut_i++){
			for(cut_j=2;cut_j<jiku_y+1;cut_j++){
				if(tuugakuro[cut_i][cut_j] != 0){
					tuugakuro[cut_i][cut_j]=tuugakuro[cut_i -1][cut_j]+tuugakuro[cut_i][cut_j -1];
				}
			}
		}

		printf("%d\n",tuugakuro[jiku_x][jiku_y]);
	}
}

Measured memory_bytes: 1028
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

bool Check(string a, string b) {
	bool ret = true;
	for (int i = 7; i >= 0 && a[i] != '*'; i--) {
		if (a[i] != b[i])ret = false;
	}
	return ret;
}

int main() {
	int n, m;
	while (cin >> n >> m && (n || m)) {
		VS n2(n), b(m); VI m2(n);
		rep(i, n)cin >> n2[i] >> m2[i];
		rep(i, m)cin >> b[i];

		int ans = 0;
		rep(i, n) {
			rep(j, m)ans += Check(n2[i], b[j])*m2[i];
		}
		Cout(ans);
	}
}


Measured memory_bytes: 3172
h, n = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]

dp = [10**18] * (h + 1 + 10 ** 5)
dp[h + 10 ** 5] = 0
for i in range(n):
    a, b = info[i]
    for j in range(h + 1 + 10 ** 5)[::-1]:
        if j - a >= 0:
            dp[j - a] = min(dp[j] + b, dp[j - a])
print(min(dp[0:10**5 + 1]))


Measured memory_bytes: 44404
N=int(input())
fn=N
li=[0]*(10**6+100)
flag=False
if N==1:
  print(0)
  exit()
for i in range(2,int(N**0.5)+1):
  while N%i==0:
    flag=True
    N/=i
    li[i]+=1
if flag==False:
  print(1)
  exit()

ans=0
if N>fn**0.5:
  ans+=1
  
for count in li:
  use=1
  while count-use>=0:
    ans+=1
    count-=use
    use+=1
print(ans)
    
    

Measured memory_bytes: 72300
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>     // pow
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

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

// int binary_search(int key) {
//     int ng = -1;
//     int ok = (int)a.size();
//     while(abs(ok - ng) > 1) {
//         int mid = (ok + ng) / 2;
//         if(isOK(mid, key))
//             ok = mid;
//         else
//             ng = mid;
//     }
//     return ok;
// }

// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W
// int MOD = 1000000007;

int main() {
    int N;
    string S, ans = "No";
    cin >> N >> S;
    if(N % 2 == 1) {
    } else {
        if(S.substr(0, N / 2) == S.substr(N / 2, N/2)) {
            ans = "Yes";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,i,ans=0,on=0,zn=0;
	char s[100001];
	scanf("%s",s);
	for(i=0;s[i]!=0;i++){
		if(s[i]=='1')on++;
		else zn++;
		if(on>0&&zn>0){
			int tmp=(on<zn?on:zn);
			ans+=tmp*2;
			on-=tmp;
			zn-=tmp;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
a = [list(map(int,input().split())) for i in range(3)]

if a[0][0]+a[1][1]+a[2][2] == a[0][2]+a[1][1]+a[2][0] == a[0][1]+a[1][0]+a[2][2] == a[0][1]+a[1][2]+a[2][0]==a[0][2]+a[1][0]+a[2][1] == a[0][0]+a[1][2]+a[2][1]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

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

    if(a >= 3200) {
        cout<<s<<endl;
    } else {
        cout<<"red"<<endl;
    }

    return 0;
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    if (N > 999)
    {
        cout << "ABD" << endl;
    }
    else
    {
        cout << "ABC" << endl;
    }
    return 0;
}

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

public class Program
{
	public static void Main()
	{
		var indexer = new List<Pair>();
		while (true)
		{
			string line = Console.ReadLine();
			if (string.IsNullOrEmpty(line))
			{
				break;
			}
			string[] input = line.Split();
			string word = input[0];
			int page = int.Parse(input[1]);
			indexer.Add(new Pair(word, page));
		}
		var output = indexer.OrderBy(elem => elem.Word)
			.ThenBy(elem => elem.Page);
		var temp = new Pair("", -1);
		foreach (var elem in output)
		{
			if (elem.Word == temp.Word)
			{
				Console.Write(" {0}", elem.Page);
			}
			else
			{
				if (!string.IsNullOrEmpty(temp.Word))
				{
					Console.WriteLine();
				}
				Console.WriteLine(elem.Word);
				Console.Write(elem.Page);
			}
			temp = elem;
		}
		Console.WriteLine();
	}
}

public class Pair
{
	public string Word;
	public int Page;
	public Pair(string word, int page)
	{
		this.Word = word;
		this.Page = page;
	}
}

Measured memory_bytes: 10636
import java.util.Scanner;

public class Main {
    public static void main (String[] args){
        try(Scanner sc = new Scanner(System.in)){
            int[] counts = new int[128];
            while(sc.hasNext()){
                String str = sc.nextLine().toLowerCase();

                for(int i=0;i<str.length();i++){
                    counts[str.charAt(i)]++;
                }
            }
            for(char ch = 'a'; ch<= 'z'; ch++){
                    System.out.println(ch+" : "+counts[ch]);
            }
        }
    }    
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int a, b, q;
  cin >> a >> b >> q;
  vector<ll> s(a), t(b);
  rep(i, a) cin >> s[i];
  rep(i, b) cin >> t[i];
  s.insert(s.begin(), -INF64);
  s.push_back(INF64);
  t.insert(t.begin(), -INF64);
  t.push_back(INF64);

  vector<ll> ans(q);
  rep(i, q) {
    ll x; cin >> x;
    auto it1 = upper_bound(ALL(s), x);
    auto it2 = upper_bound(ALL(t), x);
    ll sr = *it1, tr = *it2;
    --it1; --it2;
    ll sl = *it1, tl = *it2;
    ll res = INF64;
    chmin(res, max(sr, tr)-x);
    chmin(res, x-min(sl, tl));
    chmin(res, 2*sr-x-tl);
    chmin(res, 2*tr-x-sl);
    chmin(res, x-sl+tr-sl);
    chmin(res, x-tl+sr-tl);
    ans[i] = res;
  }
  for(auto x : ans) cout << x << endl;
}


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

int main( void )
{
  int N;
  cin >> N;
  vector<int> A( N );

  for( int i = 0; i < N; i++ )
    cin >> A.at( i );

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

  cout << abs( A.at( N - 1 ) - A.at( 0 ) ) << endl;
}

Measured memory_bytes: 3508
main :: IO()
main = do
    str <- getLine
    putStrLn $ if (getsolve str) then "Yes" else "No"
    
    
getsolve :: String -> Bool
getsolve str
    | comp12 && comp34 && not comp23 = True
    | comp13 && comp24 && not comp12 = True
    | comp14 && comp23 && not comp12 = True
    | otherwise						 = False
    where comp12 = str!!0 == str!!1
          comp13 = str!!0 == str!!2
          comp14 = str!!0 == str!!3
          comp23 = str!!1 == str!!2
          comp24 = str!!1 == str!!3
          comp34 = str!!2 == str!!3


Measured memory_bytes: 380
import java.util.Scanner;

public class Main {

    public static void main (String[] args) {
        boolean[][] mark = {{true, false, false},{false, true, false}, {false, false, true}};
        StringBuilder sb = new StringBuilder();
        Scanner sc = new Scanner(System.in);
        char[] chars;
        for (int i = 0; i < 3; i++) {
            chars = sc.next().toCharArray();
            for (int j = 0; j < 3; j++) {
                if (mark[i][j]) {
                    sb.append(chars[j]);
                }
            }
        }
        System.out.println(sb.toString());
    }
    
}


Measured memory_bytes: 23124
#include <cstdio>
#include <algorithm>

using namespace std;

int n;
int x[24], y[24], r[24], c[24];

char dp[(1 << 24) + 1];

bool intersect(int i, int j)
{
    return (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) < (r[i] + r[j]) * (r[i] + r[j]);
}

bool is_select(int i, int s)
{
    for (int j = 0; j < i; ++j)
        if (!(s & (1 << j)))
            if (intersect(i, j))
                return false;
    return true;
}

int rec(int s)
{
    if (s == (1 << n) - 1)
        return 0;

    if (dp[s] != -1)
        return dp[s];

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (s & (1 << i))
            continue;
        if (!is_select(i, s))
            continue;

        for (int j = i + 1; j < n; ++j) {
            if (s & (1 << j))
                continue;
            if (!is_select(j, s))
                continue;

            if (c[i] != c[j])
                continue;

            ans = max(ans, rec(s | (1 << i) | (1 << j)) + 2);
        }
    }
    return dp[s] = ans;
}

int main()
{
    for (;;) {
        scanf("%d", &n);
        if (n == 0)
            break;

        for (int i = 0; i < n; ++i)
            scanf("%d %d %d %d", &x[i], &y[i], &r[i], &c[i]);

        fill(dp, dp + (1 << 24) + 1, -1);
        int ans = rec(0);
        printf("%d\n", ans);

    }

    return 0;
}

Measured memory_bytes: 17412
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  std::vector<int> A(3);
  cin >> A[0] >> A[1] >> A[2];
  sort(A.begin(), A.end());
  cout << A[2] - A[0] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int D1,D2;
int get(int x,int y){return x*(n*2)+y;}
struct data{
    int to,nxt;
};
struct Graph{
    data mp[20000200];
    int head[500500],cnt;
    void link(int x,int y)
    {
        mp[++cnt].to=y;
        mp[cnt].nxt=head[x];
        head[x]=cnt;
    }
    int fl[2020][2],tf;
    int c[500500];
    void dfs(int x,int d)
    {
        c[x]=d;
        for(int i=head[x];i;i=mp[i].nxt)
            if(c[mp[i].to]==-1)
                dfs(mp[i].to,d^1);
    }
    void build(int D)
    {
        for(int i=0,j;i*i<=D;++i)
        {
            j=sqrt(D-i*i);
            if(i*i+j*j!=D)continue;
            fl[++tf][0]=i;fl[tf][1]=j;
            fl[++tf][0]=i;fl[tf][1]=-j;
            fl[++tf][0]=-i;fl[tf][1]=j;
            fl[++tf][0]=-i;fl[tf][1]=-j;
        }
        int u,x,y;
        for(int i=0;i<n*2;++i)
            for(int j=0;j<n*2;++j)
            {
                u=get(i,j);
                for(int p=1;p<=tf;++p)
                {
                    x=i+fl[p][0];y=j+fl[p][1];
                    if(x<0||x>=n*2||y<0||y>=n*2)continue;
                    link(u,get(x,y));
                }
            }
        memset(c,-1,sizeof(c));
        for(int i=0;i<n*2;++i)
            for(int j=0;j<n*2;++j)
                if(c[get(i,j)]==-1)dfs(get(i,j),0);
    }
}g1,g2;
int cnt[2][2];
int main()
{
    scanf("%d%d%d",&n,&D1,&D2);
    g1.build(D1);
    g2.build(D2);
    int x;
    for(int i=0;i<n*2;++i)
        for(int j=0;j<n*2;++j)
        {
            x=get(i,j);
            cnt[g1.c[x]][g2.c[x]]++;
        }
    int ou=1;
    for(int i=0;i<2&&ou<=n*n;++i)
        for(int j=0;j<2&&ou<=n*n;++j)
        {
            if(cnt[i][j]<n*n)continue;
            for(int p=0;p<n*2&&ou<=n*n;++p)
                for(int q=0;q<n*2&&ou<=n*n;++q)
                {
                    x=get(p,q);
                    if(g1.c[x]==i&&g2.c[x]==j)
                    {
                        ou++;
                        printf("%d %d\n",p,q);
                    }
                }
        }
    return 0;
}


Measured memory_bytes: 124800
#include<bits/stdc++.h>
using namespace std;
int sumofdigits(int n)
{
  int sum=0;
  while(n>0)
  {
    sum+=n%10;
    n/=10;
  }
  return sum;
}
int main()
{
  int n,a,b;
  cin>>n>>a>>b;
  int sum=0;
  for(int i=1;i<=n;i++)
  {
    int t = sumofdigits(i);
     if(t>=a&&t<=b)
        sum+=i;
  }
  cout<<sum<<"\n";

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstdlib>
#include<set>

using namespace std;

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

#include<iostream>

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

Measured memory_bytes: 256
#include<stdio.h>
int alpha[26];
int main()
{
    char c;
    int i;
    while(scanf("%c", &c))
    {
        if(c=='\n') break;
        if(c>='A'&&c<='Z')
            alpha[c-'A']++;
        else
            alpha[c-'a']++;
    }
    for(i=0 ; i<26 ; i++)
    {
        if(alpha[i]%2!=0)
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


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

int n;
void aaa(string s){
    int k=s.size();
    if(k==n){
        cout<<s<<endl;
    }else{
        char maxa='a';
        for(int i=0;i<k;i++){
            maxa=max(maxa,s[i]);
        }
        for(char i='a';i<=maxa+1;i++){
            aaa(s+(char)i);
        }
    }
}
 
int main(){
    cin>>n;
    string s="a";
    aaa(s);
    return 0;
}

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

class Hello
{
    static void Main(string[] args)
    {
        //Nの値を保持する
        var N = int.Parse(Console.ReadLine());
        //回答用の配列をN分用意しておく
        var ans = new int[N + 1];
        //x,y,zをそれぞれ0～120の範囲でループする
        //Nは1≦N≦10^4なのでx,y,zいずれかが100を超えた値の場合下記の条件を満たさない
        //x^2+y^2+z^2+xy+yz+zx=n
        for (var x = 1; x < 120; x++)
        {
            for (var y = 1; y < 120; y++)
            {
                for (var z = 1; z < 120; z++)
                {
                    var temp = x * x + y * y + z * z + x * y + y * z + z * x;
                    //Nの値を超えない範囲で回答用配列をカウントアップ
                    if (temp <= N)
                    {
                        ans[temp]++;
                    }
                }
            }
        }
        //最後にN行分回答を出力して終了
        for (var num = 1; num < N + 1; num++)
        {
            Console.WriteLine(ans[num]);
        }
    }
}

Measured memory_bytes: 27352
#include<stdio.h>
int main()
{
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if (0 > x - r)
	{
		printf("No\n");
		return 0;
	}
	else if (W < x + r)
	{
		printf("No\n");
		return 0;
	}
	else if (0 > y - r)
	{
		printf("No\n");
		return 0;
	}
	else if (H < y + r)
	{
		printf("No\n");
		return 0;
	}
	else
	{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 2688
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

int main(){
	std::vector<int> aList(4);

	for(int i=0; i<4; i++)
		std::cin>>aList[i];

	std::sort(aList.begin(), aList.end());

	if(aList[0]==1 && aList[1]==4 && aList[2]==7 && aList[3]==9)
		std::cout<<"YES"<<std::endl;
	else
		std::cout<<"NO"<<std::endl;

	return 0;
}

Measured memory_bytes: 256
#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 gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

int main(){
  int n,k; cin >> n >> k;
  
  priority_queue<ll> kind[n];
  rep(i,n){
    int t; ll d; cin >> t >> d;
    kind[t-1].push(d);
  }
  
  priority_queue<ll> best, remain;
  rep(i,n){
    if(!kind[i].empty()){
      best.push(kind[i].top());
      kind[i].pop();
      while(!kind[i].empty()){
        remain.push(kind[i].top());
        kind[i].pop();
      }
    }
  }
  
  vector<ll> bsum = {0};//累積和用の配列
  while(!best.empty()){
    bsum.push_back(bsum.back()+best.top());
    best.pop();
  }
  vector<ll> rsum = {0};//累積和用の配列
  while(!remain.empty()){
    rsum.push_back(rsum.back()+remain.top());
    remain.pop();
  }
  
  ll ans = 0;
  for(ll x = 1; x <= k; x++){ //x種類を試す。1~K個まで。
    if(x >= bsum.size()) break; //xがサンプルの種類数を超えたらブレイク
    if(k - x >= rsum.size()) continue; //remainの数が足りない場合
    ans = max(ans, bsum[x] + rsum[k-x] + x*x);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 8820
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int i,j,k,n,a[200][3],x[200],y[200];
	cin>>n;
	for(i=0;i<n;i++){
		x[i]=0;
	}
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	for(i=0;i<3;i++){
		for(j=0;j<n;j++){
			y[j]=a[j][i];
		}
		for(j=0;j<n;j++){
			for(k=0;k<n;k++){
				if(a[j][i]==a[k][i] && j!=k){
					y[j]=0;
				}
			}
		}
		for(j=0;j<n;j++){
			x[j]=x[j]+y[j];
		}
	}
	
	
	for(i=0;i<n;i++){
		cout<<x[i]<<endl;
	}
	
	return 0;
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int a[11];
int main(){
	for(int i=1;i<=10;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+11);
	printf("%d\n%d\n%d\n",a[10],a[9],a[8]);
}

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

int main() {
  int n;
  long c=0;
  cin>>n;
  vector<int> a(n+1),b(n);
  for(int i=0;i<=n;i++) cin>>a.at(i);
  for(int i=0;i<n;i++) cin>>b.at(i);
  for(int i=0;i<n;i++){
    int &A=a.at(i);
    int &B=a.at(i+1);
    int &C=b.at(i);
    if(A+B>C){
      c+=b.at(i);
      if(C>A) B-=(C-A);
    }
    else{
      c+=(A+B);
      B=0;
    }
  }
  cout<<c<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
#define N 128
#define MAX_VALUE 101000

int i,j,n,W,w[N];
long long d[N][MAX_VALUE],v[N],ans;
int main()
{
    cin >> n >> W;
    ++n;
    ++W;
    for (i = 1; i < n; ++i)
        cin >> w[i] >> v[i];
    for (i = 0; i < n; ++i)
    for (j = 0; j < W; ++j)
        if(i * j > 0)
            d[i][j] = -1;
        else
            d[i][j] = 0;
    for (i = 1; i < n; ++i)
        for (j = 1; j < W; ++j){
            d[i][j] = max(d[i - 1][j],d[i][j - 1]);
            if (j - w[i] > -1 && d[i - 1][j - w[i]] > -1)
                d[i][j] = max(d[i][j],d[i - 1][j - w[i]] + v[i]);
            ans = max (d[i][j],ans);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 80128