akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;
int sum(int[]);
int last(int, int, int[]);
int max(int[], int);
int min(int[], int);
int main(){
	int D;
	int satisfaction = 0;
	cin>>D;
	int c[26];
	for(int i=0; i<26; i++){
		cin>>c[i];
	}
	int s[D][26];
	for(int r=0; r<D; r++){
		for(int c=0; c<26; c++){
			cin>>s[r][c];
		}
	}
	int t[D];
	for (int day = 0; day<D; day++){
		if(day<=D/2){
			t[day]=min(c,day)+1;
		}else{
			t[day]=max(c,day-D/2)+1;
		}
	}
	
	for(int d=0; d<D; d++){
		satisfaction+=s[d][t[d]-1];
		for(int i=1; i<=26; i++){
			if(i!=t[d]){
				satisfaction-=sum(c)*(d-last(d,i,t));
			}
		}
	}
	
	for(int n : t){
		cout<<n<<endl;
	}
}

int sum(int c[]){
	int sum=0;
	for(int i=1; i<=26; i++){
		sum+=c[i-1];
	}
	return sum;
}

int last(int d, int i, int hist[]){
	int n;
	
	bool inArr = false;
	int lastDay;
	for(int k=0; k<d; k++){
		if(hist[k]==i){
			inArr=true;
			lastDay=k+1;
		}
	}
	if(inArr){
		n=lastDay;
	}else{
		n=0;
	}
	return n;
}

int max(int a[], int m){
	int maxIndex=0,maxValue=a[maxIndex];
	for(int i=1; i<sizeof(a); i++){
		if(a[i]>maxValue){
			maxIndex=i;
			maxValue=a[i];
		}
	}
	if(m>0){
		a[maxIndex]=-1;
		maxIndex=max(a,m-1);
	}
	return maxIndex;
}

int min(int a[], int m){
	int minIndex=0,minValue=a[minIndex];
	for(int i=1; i<sizeof(a); i++){
		if(a[i]<minValue){
			minIndex=i;
			minValue=a[i];
		}
	}
	if(m>0){
		a[minIndex]=101;
		minIndex=min(a,m-1);
	}
	return minIndex;
}

Measured memory_bytes: 3672
N=int(input())

a=list(map(int,input().split()))

#print(a)
for k in range(N-1):
    print(a[k],end=" ")
print(a[N-1])

for i in range(1,N):
    v=a[i]
    j=i-1
    while j>=0 and a[j]>v:
        a[j+1]=a[j]
        j=j-1
    a[j+1]=v

    for k in range(N-1):
        print(a[k],end=" ")
    
    print(a[N-1])



Measured memory_bytes: 5976
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	ll a, b, c;
	cin >> a >> b >> c;
	int ans = INF;
	int cnt;
	if( a%2 != 0 || b%2 != 0 || c%2 != 0 ){
		cout << 0 << endl;
		return 0;
	}
	ll x = abs(b-a), y = abs(c-b), z = abs(a-c);
	if( x*y*z == 0 ){
		if( x+y+z != 0 ){  
			int w = max({x, y, z});
			cnt = 0;
			while( w%2 == 0 ){
				w /= 2;
				++cnt;
			}
			ans = min( ans, cnt );
		} else {
			ans = -1;
		}
	} else {
		cnt = 0;
		while( x%2 == 0 ){
			x /= 2;
			++cnt;
		}
		ans = min( ans, cnt );
		cnt = 0;
		while( y%2 == 0 ){
			y /= 2;
			++cnt;
		}
		ans = min( ans, cnt );
		cnt = 0;
		while( z%2 == 0 ){
			z /= 2;
			++cnt;
		}
		ans = min( ans, cnt );
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}


int dp[N];
void test_case() {

    int n;
    cin>>n;

    int k;
    cin>>k;


    vec arr(n);
    rep(i,n) {
        cin>>arr[i];
    }

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

    

    dp[0] = 0;
    dp[1] =abs(arr[0] - arr[1]);

    for(int i=2; i<k; i++) {
        dp[i] = abs(arr[i] - arr[0]);
    }


    for(int i=k; i<n; i++) {

        for(int j=k; j>=1; j--) {
            
            dp[i] = min(dp[i], dp[i-j] + abs(arr[i] - arr[i-j]));
        }
    }

    cout<<dp[n-1]<<endl;




}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);

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


    int t = 1;
    //cin >> t;
    while(t--)
    {   
        test_case();
    }
}


