akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;


vector<int>  dx = {1,-1,0,0};
vector<int>  dy = {0,0,1,-1};


int main() {
	
	while(1) {
		int n; cin >> n;
		if(n == 0) break;

		int l = -1;
		int r = -1;
		int ans = 0;
		int flag = -1;
		//1 ue, -1 sita
		for (int i = 0; i < n; i++) {
			string s; cin >> s;
			if(s == "lu") {
				l = 1;
			}else if( s == "ru") {
				r = 1;
			}else if( s == "ld") {
				l = -1;
			}else if( s == "rd") {
				r = -1;
			}
			if (l == r and flag == -1 * l) {
				ans++;
				flag *= -1;
			}
		}
		cout << ans << endl;
	}

	return 0;
}



Measured memory_bytes: 3144
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;
#define LL long long

int N,M,A[11111];

int main() {
	cin>>N>>M;
	for(int i=0;i<M;i++){
		cin>>A[i];
		N-=A[i];
	}
	cout<<max(-1,N)<<endl;
	return 0;
}



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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main() {
  ll N, D;
  cin >> N >> D;
  ll X[N][D];
  rep(i,0,N) {
    rep(j,0,D) {
      cin >> X[i][j];
    }
  }

  ll sum = 0;
  ll kari = 0;
  ll ans = 0;
  rep(i,0,N) {
    rep(j,i+1,N) {
      rep(k,0,D) {
        kari = abs(X[i][k] - X[j][k]);
        sum += kari * kari;
      }
      // cout << sum << endl;
      rep(l,0,1000) {
        if (l * l == sum) {
          ans++;
          break;
        }
      }
      sum = 0;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
const int maxn = 200;
int n,a[maxn+1];
int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("A.inp","r",stdin);
	//freopen("A.out","w",stdout);
	cin >> n;
	for (int i=1; i<=2*n; i++)
		cin >> a[i];
	sort(a+1,a+1+2*n);
	int res=0;
	for (int i=1; i<=2*n; i+=2)
		res+=a[i];
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int N=100010;
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
int main(){
	int n, m, c;
	int ans, anss=0;
	int b[30];
//	int a[30][30];
	int imp;
	cin>>n>>m>>c;
	for(int i=0;i<m;i++){
		cin>>b[i];
	}
	rep(i, n){
		ans=c;
		rep(j, m){
			cin>>imp;
			ans=ans+imp*b[j];
		}
		if(ans>0){
			anss++;
		}
	}
	cout<<anss<<endl;
}

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

int main()
{
    int n, z, w;
    cin >> n >> z >> w;
    int a[n];

    for(int i = 0; i<n; i++){
        cin >> a[i];
    }
    if(n == 1)
        cout << abs(w-a[0]) << endl;
    else
        cout << max(abs(w-a[n-1]), abs(a[n-1]-a[n-2])) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int abs(int a){
	if(a>0) return a;
	else return -1*a;
}

int main(void) {
	int N;
	scanf("%d",&N);
	int n[N];
	int a=0;
	for(int i=0;i<N;i++){
		scanf("%d",&n[i]);
		a+=n[i];
	}
	
	int b=0;
	
	int ans = a;
	
	for(int i=0;i<N;i++){
		for(int j=0;j<=i;j++){
			b += n[j];
		}
		if(ans>abs(a-2*b)) ans = abs(a-2*b);
		b=0;
	}
	
	printf("%d",ans);
	
	
	
	return 0;
}

Measured memory_bytes: 128
using System;
class _0037
{
    public static void Main()
    {
        string hori = "", vert = "00000";
        int dir = 0, x = 1, y = 0;
        for (int i = 0; i < 9; i++)
        {
            if (i % 2 == 0) hori += "0" + Console.ReadLine() + "0";
            else vert += Console.ReadLine();
        }
        vert += "00000";
        Console.Write('R');
        while (x != 0 || y != 0)
        {
            dir = (dir + 4) % 4;
            switch (dir)
            {
                case 0:
                    if (hori[y * 6 + x + 1] == '1')
                    {
                        x += 1;
                        Console.Write('R');
                        dir--;
                    }
                    else dir++;
                    break;
                case 1:
                    if (vert[(y + 1) * 5 + x] == '1')
                    {
                        y += 1;
                        Console.Write('D');
                        dir--;
                    }
                    else dir++;
                    break;
                case 2:
                    if (hori[y * 6 + x] == '1')
                    {
                        x += -1;
                        Console.Write('L');
                        dir--;
                    }
                    else dir++;
                    break;
                case 3:
                    if (vert[y * 5 + x] == '1')
                    {
                        y += -1;
                        Console.Write('U');
                        dir--;
                    }
                    else dir++;
                    break;
            }
        }
        Console.Write('\n');
    }
}

Measured memory_bytes: 5272
package main

import "fmt"

func main() {
  var N int
  fmt.Scan(&N)
  
  cnt := 0
  
  for i := 1; i <= N; i++ {
    if i % 2 == 1 {
      divisor := 0
      for j := 1; j <= i; j++ {
        if i % j == 0 {
          divisor++
        }
      }
      if divisor == 8 {
        cnt++
      }
    }
  }
  fmt.Println(cnt)
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        final int A = sc.nextInt();
        final int B = sc.nextInt();
        final int C = sc.nextInt();
        final int X = sc.nextInt();
        final int Y = sc.nextInt();
        final int min = Math.min(X, Y);
        final int max = Math.max(X, Y);
        
        System.out.println(Math.min(Math.min(A + B, 2 * C) * min + A * (X - min) + B * (Y - min), max * 2 * C));
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);


int main() {
  string s; cin >> s;
  if (s[1] == 'R') cout << "ABC" << endl;
  else cout << "ARC" << endl;
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const int maxn=1e5+7;
int pre[maxn];
int main()
{
	string s;
	cin>>s;
	for(int i=1;i<=s.length();i++)
	{
		if(s[i-1]=='g')
			pre[i]=pre[i-1]+1;
		else pre[i]=pre[i-1]-1;
	//	dbg(i,pre[i]);
	}
	int mx=INF;
	int ans=0;
	for(int i=s.length();i>0;i--)
	{
		mx=min(mx,pre[i]);
		if(mx>=2&&s[i-1]=='g')
		{
			mx-=2;
			ans++;
		}
	}
	cout<<ans<<endl;
}


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

int main(void){
    
   long long int A,B,K,t;
   cin >> A >> B >> K;
   
   t = A;               
   if(K >= A){
       A = 0;
       K -= t;          
   } 
   else{
       A-= K;
       K -= t;
   }
   
   if(K > 0){
       B -= K;
       if(B < 0) B = 0;
   }
   cout << A << " " << B <<endl;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
	int num[100] = {0}, n, max = 0, i;
	
	while (scanf("%d", &n) != EOF){
		num[n-1]++;
	}
	
	for (i = 0; i < 100; i++){
		if (max < num[i]){
			max = num[i];
		}
	}
	
	for (i = 0; i < 100; i++){
		if (max == num[i]){
			printf("%d\n", i + 1);
		}
	}
	
	return (0);
}

Measured memory_bytes: 596
def main():
    """
    input:
        1 <= N <= 10^5
        N <= M <= 10^9

        a1 + a2 + ... + aN = M
        1 <= ai

    output:
        数列の項の最大公約数の最大値
    """
    N, M = map(int, input().split())

    # ans = f(N, M)
    ans = editorial(N, M)
    print(ans)


def f(N, M):
    """
    最大公約数1:
        1が含まれる
        互いに素

    最大公約数2:
        すべて2の倍数

    N=M: すべて1
    M=奇数: 最大公約数は奇数
    まず1ずつ配る
        M -= N

    N,M: 0は偶数、1は奇数
    0 0: 配ってもMは偶数のまま
    0 1: 配ってもMは奇数のまま
         1余るので配る時に２回分配る、余りはどれかに割り当てて偶数にする
    1 0: 奇数回目の配るときには奇数、偶数回目のときは偶数
    1 1: 配ってもMは奇数のまま、01と同じパターン

    """
    if N == 1:
        return M

    if N == M or M < N * 2:
        return 1

    # 1回は確実に配れる
    ans = 1
    d = 1
    M -= M
    while M >= N:
        # 配る
        M -= N
        d += 1

        # 残りをいい感じに分配したときに、今まで配った回数の最大公約数を維持できるか?
        if True:
            ans = d

    return ans


def editorial(N, M):
    """
    すべての項がK倍なら、最大公約数は最低でもKであり、それらの和であるMもKの倍数
    Mの約数は、M=A*B=B*A の対称性より
        最大 root(10^9) まで試せば良いのでTLEしない
    N=1,M=10^9のとき、最初の考えではTLEになる
    """
    ans = 1
    a_max = int(M ** 0.5)
    for a in range(1, a_max + 1):
        if M % a != 0:
            continue

        # aで割り切れるので、もう片方も試す
        b = M // a

        # e.g. N=5, M=120, a=15, M = (N + x) * a,  xは正負ゼロどれか
        # 15 + 15 + 15 + 15 + 15 = 15 * 5 = 75, rest=45 = 15 * 3
        # a * N はaの倍数、Mもaの倍数、より残りもaの倍数なのでどれかの項に配ればよい
        if a * N <= M:
            ans = max(ans, a)
        if b * N <= M:
            ans = max(ans, b)

    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout <<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr << #x << ":" << (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;

	VAR(int, n);
	int ans = 1;
	FOR(i, 1, n + 1) {
		(ans *= i) %= MOD;
	}
	OUT(ans)BR;
	
  return 0;
}


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

int main() {
  int n, a, b;
  string s;
  cin >> n >> a >> b;
  cin >> s;

  int jp = 0;
  int os = 0;

  for (int i = 0; i < n; i++) {
    char c = s.at(i);
    if (c == 'a') {
      if (jp + os < a + b) {
        cout << "Yes" << endl;
        jp++;
      } else {
        cout << "No" << endl;
      }
    } else if (c == 'b') {
      if (jp + os < a + b && os < b) {
        cout << "Yes" << endl;
        os++;
      } else {
        cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 3696
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

struct UnionFind {
  vector<ll> par;  // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<ll> cnts;

  UnionFind(ll N) : par(N), cnts(N) {  //最初は全てが根であるとして初期化
    for (ll i = 0; i < N; i++) par[i] = i;
    for (ll i = 0; i < N; i++) cnts[i] = 1;
  }

  ll root(ll x) {  // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(ll x, ll y) {  // xとyの木を併合
    ll rx = root(x);        // xの根をrx
    ll ry = root(y);        // yの根をry
    if (rx == ry) return;  // xとyの根が同じ(=同じ木にある)時はそのまま
    if (cnts[rx] > cnts[ry]) swap(rx, ry);
    par[rx] =
        ry;  // xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    cnts[ry] += cnts[rx];
  }

  bool same(ll x, ll y) {  // 2つのデータx, yが属する木が同じならtrueを返す
    ll rx = root(x);
    ll ry = root(y);
    return rx == ry;
  }
};

int main() {
  ll n, m, k;
  cin >> n >> m >> k;

  UnionFind uf(n);
  vll ans(n, 0);
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    uf.unite(a, b);
    ans[a]--;
    ans[b]--;
  }

  rep(i, n) ans[i] += uf.cnts[uf.root(i)];

  rep(i, k) {
    ll c, d;
    cin >> c >> d;
    c--;
    d--;
    bool candcd = uf.same(c, d);
    if (candcd) {
      ans[c]--;
      ans[d]--;
    }
  }

  rep(i, n) cout << --ans[i] << " ";
  cout << endl;

  return 0;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

int main()
{
    string s, p;
    cin >> s >> p;
    s += s;
    int p_in_s = s.find(p);
    if(p_in_s == string::npos) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int MAX = 200005;
const int D = 60;
/* global variables */
// to[i][j] = j -> 2^i 個先の頂点
vector<vector<int> > to(D, vector<int>(MAX));
/* function */
/* main */
int main(){
    int N;
    ll K;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> to[0][i];
        to[0][i]--;
    }
    for (int i = 0; i < D - 1; i++) for (int j = 0; j < N; j++)
        to[i+1][j] = to[i][to[i][j]];

    int v = 0;
    for (int i = D - 1; i >= 0; i--) {
        ll l = 1LL << i;
        if (l <= K) {
            v = to[i][v];
            K -= l;
        }
    }

    cout << v + 1 << '\n';

}


Measured memory_bytes: 50860
int t,n,m,l,i,j,a,b,k,P[1001],T[1001],Q[2001],C[2001][2001],V[2001],d[1001][1001];
int match(s){int i=l;for(;i<l+l;i++)if(C[s][i]&&!V[i])if(V[i]=1,Q[i]<0||match(Q[i]))return Q[s]=i,Q[i]=s,1;return 0;}
main(){
  for(;scanf("%d%d%d",&n,&m,&l),l;printf("%d\n",l-t)){
	memset(C,0,sizeof(C));memset(Q,0xff,sizeof(Q));
	//memset(d,99,sizeof(d));for(i=0;i<n;i++)d[i][i]=0;
    for(i=0;i<n;i++)for(j=0;j<n;j++)d[i][j]=i==j?0:99999;
    for(i=0;i<m;i++)scanf("%d%d%d",&a,&b,&k),d[a][b]=d[b][a]=k;
	for(i=0;i<l;i++)scanf("%d%d",P+i,T+i);
	//warshall-floyd
	for(k=0;k<n;k++)for(i=0;i<n;i++)for(j=0;j<n;j++)if(d[i][j]>d[i][k]+d[k][j])d[i][j]=d[i][k]+d[k][j];
	for(i=0;i<l;i++)for(j=0;j<l;j++)if(i!=j&&d[P[i]][P[j]]<99999&&T[i]+d[P[i]][P[j]]<=T[j])C[i][l+j]=C[l+j][i]=1;
    for(t=i=0;i<l;i++)memset(&V,0,sizeof(V)),t+=match(i);
  }
  return 0;
}

Measured memory_bytes: 18560
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

struct BIT{
    vector<ll> bit; //1-indexed
    int n;
    BIT(int n) : n(n), bit(vector<ll>(n+1, 0)) {}
    ll sum(int i){
        ll s = 0;
        while(i > 0){
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }
    void add(int i, int x){
        while(i <= n){
            bit[i] += (ll)x;
            i += i & -i;
        }
    }
};

int main(void)
{
    int N,M;
    cin >> N >> M;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    BIT bitA(N);
    BIT bitB(N);
    SORT(A);
    REP(i, N){
        bitA.add(i+1, A[i]);
    }
    vector<pii> cb(M);
    REP(i, M){
        cin >> cb[i].se >> cb[i].fi;
    }
    RSORT(cb);
    int it = 1;
    REP(i, M){
        REP(j, cb[i].se){
            bitB.add(it++, cb[i].fi);
            if(it>N)break;
        }
        if(it>N)break;
    }
    
    ll ans = bitA.sum(N);
    REP(i, N){
        ans = max(ans, bitA.sum(N) - bitA.sum(i+1) + bitB.sum(i+1));
    }
    pr(ans);

    // int N,M;
    // cin >> N >> M;
    // vector<ll> A(N);
    // vector<pii> AI(N);
    // for (int i = 0; i < N; i++) {
    //     cin >> A[i];
    //     AI[i].fi = A[i];
    //     AI[i].se = i+1;
    // }
    // BIT bit(N);
    // REP(i, N){
    //     bit.add(i+1, A[i]);
    // }
    // vector<pii> cb(M);
    // REP(i, M){
    //     cin >> cb[i].se >> cb[i].fi;
    // }
    // SORT(AI);
    // RSORT(cb);
    // int ait = 0;
    // REP(i, M){
    //     if(ait == N) break;
    //     REP(j, cb[i].se){
    //         if(AI[ait].fi < cb[i].fi){
    //             bit.add(AI[ait].se, cb[i].fi - A[AI[ait].se-1]);
    //             ait++;
    //         }else{
    //             break;
    //         }
    //     }
    // }
    // pr(bit.sum(N));
    // return 0;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <bitset>
#include <stack>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
using namespace std;
typedef long long ll;
int n;

void solve(){
	scanf("%d",&n);
	printf("%d\n",n^1);
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 1732
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A9x9 solver = new A9x9();
        solver.solve(1, in, out);
        out.close();
    }

    static class A9x9 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            if (a <= 9 && b <= 9) out.println(a * b);
            else out.println(-1);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22868
#include <iostream>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>

void update(int a,int b);

using namespace std;

/*const double EPS = 1e-10;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,1,0,-1};
const int INF = 1001001001;*/

#define clear(a) memset((a), 0, sizeof(a))
#define mclear(a) memset((a), -1, sizeof(a))
#define show(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

pair<int, int> seg[1 << 18];



int main(){
  int n,r,l;
  int team[100000]={0};
  
  scanf("%d %d %d",&n,&r,&l);
  for(int i=0; i<n; i++) update(i,0);
  int watch=0,sento=0;

  for (int i=0;i<r;i++){
    int d,t,x;
    scanf("%d %d %d",&d,&t,&x);
    team[sento]+=t-watch;
    update(d-1,x);
    sento=seg[0].second-1;
    watch=t;
  }
  team[sento]+=l-watch;
  
  int maxi = 0;
  for (int i=1;i<n;i++){
    if(team[maxi]<team[i]) maxi=i;
  }
  printf("%d\n",maxi+1);
  return (0);
}



void update(int k, int x){
  int id = k + 1;
  k += (1 << 17) - 1;
  seg[k].first += x;
  seg[k].second = id;
  
  while (k){
    k = (k - 1) / 2;
    if (seg[k * 2 + 1].first > seg[k * 2 + 2].first){
      seg[k] = seg[k * 2 + 1];
    }
    else if (seg[k * 2 + 1].first < seg[k * 2 + 2].first){
      seg[k] = seg[k * 2 + 2];
    }
    else {
      seg[k] = seg[k * 2 + 1];
    }
  }

}

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

int n, W;
int v[3001], w[3001];
ll dp[3001][3001][2];
const ll M = 998244353;
ll rec(int i, int j, bool f) {
    if (i == 0 && j == 0 && !f) return 1;
    if (i == 0) return 0;
    if (dp[i][j][f] != -1) return dp[i][j][f];
    if (f && j - w[i] >= 0)
        return dp[i][j][f] =
                   (rec(i - 1, j, false) + rec(i - 1, j - w[i], false) + rec(i - 1, j, true) + rec(i - 1, j - w[i], true)) % M;
    return dp[i][j][f] = (rec(i - 1, j, true) + rec(i - 1, j, false)) % M;
}
int main() {
    memset(dp, -1, sizeof(dp));
    cin >> n >> W;
    reps(i, n) cin >> w[i];
    cout << (rec(n, W, false) + rec(n, W, true)) % M << endl;
    return 0;
}

Measured memory_bytes: 144592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using ProCon.Util;

namespace ProCon
{
    class Program
    {
        static void Main(string[] args)
        {
            AC134B();
        }

        static void AC134B()
        {
            //https://atcoder.jp/contests/abc135/tasks

            var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var N = input[0];
            var D = input[1];

            var target = D * 2 + 1; //一人の監視員が監視する本数

            var num = N % target == 0 ? N / target : N / target + 1;

            Console.WriteLine(num);
            Console.ReadKey();
        }

    }
}


Measured memory_bytes: 13268
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, sum int = 0, 0, 0

func main() {
	var N int
	var S string
	fmt.Scan(&N, &S)

	// i文字目から，j文字目から始まる文字列のうち最長のもの
	dp := make([][]int, N+5)
	for i := 0; i < N+5; i++ {
		dp[i] = make([]int, N+5)
	}
	for i := N - 1; 0 <= i; i-- {
		for j := N - 1; 0 <= j; j-- {
			if S[i] == S[j] {
				dp[i][j] = dp[i+1][j+1] + 1
			} else {
				dp[i][j] = 0
			}
		}
	}

	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			now := min(dp[i][j], j-i)
			ans = max(ans, now)
		}
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] > h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 208000
// uno {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }

// }}}

string s;
void input() {
    cin >> s;
}

void solve() {
    int ans = 0, i = 0, j = s.length()-1;
    while(i < j) {
        if(s[i] != s[j]) {
            ans++;
        }
        i++; j--;
    }
    printf("%d\n", ans);
}

int main( int argc, char *argv[] ) {
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
    while b: 
    	a, b = b, a % b
    return a
 
while True:
    try:
        line = input()
    except:
        break
    a, b = map(int, line.strip().split())
    g = gcd(a, b)
    print(g, a * b // g)

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

using namespace std;

#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if (s[0] == '7' || s[1] == '7' || s[2] == '7')
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3652
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  ll n,a,b; 
  cin >> n;
  int ans = 0;
  
  if(n % 2 == 0) ans += n/2;
  else ans += n/2 + 1;
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3556
from math import ceil
n,k=map(int,input().split())
s=list(input())

if s[0]=='R':
    s=['L' if i=='R' else 'R' for i in s]
p=[]
for i in range(n-1):
    if s[i]!=s[i+1]:
    	p.append(i)

unti=len(p)/2
kaisu=ceil(len(p)/2)

if kaisu<=k:
    print(n-1)
else:
	# if unti%2==0:
	# 	print(n-1-len(p)+k*2)
	# else:
	print(n-1-len(p)+k*2)
	# for i in range(k:)

    



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

using namespace std;
int main()
{
	vector<char> toDay(10);

	for (int i = 0; i < toDay.size(); i++)
	{
		cin >> toDay.at(i);
	}

	toDay.at(3) = '8';

	for (int i = 0; i < toDay.size(); i++)
	{
		cout << toDay.at(i);
	}

	cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

// ll dp[]

int main(){
  ll r;

  scanf("%lld", &r);

  printf("%f", 2.0*PI*(float)r);

  return 0;
}

Measured memory_bytes: 1752
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
# import numpy as np
starttime = time.time()
# import numpy as np
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

try:
    # sys.setrecursionlimit(int(pow(10,6)))
    sys.stdin = open("input.txt", "r")
    # sys.stdout = open("../output.txt", "w")
except:
    pass

n=L()[0]
A=[L() for i in range(n)]
dp=[[0,0,0] for i in range(n)]
dp[0]=A[0][::]
for i in range(1,n):
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+A[i][0]
    dp[i][1]=max(dp[i-1][0],dp[i-1][2])+A[i][1]
    dp[i][2]=max(dp[i-1][1],dp[i-1][0])+A[i][2]
print(max(dp[-1])) 

endtime = time.time()
# print(f"Runtime of the program is {endtime - starttime}")



Measured memory_bytes: 51760
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include <algorithm>

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

using namespace std;
typedef long long ll;
const int MAX = 1000100;

int head, tail;
int T[MAX];

void insertx(int x) {
	if (head != 0)T[head - 1] = x;
	else T[MAX - 1] = x;
	if (head != 0)head--;
	else head = MAX - 1;
}

void deletex(int x) {
	for (int i = head;;) {
		if (T[i] == x) {
			if (tail == 0) {
				for (int j = i; j != MAX - 1;) {
					T[j] = T[(j + 1) % MAX];
					j = (j + 1) % MAX;
				}
			}
			else {
				for (int j = i; j != tail - 1;) {
					T[j] = T[(j + 1) % MAX];
					j = (j + 1) % MAX;
				}
			}
			if (tail != 0)tail--;
			else tail = MAX - 1;
			return;
		}
		i = (i + 1) % MAX;
		if (i == tail)return;
	}
}

void deleteFirst() {
	head = (head + 1) % MAX;
}

void deleteLast() {
	if (tail != 0)tail--;
	else tail = MAX - 1;
}

int main() {
	int n, x;
	char s[20];

	cin >> n;
	head = 1;
	tail = 1;
	rep(i, n) {
		scanf("%s", s);
		if (strcmp(s, (const char*)"insert") == 0) {
			scanf("%d", &x);
			insertx(x);
		}
		else if (strcmp(s, (const char*)"delete") == 0) {
			scanf("%d", &x);
			deletex(x);
		}
		else if (strcmp(s, (const char*)"deleteFirst") == 0) {
			deleteFirst();
		}
		else if (strcmp(s, (const char*)"deleteLast") == 0) {
			deleteLast();
		}
	}

	for (int i = head;;) {
		if (i == tail - 1) {
			printf("%d\n", T[i]);
			break;
		}
		else if (i == MAX - 1 && tail == 0) {
			printf("%d\n", T[i]);
			break;
		}
		else {
			printf("%d ", T[i]);
		}
		i = (i + 1) % MAX;
	}
	return 0;
}


Measured memory_bytes: 7044
use std::vec::Vec;
use std::cmp::*;
use std::collections::HashSet;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();
    let a: Vec<usize> = read_vec();

    let mut v = [0; 1_000_000];
    for &e in &a {
      v[e] += 1;
    }

    let h: HashSet<usize> = a.into_iter().collect();

    let mut ans = 0;
    for x in h {
      let mut tmp = 0;
      if x > 0 {tmp += v[x-1];}
      tmp += v[x];
      tmp += v[x+1];
      ans = max(tmp, ans);

    }

    println!("{}", ans);

}


Measured memory_bytes: 10236
#include<bits/stdc++.h>
using namespace std;
long long a[100010];
int main(){
	long long n;
	cin>>n;
	long long res=0;
	long long cnt=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]<0)res++;
		a[i]=abs(a[i]);
		cnt+=a[i];
	}
	sort(a,a+n);
	if(res%2!=0){
		cout<<cnt-a[0]*2<<endl;
		return 0;
	}
	else if(res%2==0){
		cout<<cnt<<endl;
		return 0;
	}
	return 0;
}

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

int main() {
  bool ans=true;
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    int x;
    cin >> x;
    if(x%2==0&&x%3!=0&&x%5!=0) ans=false;
  }
  if(ans) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main(void) {
	int n, x, i, a = 1;
	cin >> n >> x;
	if (x == 1 || x == 2 * n - 1)
		printf("No\n");
	else {
		printf("Yes\n");
		for (i = 0; i < n - 2; i++) {
			if (a == x - 1)
				a = x + 2;
			printf("%d\n", a);
			a++;
		}
		printf("%d\n%d\n%d\n", x - 1, x, x + 1);
		for (i = 0; i < n - 2; i++) {
			if (a == x - 1)
				a = x + 2;
			printf("%d\n", a);
			a++;
		}
	}
	return 0;
}

Measured memory_bytes: 1536
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-8;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int x, y, z;
	while (scanf("%d%d%d", &x, &y, &z), x|y|z)
	{
		float p = 1.0 / x;
		int v[4], e[51], a[51];
		for (int i = 0; i < x; ++i)
			scanf("%d", v + i);
		memset(e, 0, sizeof(e));
		for (int i = 0; i < z; ++i)
		{
			int t;
			scanf("%d", &t);
			scanf("%d%d", e + t, a + t);
		}

		static float dp[51][5001];
		for (int i = 0; i <= y; ++i)
			for (int j = 0; j <= 5000; ++j)
				dp[i][j] = 0;
		dp[0][0] = 1;
		for (int i = 0; i < y; ++i)
		{
			for (int j = 0; j <= 5000; ++j)
			{
				if (dp[i][j] == 0)
					continue;

				for (int k = 0; k < x; ++k)
				{
					int to = min(y, i + v[k]);
					int money = j;
					if (e[to] == 1)
						to = min(y, to + a[to]);
					else if (e[to] == 2)
						money = min(5000, money + a[to]);
					else if (e[to] == 3)
						money = max(0, money - a[to]);

					dp[to][money] += dp[i][j] * p;
				}
			}
		}

		double res = 0;
		for (int i = 0; i <= 5000; ++i)
			res += i * dp[y][i];

		printf("%d\n", (int)res);
	}

	return 0;
}

Measured memory_bytes: 1876
using System;
using System.Collections.Generic;
class Solve{
    int N;
    int K;
    const long mod = 924844033;
    public Solve(){}
    public static int Main(){
        new Solve().Calc();
        return 0;
    }
    void Calc(){
        getinput();
        long count = 0;
        int length = (2*N-2*K)/(2*K);
        int larger = 2*N-2*K - (2*K)*length;
        int smaller = 2*K-larger;
        long[,] dp = new long[2*N,N+1];
        long[] fact = new long[N+1];
        for(int i=1;i<N+1;i++){
            dp[0,i] = 0;
            dp[1,i] = 0;
        }
        dp[1,1] = 1;
        for(int i=0;i<2*N;i++){
            dp[i,0] = 1;
        }
        for(int i=2;i<2*N;i++){
            if((i <= (length+2)*larger && i%(length+2) == 0) || ((i > (length+2)*larger) && ((i - (length+2)*larger)%(length+1) == 0))){
                for(int j=0;j<N+1;j++){
                    dp[i,j] = dp[i-1,j];
                }
            }
            else{
                for(int j=1;j<N+1;j++){
                    dp[i,j] = (dp[i-1,j]+dp[i-2,j-1])%mod;
                }
            }
        }
        {
            fact[0] = 1;
            for(int i=1;i<N+1;i++){
                fact[i] = i*fact[i-1]%mod;
            }    
        }
        for(int i=1;i<N+1;i++){
            if(i%2==0){
                count = (count - (fact[N-i]*dp[2*N-1,i])%mod + mod)%mod;
            }
            else{
                count = (count + (fact[N-i]*dp[2*N-1,i])%mod)%mod;
            }
        }
        Console.WriteLine((fact[N]-count+mod)%mod);
    }
    void getinput(){
        string[] str = Console.ReadLine().Split(' ');
        N = int.Parse(str[0]);
        K = int.Parse(str[1]);
    }    
}

Measured memory_bytes: 65240
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
#m = int(input())
h, w = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

black = 0
l = []
l.append(["#"] * (w+2))
for i in range(h):
    z = list(input())
    
    for j in range(len(z)):
        if z[j] == "#":
            black += 1
            
    z.append("#")
    z.insert(0, "#")
    l.append(z)
    
l.append(["#"] * (w+2))

q = deque([])
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
f = [[float("INF") for i in range(w+2)] for j in range(h+2)]

q.append((1, 1, 0))
f[1][1] = 0
while q:
    y, x, cnt = q.popleft()
    if y == h and x == w:
        print(h * w - black - cnt - 1)
        sys.exit()
    
    for i in range(4):
        if l[y+dy[i]][x+dx[i]] == "." and f[y+dy[i]][x+dx[i]] != 0:
            q.append((y+dy[i], x+dx[i], cnt+1))
            f[y+dy[i]][x+dx[i]] = 0

print(-1)
            
            
    
    













Measured memory_bytes: 10028
#include <iostream>
#include <algorithm>
#include <cstring>
#include<cstdio>
using namespace std;

int main()
{
	int n, a, b;

	cin >> n >> a >> b;

	if (a*n >= b)
		cout << b << endl;
	else
		cout << a*n<<endl;
	

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main(){
  int n;
  cin >> n;
  vvi a(n);
  int q;
  cin >> q;
  REP(i,q){
    int b,t;
    cin >> b >> t;
    if(b==0){
      int x;
      cin >> x;
      a[t].eb(x);
    }else if(b==1){
      REP(j,a[t].size()-1) cout << a[t][j] << " ";
      if(!a[t].empty()) cout << a[t].back() << endl;
      else puts("");
    }else{
      a[t].clear();
    }
  }
}



Measured memory_bytes: 8908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll n, ans;

int main() {
	fastio; cin >> n;
	FOR(i, 2, sqrt(n)) {
		ll c = 0;
		while (n % i == 0) {
			n /= i;
			c++;
		}
		FOR(i, 1, 100) if (c >= i) {
			ans++;
			c -= i;
		}
	}
	if (n > 2) ans++;
	cout << ans;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	if(m<=1)printf("0");
	
	else if(n>=m){
		printf("1");
	}
	else{
		for(int i=0;i<400;i++){
		if((i*n-i+1)>=m){
			printf("%d",i);
			break;
		}
	}
	}
	
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>
#include <cstdint>
#include <complex>
#include <bitset>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

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

class UnionFind {
public:
    int n;
    vector<int> parent;
    vector<int> rank;
    UnionFind(int m) {
        n = m;
        parent.resize(n);
        rank.resize(n, 0);
        for (int i = 0; i < n; i++) {
            parent[i] = i;
        }
    }

    int find(int node) {
        if (parent[node] == node) {
            return node;
        } else {
            parent[node] = find(parent[node]);
            return parent[node];
        }
    }

    void unite(int node1, int node2) {
        node1 = find(node1);
        node2 = find(node2);
        if (node1 == node2) {
            return;
        } else {
            if (rank[node1] < rank[node2]) {
                parent[node1] = node2;
            } else if (rank[node1] > rank[node2]) {
                parent[node2] = node1;
            } else {
                parent[node1] = node2;
                rank[node1] += 1;
            }
        }
    }

    bool same(int node1, int node2) {
        node1 = find(node1);
        node2 = find(node2);
        if (node1 == node2) {
            return true;
        } else {
            return false;
        }
    }
};

struct edge{
    int to, from, cost;
    edge(int to, int from, int cost): to(to), from(from), cost(cost) { };
};

bool compare(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
}

int main() {
    int n; cin >> n;
    vector<edge> graph;
    vector<pint> X, Y;
    rep(i, n) {
        int x, y; cin >> x >> y;
        X.push_back(make_pair(x, i));
        Y.push_back(make_pair(y, i));
    }
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    rep(i, n-1) {
        int u = X[i].second;
        int v = X[i+1].second;
        int cost = X[i+1].first - X[i].first;
        graph.push_back(edge(u, v, cost));
    }
    rep(i, n-1) {
        int u = Y[i].second;
        int v = Y[i+1].second;
        int cost = Y[i+1].first - Y[i].first;
        graph.push_back(edge(u, v, cost));
    }

    sort(graph.begin(), graph.end(), compare);

    UnionFind uf(n);
    ll ans = 0;
    rep(i, graph.size()) {
        int u = graph[i].to;
        int v = graph[i].from;
        int cost = graph[i].cost;
        if (uf.same(u, v)) continue;
        uf.unite(u, v);
        ans += cost;
    }

    cout << ans << endl;


    return 0;
}


    


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

int main()
{
  int n, x;
  cin >> n >> x;
  
  vector <int> a(n);
  for (int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  
  int ans = 0;
  while(ans < n){
    x -= a.at(ans);
    if (x < 0) break;
    ans++;
  }
  if (x > 0) ans--;
  cout << ans << endl;
}

Measured memory_bytes: 256
a = []
a = gets.split.map(&:to_i)
a.sort!
if (a[1] -a[0]) % 2 == 0
  puts (a[1] - a[0])/2 + a[2] - a[1]
  #puts (a[1] - a[0])/2
else
  puts 1 + (1 +a[1] - a[0])/2 + a[2] - a[1]
end

Measured memory_bytes: 1788