Measured memory_bytes: 3976
#include<cstdio>
#include<cstring>
#include<algorithm>
int main(void){
  int n, k, m;
  int t1, t2, ans;
  bool c[100010];
  bool f;
  for( ; ; ){
    scanf("%d %d", &n, &k);
    if(!(n + k)) break;
    for(int i = 0;i <= n; i++) c[i] = false;
    for(int i = 0;i < k; i++){
      scanf("%d", &m);
      c[m] = true;
    }
    f = c[0]? true : false;
    t1 = f? 1 : 0;
    t2 = ans = 0;
    if(f){
      for(int i = 1;i <= n; i++){
	if(c[i]){
	  t1++; t2++;
	}
	else if(!f && i >= 2 && c[i - 1] && c[i + 1] && i < n){
	  t1++; t2 = 0; f = true;
	}
	if(!c[i] && (f || i < 2) || i == n){
	  if(!f && c[i] < n) t1++;
	  ans = std::max(ans, t1);
	  if(f){
	    t1 = t2; t2 = 0;
	  } else {
	    t1 = t2 = 0;
	  }
	  f = c[0]? true : false;
	  if(c[i + 1] == true){
	    t1++; f = true;
	  }
	}
      }
    } else {
      for(int i = 1;i <= n; i++){
	if(c[i]) t1++;
	if(!c[i] || i == n){
	  ans = std::max(ans, t1);
	  t1 = 0;
	}
      }
    }
    printf("%d\n", ans);
  }
}


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

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

    if(s.size()<=k){
        cout << s << endl;
    }else{

        cout << s.substr(0, k) << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans = n + 1;
    VL sum(n+1, 0);
    REP(i,n)sum[i+1] = sum[i] + (s[i] == '.' ? 1 : 0);
    REP(i,n+1){
        int t = (i - sum[i] - sum[0]) + (sum[n] - sum[i]);
        ans = min(ans, t);
    }
    PUTS(ans);
}

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

int main(){
  int N;
  int a[100];
  cin >> N;
  for(int i=0;i<N;++i){
    cin >> a[i];
  }
  sort(a, a+N,greater<int>());
  int Alice = 0;
  int Bob = 0;
  for(int i=0; i<N;++i){
    if(i%2==0){
      Alice += a[i];
    }
    else{
      Bob +=a[i];
    }
  }
  cout << Alice - Bob << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<vector<double>> vvd;
typedef vector<double> vd;

#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 1000*1001;

#define forn(i, n) for(int i = 0; i < n; i++)
#define forsn(i, s, n) for(int i = s; i < n; i++)
#define all(x) x.begin(), x.end()


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n, k;
	cin >> n >> k;
	vll a(n);
	forn(i, n) cin >> a[i];
	sort(all(a));
	ll ans = 0;
	forn(i, n - k) ans += a[i];
	cout << ans << endl;
}		


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	string S, S2, T;
	cin >> S >> T;
	S2 = S;
	S2 += S;

	if ( S2.find(T) != string::npos )
		cout << "Yes" << "\n";
	else
		cout << "No" << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

namespace {
	int search(int n, int x, int a) {
		int remain = x - a;
		int mid = remain / 2;
		int btomid = mid - a - (remain == mid * 2);
		int midtoc = n - mid;
		//std::cout << "a: " << a << ", mid: " << remain / 2. << ", btomid: " << btomid << ", midtoc: " << midtoc << '\n';
		return std::max(0, std::min(btomid, midtoc));
	}

	int search(int n, int x) {
		int total = 0;
		int imax = std::min(n - 1, x / 3);
		for (int i = 1; i < imax; i++) {
			total += search(n, x, i);
		}
		return total;
	}
}

int main() {
	int n;
	int x;

	while (true) {
		std::cin >> n >> x;
		if (n == 0 && x == 0) {
			break;
		}
		std::cout << search(n, x) << std::endl;
	}
}

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

 void printTime(int a,int b,int c)
 {
		cout.width(2);
		cout.fill('0');
		cout << a << ":";

		cout.width(2);
		cout.fill('0');
		cout << b << ":";

		cout.width(2);
		cout.fill('0');
		cout << c << endl;
 }

int main()
{
	int hours,minutes,seconds;
	while(cin >> hours >> minutes >> seconds  && hours != -1 && minutes != -1 && seconds != -1)
	{
		int max_hours = 2;
		int temp = max_hours*60*60 - hours*60*60 - minutes*60 - seconds;
		int ans_seconds = temp % 60;
		int ans_minutes = temp/60;
		int ans_hours = ans_minutes/60;
		ans_minutes -= ans_hours*60;

		printTime(ans_hours,ans_minutes,ans_seconds);	

		temp *= 3;
		ans_seconds = temp%60;
		ans_minutes = temp/60;
		ans_hours = ans_minutes/60;
		ans_minutes -= ans_hours*60;

		printTime(ans_hours,ans_minutes,ans_seconds);
	}
	return 0;
}

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

int main()
{
    int n,m;
    cin>>n>>m;
    int a[m];
    for(int i=0;i<m;i++)
        cin>>a[i];
    int sum=accumulate(a,a+m,0);
    int ans= n-sum;
    if(ans<0)
        cout<<"-1"<<endl;
    else
        cout<<ans<<endl;
    return 0;
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

vector<string> expected;
const string ALL = "AKIHABARA";

void dfs(string current, int index) {
  if (index == 9) {
    expected.push_back(current);
    return;
  }

  if (ALL.at(index) == 'A') {
    dfs(current, index + 1);
  }
  dfs(current + ALL.at(index), index + 1);
}

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

  string S;
  cin >> S;

  dfs("", 0);

  if (find(expected.begin(), expected.end(), S) != expected.end()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
class PriorityQueue
  def initialize
    @heap = []
    @node_num = 0
  end

  def push(x)
    i = @node_num # 自分のノード番号
    @node_num += 1
    while i > 0
      par = (i - 1) / 2 # 親のノード番号
      break if @heap[par][0] <= x[0]
      @heap[i] = @heap[par]
      i = par
    end
    @heap[i] = x
  end

  def pop()
    ret = @heap[0]
    @node_num -= 1
    x = @heap[@node_num]
    i = 0
    while i * 2 + 1 < @node_num
      a, b = i * 2 + 1, i * 2 + 2
      a = b if b < @node_num && @heap[b][0] < @heap[a][0]
      break if @heap[a][0] >= x[0]
      @heap[i] = @heap[a]
      i = a
    end
    @heap[i] = x
    return ret
  end

  def get()
    @heap[0]
  end
end

N,M = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

q = PriorityQueue.new
a.each do |ai|
  q.push([-ai, 1])
end
M.times do
  b, c = gets.split.map(&:to_i)
  q.push([-c, b])
end

cnt = N
ans = 0
while cnt > 0
  c, b = q.pop
  c = -c
  if b < cnt
    ans += b*c
    cnt -= b    
  else
    ans += c * cnt
    cnt = 0
  end
end

puts ans


Measured memory_bytes: 18316
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n,W;
    cin>>n>>W;

    ll wt[n],val[n];

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

    ll mat[2][W+1];
    memset(mat, 0, sizeof(mat));
    int i = 0;
    while (i < n)
    {
        int j = 0;
        if (i%2!=0)
        {
            while (++j <= W)
                if (wt[i] <= j)
                    mat[1][j] = max(val[i] + mat[0][j-wt[i]], mat[0][j] );
                else
                    mat[1][j] = mat[0][j];
        }
        else
        {
            while(++j <= W)
                if (wt[i] <= j)
                    mat[0][j] = max(val[i] + mat[1][j-wt[i]], mat[1][j]);
                else
                    mat[0][j] = mat[1][j];
        }
        i++;
    }
    cout<<max(mat[0][W],mat[1][W]);
}

Measured memory_bytes: 1792
s=str(input())
n=len(s)
x=s[:(n-1)//2]
y=s[(n+3)//2-1:]
ans=0

for i in range(3):
    if s==s[::-1]:
        ans +=1

    if i==0:
        s=x
    elif i==1:
        s=y

print("Yes" if ans==3 else "No")

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int n;
  cin >> n;
  string a,b;
  int point[2] = {};
  for(int i=0;i<n;i++){
      cin >> a >> b;
      if(a>b) point[0] += 3;
      else if (a<b) point[1] += 3;
      else{ point[0]++; point[1]++;}
  }
  cout << point[0] << " " << point[1] << endl;
  return 0;
}


Measured memory_bytes: 3140
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
var Q=arr[0]-0;
var a=[];
var s="";
for(var i=1;i<=Q;i++){
   var q=arr[i].split(" ");
   if(q[0]=="0")a.push(q[1]-0);
   else if(q[0]=="1")s+=(a[q[1]]-0)+"\n";
   else a.pop();
}
console.log(s.trim());


Measured memory_bytes: 54172
// {{{
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#if __cplusplus >= 201103
#include <numeric>
#endif
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()

//#if __cplusplus >= 201103
typedef long long ll;
//#endif
typedef pair<int, int> P;
typedef pair<int, P> IP;

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

const int INF = 100000000;
//#if __cplusplus >= 201103
const ll LINF = 10000000000000000ll;
//#endif
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
// }}}

int n;
int m[2][100];

void init()
{
}

void solve()
{
    int ans = 0;
    REP(i, n){
        int sum = 0;
        REP(j, n){
            sum += m[j<=i? 0 : 1][j];
        }
        sum += m[1][i];
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    REP(i, 2){
        REP(j, n){
            cin >> m[i][j];
        }
    }
    solve();
    return 0;
}

// vim:set foldmethod=marker:


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



int main(int argc, char const *argv[])
{

#if !ONLINE_JUDGE

	freopen("in1.txt", "r", stdin);
	freopen("out1.txt", "w" , stdout);

#endif

	int n;
	cin >> n;

	long long res = 1;

	for (int i = 1; i <= n; i++)
	{
		res = ((res % 1000000007) * (i % 1000000007)) % 1000000007;
	}
	cout << res << endl;


	return 0;
}

Measured memory_bytes: 3596
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

int A, B;

signed main()
{
	cin >> A >> B;
	int ans = A - (B * 2);
	cout << MAX(ans, 0) << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
  
int main()
{
    int w, n;
    cin >> w >> n;
    vector<int> num(w);
    for(int i=0; i<w; ++i)
        num[i] = i+1;
  
    for(int i=0; i<n; ++i){
        int a, b;
        char c;
        cin >> a >> c >> b;
        swap(num[a-1], num[b-1]);
    }
  
    for(int i=0; i<w; ++i)
        cout << num[i] << endl;
  
    return 0;
}

Measured memory_bytes: 1192
D = int(input())
c = [int(i) for i in input().split()]
s = [[int(i) for i in input().split()] for _ in range(D)]
t = [int(input())-1 for _ in range(D)]

def scoreing(x):
    res = 0
    last = 0
    for day,i in enumerate(range(D),1):
        if t[i] == x:
            last = day
            res += s[i][x]
        res -= c[x]*(day-last)
    return res

score = [0]*26
for i in range(26): score[i] = scoreing(i)
M = int(input())
ans = [0]*M
for i in range(M):
    d,q = map(int,input().split())
    d -= 1
    q -= 1
    old = t[d]
    t[d] = q
    score[old] = scoreing(old)
    score[q] = scoreing(q)
    ans[i] = sum(score)
for i in range(M): print(ans[i])

Measured memory_bytes: 77120
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			long x = sc.nextLong();
			long y = sc.nextLong();
			
			if(y==0) {
				if(x>0) {
					System.out.println(x+1);
					return;
				}else {
					System.out.println(Math.abs(x));
					return;
				}
				
			}
			
			if(x==0) {
				if(y>0) {
					System.out.println(y);
					return;
				}
				else {
					System.out.println(Math.abs(y)+1);
					return;
				}
			}
			
			if(x*y>0) {
				if(x>y) {
					System.out.println(Math.abs(x-y)+2);
					return;
				}
				else {
					System.out.println(Math.abs(x-y));
					return;
				}
			}
			
			if(x>0&&y<0&&x*(-1)<y) {
				System.out.println(Math.abs(x-y*(-1))+1);
				return;
			}
			
			System.out.println(Math.abs(x*(-1)-y)+1);
			
			
		}
		
	}
	


Measured memory_bytes: 35732
#include <iostream>
using namespace std;
int main(void){
    int h,w;
    cin >> h >> w;
    
    while (1<2){
     
    if (h==0) return 0;
    
    for (int i=1; i<=h; i++)
    
    {for (int j=1; j<=w; j++){
    cout << "#";}
    
    cout << endl;}
        
    cout << "\n";    
    cin >> h >> w;}
    
    
}



Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int x, a, b;
    cin >> x >> a >> b;

    int ans = x - a;
    while(ans >= b){
        ans -= b;
    }
    p(ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
//#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    int res = 1;

    x = x;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);

        y = y>>1;
        x = (x*x);
    }
    return res;
}
bool isprime(int x)
{
      if(x<2)
        return false;
    for(int i=2;i*i<=x;i++)
     {
        if (x%i==0)
            return false;
    }
    return true;
}
vector<int>primeFactors(int n)
{
    vector<int>v;
    while (n % 2 == 0)
    {
        v.pb(2);
        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        while (n % i == 0)
        {
            v.pb(i);
            n = n/i;
        }
    }
    if (n > 2)
        v.pb(n);
    return v;
}
void solve()
{
int n;
cin>>n;
int m=100;
int ans=0;
while(m<n)
{
    m+=m/100;
    ans++;
}
cout<<ans<<endl;
}
signed main()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
//cin>>t;
t=1;
while(t--)
{
  solve();
}
}


Measured memory_bytes: 3676
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する


int main() {
    int n,k,x,y;
    cin >> n >> k >> x >> y;
    cout << min(n,k) * x + max(0,(n-k)) * y << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
A, B, C = map(int, input().split())
K = int(input())
def dfs(x, y, z, k):
  if k == 0:
    return x < y < z
  res = False
  res |= dfs(x * 2, y, z, k - 1)
  res |= dfs(x, y * 2, z, k - 1)
  res |= dfs(x, y, z * 2, k - 1)
  return res
if dfs(A, B, C, K): print("Yes")
else: print("No")

Measured memory_bytes: 67556
#include <iostream>
using namespace std;
int main(void){
    int n, m;
    long long ans = 0;
    long long const mod = 1e9+7;
    cin >> n >> m;
    if(n == m){
        ans = 2;
        for(int i=1;i<=n;i++){
            ans *= i;
            ans %= mod;
            ans *= i;
            ans %= mod;
        }
    }else if(abs(n-m) <= 1){
        ans = 1;
        for(int i=1;i<=n;i++){
            ans *= i;
            ans %= mod;
        }
        for(int i=1;i<=m;i++){
            ans *= i;
            ans %= mod;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long sum,n,q,tong[233333];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n;
	for(long long i=1,x;i<=n;i++)cin>>x,tong[x]++,sum+=x;
	cin>>q;
	while(q--){
		long long b,c;
		cin>>b>>c;
		sum=sum-b*tong[b]+c*tong[b];
		tong[c]+=tong[b];
		tong[b]=0;
		cout<<sum<<endl;
	}
}


Measured memory_bytes: 4432
N,K,S = map(int,input().split())
A = [str(10**9) for i in range(N)]
if S != 10**9:
    for i in range(K):
        A[i] = str(S)
else:
    for i in range(N-K):
        A[i] = str(1)
A = ' '.join(A)
print(A)

Measured memory_bytes: 11288
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int p[5005],c;
int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	int n,m;
	cin>>n>>m;n=pow(2,n);
	int a,b;
	p[0]=0;
	FOR(i,1,n-1)p[i]=1000000000;
	FOR(i,1,m){
		cin>>a>>b;
		int t=0;
		FOR(j,1,b){
			cin>>c;
			t=t+(1<<(c-1));
		}
		FOR(j,0,n-1){
			p[j|t]=min(p[j]+a,p[j|t]);
		}
	}
	if(p[n-1]==1000000000)cout<<-1;else cout<<p[n-1];
	return 0;
}




Measured memory_bytes: 512
#include <stdio.h>
 
int main(){
    int sum = 0;
    char ch;
 
    while(1)
    {
        while((ch=getchar()) != '\n'){
            sum += ch-'0';
        }
        if(sum == 0)
            break;
        else{
            printf("%d\n",sum);
            sum = 0;
        }
    }
}


Measured memory_bytes: 2692
# C
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
countS = Counter(S)
maxS = max(countS.values())
ans = []
for key,value in countS.items():
  if value == maxS:
    ans.append(key)

for a in sorted(ans):
  print(a)


Measured memory_bytes: 38644
import math
a,b,h,m=map(int,input().split())
h=h*30+(m/60)*30
m=m*6
diff=abs(h-m)*((math.pi)/180)
if(diff>180):
    diff=diff-180
ans=a*a+b*b-2*a*b*(math.cos(diff))
print(math.sqrt(ans))
    

Measured memory_bytes: 9444
import math
A, B = list(map(int, input().split()))
ans = -1
low = math.floor(min(A//0.08, B//0.1))
hig = math.ceil(max((A+1)//0.08, (B+1)//0.1))
for i in range(low, hig):
   a = math.floor(i * 0.08)
   b = math.floor(i * 0.1)
   if A == a and B == b:
     ans = i
     break
print(ans)

Measured memory_bytes: 62136
package main

import (
        "bufio"
        "fmt"
        "os"
)

func solution(x, y int) int {
        c := 0
        for cur := x; cur <= y; cur <<= 1 {
                c++
        }
        return c
}

func main() {
        r := bufio.NewReader(os.Stdin)
        var x, y int
        fmt.Fscan(r, &x, &y)
        fmt.Println(solution(x, y))
}

Measured memory_bytes: 1836
#include<stdio.h>
#include<string.h>
int main(void) {
	int  n, count = 0;
		while (scanf("%d", &n) != EOF){
		for (size_t a = 0; a <= 9; a++)
		{
			for (size_t b = 0; b <= 9; b++)
			{
				for (size_t c = 0; c <= 9; c++)
				{
					for (size_t d = 0; d <= 9; d++)
					{
						if (a + b + c + d==n)
						{
							count++;
						}
					}
				}
			}
		}
		printf("%d\n", count);
		count = 0;
	}
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] x = new int[5];
		for (int i = 0; i < x.length; i++) {
			if(sc.nextInt() == 0) {
				System.out.println(i + 1);
				break;
			}
		}
	}
}


Measured memory_bytes: 35536
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
using namespace std;

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

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

	int b[2] = {}, c[2] = {};
	for (int i = 0; i < n; i++) {
		if (a[i] == b[0] || a[i] == b[1])
			c[a[i] == b[1]]++;
		else {
			if (b[0] == 0) b[0] = a[i], c[0]++;
			else if (b[1] == 0) b[1] = a[i], c[1]++;
			else break;
		}
	}
	if (b[0] < b[1])
		swap(b[0], b[1]), swap(c[0], c[1]);

	if (c[0] + c[1] != n || !(c[1] == 0 || b[0] - b[1] == 1)) {
		cout << "No" << endl;
		quick_exit(0);
	}

	if (c[1] == 0 && b[0] == n - 1) {
		cout << "Yes" << endl;
		quick_exit(0);
	}

	if (b[0] - c[1] > 0 && b[0] - c[1] <= c[0] / 2) {
		cout << "Yes" << endl;
		quick_exit(0);
	}

	cout << "No" << endl;

}


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

int main()
{
	double height;
	double Min=100000000, Max=0;
	while(cin>>height){
		Min = min( Min, height );
		Max = max( Max, height);
	}
	
	double difference = Max - Min;
	cout<<difference<<endl;
	return 0;
}
	

Measured memory_bytes: 1280
#>,>++++++[<-------->-],----------[<[>++++++++++<-]>-->++++++[<------>-],[-]],----------[>+++++++++[<--------->-]+<+<[>[+>>]>[>+++++[<<----->>-]>]<<<<<+>-]<[>+<-]>>>+++++++++[<+++++++++>-]<.,----------]++++++++++
bf Main.sh

Measured memory_bytes: 688
T=input()
T=[str(t) for t in T]
for a in range(len(T)):
    if T[a]=='?':
        if a-1>=0 and T[a-1]=='P':
            T[a]='D'
        elif a+1>len(T)-1:
            T[a]='D'
        else:
            T[a]='D'
print(''.join(T))


Measured memory_bytes: 10812
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  string op;
  while(true){
    cin >> A >> op >> B;
    if (op == "+") {
      cout << A + B << endl;
    }else if(op == "-") {
      cout << A - B << endl;
    }else if(op == "*") {
      cout << A * B << endl;
    }else if(op == "/") {
      cout << A / B << endl;
    }else if(op == "?") {
      return 0;
    }
  }
}


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

using namespace std;

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

  int N; cin>>N;
  vector<unsigned long> A(N); for (auto& a : A) cin>>a;
  unsigned long allxor = 0;
  for (auto a : A)
    allxor ^= a;
  for (auto& a : A)
    a &= compl allxor;
  int rank = 0;
  for (int i = 59; i >= 0; i--) {
    int j = rank;
    while (j < N and ((A[j] & (1ull << i)) == 0)) {
      j++;
    }
    if (j >= N)
      continue;
    if (rank != j)
      A[rank] ^= A[j];
    for (int k = rank+1; k < N; k++) {
      A[k] = min(A[k], A[k] xor A[rank]);
    }
    rank++;
  }
  unsigned long ansb = 0;
  for (auto a : A) {
    ansb = max(ansb, ansb xor a);
  }
  cout << ansb*2 + allxor << endl;

  return 0;
}


Measured memory_bytes: 1024
N = int(input())

H = list(map(int,input().split()))

flg = True
for i in range(1,N):
    if H[i] > H[i-1]:
        H[i] = H[i]-1
    if H[i-1] - H[i] > 0:
        flg = False
        break

if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14252
n=int(input())

if n<=111:
  print(111)
  
elif n<=222:
  print(222)
  
elif n<=333:
  print(333)
  
elif n<=444:
  print(444)
  
elif n<=555:
  print(555)
  
elif n<=666:
  print(666)
  
elif n<=777:
  print(777)
  
elif n<=888:
  print(888)
  
else:
  print(999)

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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a>=b && a>=c){
		cout << (a*10+b+c) << endl;
	}else if(b>=c){
		cout << (a+b*10+c) << endl;
	}else{
		cout << (a+b+c*10) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	ll A,B,C,K;
	cin>>A>>B>>C>>K;
	ll x = max({A,B,C});
	ll ans = x * (2L<<(K-1)) - x + A+B+C;
	ote(ans);
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long a,b,w;
    while(scanf("%lld %lld %lld",&w,&a,&b)==3)
   {
        if(a+w<b)
        {
            printf("%lld\n",b-a-w);continue;
        }
    if(b+w<a)
        {
              printf("%lld\n",a-b-w);continue;
        }
    if((a<=b)&&(a+w>=b))
     {
          printf("0\n");continue;
     }
     if((b<=a)&&(b+w>=a))
    {
          printf("0\n");continue;
    }
   }
    return 0;
}


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

int n, l, tot, absmin, absmin2,ans;
bool flag;

int main() {
  
  cin >> n >> l;
  absmin = 100000;
  absmin2 = 100000;
  flag = true;

  tot = n * (l + l + n - 1) / 2;

  for (int i = 1; i <= n; i++) {
    absmin = min(absmin,abs(l-1+i));
    
    if (absmin != absmin2 && abs(l-1+i) != l-1+i) {
      flag = false;
    }
    absmin2 = absmin;
  }

  if (flag) {
    ans = tot - absmin;
  } else {
    ans = tot + absmin;
  }

  cout << ans << endl;
}

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

using namespace std;
using ll = long long;
#define endl '\n'
#define all(v) v.begin(), v.end()

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (auto& v : a) cin >> v;
    ll S = a[0];
    for (int i = 1; i < n; i++)
        S ^= a[i];
    for (ll& v : a)
        cout << (S ^ v) << " ";
    cout << endl;
}


Measured memory_bytes: 4824
S = input()

if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
elif S == 'SAT':
    print(1)


Measured memory_bytes: 8792
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;
 
 int main(void){
     int N[4],a=0,b=0,c=0,d=0;
     for(int i=0; i<4; i++){
         cin >> N[i];
         if(N[i]==1){
             a=1;
         }else if(N[i]==7){
             b=1;
         }else if(N[i]==9){
             c=1;
         }else if(N[i]==4){
             d=1;
         }
     }
     if(a==1 && b==1 && c==1 && d==1){
         cout << "YES" << endl;
     }else{
         cout << "NO" << endl;
     }
 }

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

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

//
void insertionSort(int A[], int n, int g) {
    for ( int i = g; i < n; i++ ) {
        int v = A[i];
        int j = i - g;
        while( j >= 0 && A[j] > v ) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shellSort(int A[], int n) {
    //
    for ( int h = 1; ; ) {
        if ( h > n ) break;
        G.push_back(h);
        h = 3*h + 1;
    }

    for ( int i = G.size()-1; i >= 0; i--) {//
        insertionSort(A, n, G[i]);
    }
}

int main() {
    cin >> n;
    //
    for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);
    cnt = 0;

    shellSort(A, n);

    cout << G.size() << endl;
    for ( int i = G.size() - 1; i >= 0; i-- ) {
        printf("%d", G[i]);
        if ( i ) printf(" ");
    }
    printf("\n");
    printf("%d\n", cnt);
    for ( int i = 0; i < n; i++ ) printf("%d\n", A[i]);

    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int dp[301][301];
int w[300];

int daruma(int l, int r)
{
    if (dp[l][r] != -1)
        return dp[l][r];
    if (abs(l - r) <= 1)
        return 0;

    int res = 0;
    if (abs(w[l] - w[r - 1]) <= 1 && daruma(l + 1, r - 1) == r - l - 2)
        res = r - l;
    for (int i = l + 1; i <= r - 1; i++)
        res = max(res, daruma(l, i) + daruma(i, r));

    return dp[l][r] = res;
}

int main()
{
    int n;
    while (cin >> n,n)
    {
        rep(l, 301) rep(r, 301) dp[l][r] = -1;
        rep(i, n) cin >> w[i];
        OP(daruma(0, n));
    }
    return 0;
}


Measured memory_bytes: 3464
//https://atcoder.jp/contests/dp/tasks/dp_c
//shauryakr
#include<bits/stdc++.h>
using namespace std;
int A[100010], B[100010], C[100010], n;
int dp[100010][4];
int solve(int ind, int type)
{
    if(ind == n)
        return 0;
    if(dp[ind][type] != -1)
        return dp[ind][type];
    int ans = 0;
    for(int i=1; i<=3; i++)
    {
        if(i != type)
        {
            if(i==1)
            {
                ans = max(ans, solve(ind+1, i) + A[ind]);
            }
            else if(i==2)
            {
                ans = max(ans, solve(ind+1, i) + B[ind]);
            }
            else
            {
                ans = max(ans, solve(ind+1, i) + C[ind]);
            }
            
        }
    }
    dp[ind][type] = ans;
    return ans;
}
int main()
{
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> A[i] >> B[i] >> C[i];
    }
    memset(dp, -1, sizeof dp);
    cout << solve(0, 0) << endl;
    return 0;
}

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

int main(){
	int n,x,ans=0;
	while(1){	
		scanf("%d %d",&n,&x);
		if(n+x==0) break;
		ans=0;
		for(int i=1;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				for(int k=j+1;k<=n;k++){
					if(i+j+k==x) ans++;
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

int main(){

    int N;
    cin >> N;

    int ans = 0;
    for (int A = 1; A < N; A++){
        for (int B = 1; B < N; B++){
            if (A*B > N) break;
            if (A*B < N) ans++; 
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <cstring>
#include <iomanip>
#include <vector>
using namespace std;

const int MAX_N = 2e5 + 10, MOD = 1e9 + 7;
int n, m;
int Arr[MAX_N];
string s;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> s;
	for (int i = 0; i + 1 < s.size(); i++)
		if (s[i] == s[i + 1]) {
			cout << "Bad\n";
			return 0;
		}
	cout << "Good\n";
	return 0;
}

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

int main() {
	int cnt = 0, n = 3;
	char c;

	while (n--) {
		scanf("%c", &c);

		if (c == 'o')
			cnt++;
	}

	printf("%d", 700 + 100 * cnt);

	return 0;
}

Measured memory_bytes: 256
def dfs(now,origin,drawn): # 深さ優先探索　再帰関数　originは変更しない　drawnは訪れた場所に1それ以外は0
    positive = '.' # 進める場所
    negative = '#' # 進めない場所(壁)
    direct = [0,0,0,0] # [上,下,左,右]を表す
    height = len(origin)
    width = len(origin[0])
    now_h = now[0]
    now_w = now[1]
    ### それぞれの方向について、originにおいてpositiveかつdrawnにおいて0（つまり訪れたことがある）なら進める
    if now_h != 0 and origin[now_h-1][now_w] == positive and drawn[now_h-1][now_w] == 0:
        direct[0] = 1
    if now_h != height-1 and origin[now_h+1][now_w] == positive and drawn[now_h+1][now_w] == 0:
        direct[1] = 1
    if now_w != 0 and origin[now_h][now_w-1] == positive and drawn[now_h][now_w-1] == 0:
        direct[2] = 1
    if now_w != width-1 and origin[now_h][now_w+1] == positive and drawn[now_h][now_w+1] == 0:
        direct[3] = 1

    if sum(direct) == 0: # 進む先がなければ終了
        return 0
    d = {0:[now_h-1,now_w],1:[now_h+1,now_w],2:[now_h,now_w-1],3:[now_h,now_w+1]} # 進む先の座標を辞書にしておく
    for i in range(4):
        if direct[i] == 1:
            drawn[d[i][0]][d[i][1]] = 1 # d[i]の座標に移動したのでdrawnで訪れたことを記録した
            dfs(d[i],origin,drawn) # 再帰
    return 0

while True:
    W, H = map(int,input().split()) # 入力を受け取る
    if W == 0 and H == 0: # 両方0だったらbreak
        break
    tiles = [list(input()) for i in range(H)] # 入力
    possible_tiles = [[0 for i in range(W)] for j in range(H)] # 訪れたことがある場所を記憶する
    for h in range(H):
        for w in range(W):
            if tiles[h][w] == '@': # 現在地
                now = [h,w]
                break
    possible_tiles[now[0]][now[1]] = 1 # 現在地は既に訪れている
    dfs(now,tiles,possible_tiles) # 探索
    ans = 0
    for h in range(H):
        for w in range(W):
            if possible_tiles[h][w] == 1:
                ans += 1
    print(ans)


Measured memory_bytes: 5924
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10

int N;
set<int>a;

int main() {

	cin >> N;
	for (int i = 0; i < N; i++) {
		int A; cin >> A;
		if (a.count(A) == 0)a.insert(A);
		else a.erase(A);
		
	}
	cout << a.size() << endl;




	return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int N,X,T;
cin>>N>>X>>T;

int steps = N/X;
bool extra = N%X;
cout<<(steps+extra)*T<<endl;

return 0;
}

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

using namespace std;

const int N = 777777;

int x[N], y[N], a[N];
pair < double, pair <int, int> > e[N];
int p[N];
double cost[N];
double dist[42][42];
double f[N];

int find_set(int x) {
  if (x != p[x]) {
    p[x] = find_set(p[x]);
  }
  return p[x];
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", x + i, y + i, a + i);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      dist[i][j] = sqrt((x[i] - x[j]) * 1LL * (x[i] - x[j]) + (y[i] - y[j]) * 1LL * (y[i] - y[j]));
    }
  }
  for (int t = 1; t < (1 << n); t++) {
    int m = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        if (t & (1 << i)) {
          if (t & (1 << j)) {
            e[m++] = make_pair(dist[i][j], make_pair(i, j));
          }
        }
      }
    }
    sort(e, e + m);
    for (int i = 0; i < n; i++) {
      p[i] = i;
    }
    cost[t] = 0;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (t & (1 << i)) {
        cost[t] += a[i];
        cnt++;
      }
    }
    for (int i = 0; i < m; i++) {
      int u = e[i].second.first;
      int v = e[i].second.second;
      u = find_set(u);
      v = find_set(v);
      if (u != v) {
        cost[t] -= e[i].first;
        p[u] = v;
      }
    }
    cost[t] /= cnt;
  }
  for (int t = 0; t < (1 << n); t++) {
    f[t] = 0;
  }
  f[0] = 1e30;
  for (int t = 0; t < (1 << n); t++) {
    int other = (1 << n) - 1 - t;
    int cur = other;
    while (cur > 0) {
      f[t + cur] = max(f[t + cur], min(f[t], cost[cur]));
      cur = (cur - 1) & other;
    }
  }
  printf("%.15f\n", f[(1 << n) - 1]);
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
const int INF = 10000;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  int n;
  cin>>n;
  int t[n],a[n];
  for(int i = 0; i < n; i++){
    cin>>t[i]>>a[i];
  }
  ll tt = t[0];
  ll aa = a[0];
  for(int i = 1; i < n; i++){
    if(tt<=t[i]&&aa<=a[i]) {
      tt = t[i];
      aa = a[i];
      // cout<<"IF";
    }
    else{
      ll mod = lmax((tt-1)/t[i]+1,(aa-1)/a[i]+1);
      tt = t[i]*mod;
      aa = a[i]*mod;
      // cout<<"ELSE";
    }
    // cout<<tt<<" "<<aa<<endl;
  }
    cout<<tt+aa<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n)cin >> a[i];
    int sum = 0;
    rep(i, n)sum += a[i];
    vector<int> p;
    for(int i = 1; i * i <= sum; i++){
        if(sum % i == 0){
            p.push_back(i);
            p.push_back(sum / i);
        }
    }
    int ans = 0;
    for(int x : p){
        vector<int> y(n);
        rep(i, n)y[i] = a[i] % x;
        sort(y.begin(), y.end());
        int cnt = 0;
        int l = 0;
        int r = n - 1;
        while(l < r){
            if(y[l] + y[r] < x){
                y[r] += y[l];
                cnt += y[l];
                l++;
            }else if(y[l] + y[r] == x){
                cnt += y[l];
                l++;
                r--;
            }else{
                cnt += x - y[r];
                y[l] -= x - y[r];
                r--;
            }
            if(cnt > k)break;
        }
        if(cnt <= k)ans = max(ans, x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256