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

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

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s-1);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int p,q,r;
    cin >> p >> q >> r;

    cout << p+q+r-max({p,q,r}) << endl;
    return 0;
}


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

using namespace std;

int t,n;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  	cin>>t>>n;
	for (int i=-(t-1);i<=t-1;i++)
      cout<< n+i<<" ";
  return 0;
}

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

using namespace std;

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)

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

map<ll, int> mp;
int n, m, a;
ll acu = 0, res = 0;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> m;

	mp[0] = 1;
	for (int i = 0; i < n; i++) {
		cin >> a;
		acu += a;
		acu %= m;
		res += mp[acu];
		mp[acu]++;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int weight[1000000];
long long int value[1000000];
long long int dp[1000000]; 


int main(int argc, char const *argv[])
{
	int N, W;
	while(cin >> N >> W) {
		memset(weight, 0, sizeof(weight));
		memset(value, 0, sizeof(value));
		memset(dp, 0, sizeof(dp));
		for(int i=1; i<=N; i++){
			cin >> weight[i] >> value[i];
		}
		for(int i=1; i<=N; i++) {
			for(int j=W; j>=weight[i]; j--){
				dp[j] = max(dp[j], dp[j - weight[i]] + value[i]);
			}
		}
		cout << dp[W] << endl;
	}
	return 0;
}

Measured memory_bytes: 23096
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(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 emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int a[105];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int ans=0;
	int n;cin>>n;
	FOR(i,1,n)cin>>a[i];
	sort(a+1,a+n+1);
	FOR(i,1,n){
		FOR(j,i+1,n){
			FOR(k,j+1,n){
				if(a[k]-a[j]<a[i]&&a[k]-a[i]<a[j]&&a[i]!=a[j]&&a[j]!=a[k])ans++;
			}
		}
	}
	cout<<ans;
	RE 0;
}


Measured memory_bytes: 3644
S = int(input())
l = S // 100
r = S % 100

if (l<1 or l>12) and (r<1 or r>12):
    print('NA')
elif (l>=1 or l<=12) and (r==0 or r>12):
    print('MMYY')
elif (l==0 or l>12) and (r>=1 or r<=12):
    print('YYMM')
else:
    print('AMBIGUOUS')

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  map<int, int> mp;
  vector<int> ze{1, 3, 5, 7, 8, 10, 12}, on{4, 6, 9, 11}, tw{2};
  for (int i : ze) mp[i] = 0;
  for (int i : on) mp[i] = 1;
  for (int i : tw) mp[i] = 2;
  int x, y; cin >> x >> y;
  cout << (mp[x] == mp[y]? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int K, X;

int main()
{
    cin >> K >> X;
    int p = -300;
    while(p < 300){
        if(abs(p - X) < K)
            cout << p << " ";
        p++;
    }
}

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

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  string S;
  cin >> S;
  vector<string> ANS(N);
  int pass = 0;
  int foreign = 0;
  for(int i=0;i<N;i++){
    if(S.at(i) == 'c'){
      ANS.at(i) = "No";
    }else if(S.at(i) == 'a'){
      if(pass<A+B){
        ANS.at(i) = "Yes";
        pass ++;
      }else{
        ANS.at(i) = "No";
      }
    }else{
      if(pass<A+B && foreign<B){
        ANS.at(i) = "Yes";
        pass ++;
        foreign ++;
      }else{
        ANS.at(i) = "No";
      }
    }
  }
  for(int i=0;i<N;i++){
    cout << ANS.at(i) << endl;
  }
}

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

#define ff first
#define ss second
#define all(abcc) (abcc).begin(), (abcc).end()
#define endl '\n'
#define left aba
#define right abc

using namespace std;

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

const int N=(int)1e5+3;

int n, m, a, b;

vector<int> neigh[N], order;
bool used[N];
int dist[N];

void dfs(int curr) {
    used[curr]=1;

    for(int i:neigh[curr]) {
        if(!used[i]) {
            dfs(i);
        }
    }

    order.push_back(curr);
}

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

    cin>>n>>m;
    for(int i=0; i<m; ++i) {
        cin>>a>>b;
        neigh[a].push_back(b);
    }

    for(int i=1; i<=n; ++i) {
        if(!used[i]) {
            dfs(i);
        }
    }

    reverse(all(order));

    for(int i:order) {
        for(int j:neigh[i]) {
            dist[j]=max(dist[j], dist[i]+1);
        }
    }

    cout<<*max_element(dist+1, dist+1+n)<<endl;

    //cerr<<"Time: "<<(double)clock()/CLOCKS_PER_SEC<<"s"<<'\n';
    return 0;
}


Measured memory_bytes: 8824
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, n)
	for i := range as {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
	}
	m := make(map[int]int)
	for i := range as {
		m[as[i]]++
	}
	bs := make([]int, 0)
	for _, v := range m {
		bs = append(bs, v)
	}
	sort.Sort(sort.Reverse(sort.IntSlice(bs)))
	var sum int
	for i := 0; i < min(k, len(bs)); i++ {
		sum += bs[i]
	}
	fmt.Println(n - sum)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 22536
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        long mod = 1000000007;
        long ans = 0;
        int[] d = new int[N+1];
        for (int i = 0; i <= N; i++) {
            d[i] = i;
        }
        long[] s = new long[N+2];
        for (int i = 1; i <= N+1; i++) {
            s[i] += s[i-1] + d[i-1];
            s[i] %= mod;
        }
        for (int i = K; i <= N+1; i++) {
            ans += count(N, i, s, mod);
            ans %= mod;
        }
        System.out.println(ans);
    }
    long count(int N, int K, long[] s, long mod) {
        long min = s[K]+mod-s[0];
        min %= mod;
        long max = s[N+1]+mod-s[N+1-K];
        max %= mod;
        long t = max + mod - min;
        t %= mod;
        t += 1;
        t %= mod;
        return t;
    }
}


Measured memory_bytes: 29688
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){
		
		Scanner scanner = new Scanner(System.in); 
		int input_number = scanner.nextInt();
//		System.out.println(input_number*input_number*input_number);
		System.out.println(Math.round(Math.pow(input_number, 3)));
	}

}

Measured memory_bytes: 17180
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
int main(){
    int n,s;
    long long sum;
    cin  >> n >> s;
    sum = s;
    if(n>1){
        for(int i = 1; i < n; i++){
            sum*=(s-1);
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
/*
------------____________----------------
--------------CRISTIANO-----------------
SUUUUUUUUUIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
GOOOOOOOOOOOOOOAAAAAAAALLLLLLLLLLLLLLLLL
 
Author- Shubham Jha
IIIT- ALLAHABAD
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl "\n"
ll dp[100005],arr[100005]={0};
ll func(int n,int k)
{
    if(n<=1)
        return 0 ;
    if(dp[n]!=-1)
        return dp[n];
    else
    {
       ll mini=10101010101010;
       for(ll i=1;i<=k;i++)
       {
          if((n-i)<1)
            break;
          mini=min((abs(arr[n]-arr[n-i])+func(n-i,k)),mini);
       }
       dp[n]=mini;
    }
    return dp[n];
}
int main()
{
    int n,i,k;
    cin>>n>>k;
    ffor(i,1,n+1)
    {
      cin>>arr[i];
      dp[i]=-1;
    }
    dp[0]=0,dp[1]=0;
    cout<<func(n,k);

}

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

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

    m = n;

    int k = 0;

    for(int i = 0; m > 0; ++i){
        k += m % 10;
        m /= 10;
    }

    if(n % k == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
#include <tuple>
#include<iomanip>
#include<cmath>
using namespace std;
double const pi = acos(-1.0);
double f(pair<int,int>p1,pair<int,int>p2) {
	int x1, x2, y1, y2;
	tie(x1, y1) = p1;
	tie(x2, y2) = p2;
	double p = acos(1.0/(hypot(x1, y1)*hypot(x2, y2)) * (x1*x2 + y1 * y2)) * 180 / pi;
	return min(p, 360 - p);
}
int main() {
	int n; cin >> n;
	vector<pair<int, int>>v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i].first >> v[i].second;
	}
	sort(v.begin(), v.end());
	double res = 1e9;
	do {
		double a = 0;
		int x = 1, y = 0;
		int cx = 0, cy = 0;
		pair<int, int> p1, p2;
		for (int i = 0; i < n; ++i) {
		    p1 = make_pair(x, y);
			p2 = make_pair(v[i].first - cx, v[i].second - cy);
			a += f(p1, p2);
			tie(x, y) = p2;
			tie(cx, cy) = v[i];
		}
		p1 = make_pair(x, y);
		p2 = make_pair(-v.back().first, -v.back().second);
		a += f(p1, p2);
		res = min(res, a);
	} while (next_permutation(v.begin(), v.end()));
	cout << fixed << setprecision(16) << res << endl;
	return 0;
}


Measured memory_bytes: 3432
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int ta[24*60*60];
int main(){
	int n;
	while(true){
	cin>>n;
	if(n==0)break;
	for(int i=0;i<24*60*60;i++)ta[i]=0;
	int a,b,c,d,e,f;
	for(int i=0;i<n;i++){
	scanf("%d:%d:%d %d:%d:%d",&a,&b,&c,&d,&e,&f);
	int now=a*3600+b*60+c,next=d*3600+e*60+f;
	ta[now]++;
	ta[next]--;
	}
	for(int i=0;i<24*60*60-1;i++)ta[i+1]+=ta[i];
	int ans=0;
	for(int i=0;i<24*60*60;i++)ans=max(ans,ta[i]);
	cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1576
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}



  








      

 
  int main() {
   int n;
   cin >> n;
   ll a[n+1],cnt2 = 0,cnt4=0;
   rep (i,n){
     cin >> a[i];
     if (a[i]%4==0) cnt4++;
     if (a[i]%2==0 && a[i]%4!=0) cnt2++;
   }
   bool ok=false;
   if (cnt4 >= n/2) ok = true;
   else if (cnt4 + cnt2/2 >= n/2) ok = true;

   if (ok) cout << "Yes" << endl;
   else cout << "No" << endl;
  
   

}




Measured memory_bytes: 4380
#include<stdio.h>
#include<stdlib.h>


int compareInt(const void *a, const void *b){
  return *((const int *)b) - *((const int *)a);
}

int main(){
  int height[10];
  int i;

  for(i=0;i<10;i++){
    scanf("%d",&height[i]);
  }

  qsort(height, 10, sizeof(int), compareInt);

  printf("%d\n%d\n%d\n",height[0],height[1],height[2]);

  return 0;
}

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

#include <iostream>
#include <vector>
#include <algorithm>

inline int min(int x, int y) {return x < y ? x : y;}
inline long min(long x, long y) {return x < y ? x : y;}
inline int max(int x, int y) {return x > y ? x : y;}
inline long max(long x, long y) {return x > y ? x : y;}

inline void swap(int &a, int &b) {
    int tmp = a;
    a = b;
    b = tmp;
}

inline int euclid(int a, int b) {
    if (a > b) swap(a, b);
    int r = a % b;
    while (r > 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

using namespace std;
#define int long long int

class Store {
    public:
        int a, b;
        bool operator<(const Store& x) {
            return a < x.a;
        };
};

signed main() {
    int N, M;
    cin >> N >> M;
    vector<Store> stores(N);
    for (int i = 0; i < N; i++) {
        cin >> stores[i].a >> stores[i].b;
    }
    sort(stores.begin(), stores.end());

    int cnt = 0;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int price = stores[i].a;
        int num = stores[i].b;
        if (cnt + num >= M) {
            ans += (M - cnt) * price;
            break;
        }
        else {
            ans += num * price;
            cnt += num;
        }
    }

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


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, X;
  	cin >> N >> X;
    vector<int> L(N);
    for(int i=0; i<N; i++){
        cin >> L[i];
    }
    vector<int> D(N+1);
    D[0]=0;
    int cnt=1;
    for(int i=0; i<N; i++){
        D[i+1]=D[i]+L[i];
        if(X>=D[i+1]){
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

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

    int big_sum = 0;
    repi(i, 1, n+1){
        string num = to_string(i);
        int sum = 0;
        rep(i, num.size()){
            sum += num[i] - '0';
        }

        if(a <= sum && sum <= b) big_sum += i;
    }

    cout << big_sum << endl;
}

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

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

    string s;
    cin >> s;
    
    if (a < 3200)
    {
            cout << "red";
            return 0;
    }

    cout << s;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

ll mod_pow(ll x, ll n, ll mod = MOD) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	
	return res;
}

vector<ll> fact, inv;
void fact_inv(int n, ll mod = MOD) {
	fact.resize(n + 1);
	inv.resize(n + 1);
	
	fact[0] = 1;
	FOR(i, 1, n + 1) fact[i] = fact[i - 1] * i % mod;
	inv[n] = mod_pow(fact[n], mod - 2, mod);
	for (int i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}

ll ncr(ll n, ll r, ll mod = MOD) {
	if (n < r || r < 0 || n < 0) return 0;
	return fact[n] * inv[r] % mod * inv[n - r] % mod;
}

ll dp[212345], dp2[212345];

int main() {
	fact_inv(512345);
	
	int N;
	cin >> N;
	vector<ll> x(N);
	REP(i, N) scanf("%lld", &x[i]);
	
	ll ans = 0;
	
	REP(i, N - 1) {
		if (i == 0) dp[i] = 1;
		else {
			dp[i] = dp[i - 1] * (i + 1) % MOD;
			dp[i] = (dp[i] + fact[i]) % MOD;
		}
	}
	
	REP(i, N - 1) {
		ll cur = fact[N - 1] * inv[i + 1] % MOD;
		cur = cur * dp[i] % MOD;
		cur = cur * (x[i + 1] - x[i]) % MOD;
		ans = (ans + cur) % MOD;
	}
	
	cout << ans << endl;
	
	return 0;
}


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

int main(){
    long long ans=0,sum=0;
    int n,m;
    cin >> n;
    
    int a[n+1],b[n];

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

    for (int i = 0; i < n; i++){
        cin >>b[i];
    }


    if(n%2==0){

        for(int i = 0; i < (n+1)/2; i++){
            int t=min(b[i],a[i]);
            a[i] -=t;
            b[i] -=t;
            ans += t;

            int t1=min(b[i],a[i+1]);
            a[i+1] -= t1;
            ans += t1;
            b[i] -= t1;

            int t2=min(b[n-1-i],a[n-i]);
            a[n-i] -=t2;
            b[n-1-i] -=t2;
            ans += t2;

            int t3=min(b[n-1-i],a[n-i-1]);
            a[n-1-i] -= t3;
            ans += t3;
            b[n-1-i] -= t3;

        }

    }else{

        for(int i = 0; i < n/2 ; i++){

            int t=min(b[i],a[i]);
            a[i] -=t;
            b[i] -=t;
            ans += t;

            int t1=min(b[i],a[i+1]);
            a[i+1] -= t1;
            ans += t1;
            b[i] -= t1;

            int t2=min(b[n-1-i],a[n-i]);
            a[n-i] -=t2;
            b[n-1-i] -=t2;
            ans += t2;

            int t3=min(b[n-1-i],a[n-i-1]);
            a[n-1-i] -= t3;
            ans += t3;
            b[n-1-i] -= t3;

        }

        ans += min(b[n/2],a[n/2]+a[(n/2)+1]);
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
  

int task = 1;
const int mxN = 2e5 + 1;
const ll mod=1000000007;

const ll modi = 998244353; 


long long int binpow(ll a,ll b){
  ll res = 1;
  while(b>0){
    if(b&1)
      res = res*a%2019;
    a=a*a%2019;
    b>>=1;
  }
  return res;
}


void solve(){
  string s;
  cin >> s;
  long long int n = s.length();
  long long int div[n+1];
  div[n] = 0;
  map<long long int,long long int> mp;
  mp[0]++;
  for(long long int i =n-1;~i;i--){
    long long int num = s[i]-'0';
    div[i] = ((div[i+1])%2019+(num*binpow(10,n-1-i))%2019)%2019;
    // cout << num << endl;
    // cout << div[i] << endl;
    mp[div[i]]++;
  }

  // now need to find pairs i,j s.t. div3 = div673 =  0;

  long long int ans = 0;

  for(auto e: mp){
    ans = ans + (e.second*(e.second-1)/2);
  }

  cout << ans << endl;
}
 
 
int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output1.txt","w",stdout);
    #endif
    // int t;cin >> t;while(t--)
        // cout << "Case #" << task << ": " ;
        solve();
        // task++;
    // }

}

Measured memory_bytes: 5288
#include<iostream>
#include<cmath>
const double ESP=1e-10;
using namespace std;
int main(){

  double ax,ay,bx,by,cx,cy,dx,dy;
  while(cin>>ax>>ay>>bx>>by>>cx>>cy>>dx>>dy){
    if(fabs((by-ay)*(dy-cy)+(bx-ax)*(dx-cx))<ESP)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;

  }
}

Measured memory_bytes: 1216
#include <iostream>
#include <algorithm>
#include <math.h>
#include <complex>
#include <iomanip>

using namespace std;

int main(){
	int d, e;
	while(cin >> d >> e, d || e){
		double ans = INFINITY;
		for(int x = 1; x <= d; x++){
			int y = d - x;
			double tmp = sqrt((double)x*x + y*y);
			ans = min(ans, abs(e - tmp));
		}
		cout <<fixed;
		cout <<setprecision(8) << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3204
w, h = [eval(x) for x in input().split()]
sharp, dot = '#', '.'
while w != 0 and h != 0:
  for i in range(w):
    if i % 2 == 0:
      newsharp, newdot = sharp, dot
    else:
      newsharp, newdot = dot, sharp
    for j in range(h):
      if j % 2 == 0:
        print(newsharp, end='')
      else:
        print(newdot, end='')
    print()
  print()
  w, h = [eval(x) for x in input().split()]



Measured memory_bytes: 6976
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int N;cin>>N;
    if(N%1000==0){
        cout << 0 << endl;
        return 0;
    }
    cout << 1000-(N%1000) << endl;
    return 0;
}


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

import itertools, math

lst = []
for i in range(n):
  x, y = [int(elem) for elem in input().split()]
  lst.append((x, y))

tmp = [i for i in range(n)]
pairs = list(itertools.combinations(tmp, 2))
ds = {}
for a, b in pairs:
  d = math.sqrt((lst[a][0] - lst[b][0]) ** 2 + (lst[a][1] - lst[b][1]) ** 2)
  if not a in ds:
    ds[a] = {}
    ds[a][b] = d
  else:
    ds[a][b] = d

cands = list(itertools.permutations(tmp, n))
result = 0
for cand in cands:
  res = 0
  for i, elem in enumerate(cand[:-1]):
    if elem in ds and cand[i+1] in ds[elem]:
      res += ds[elem][cand[i+1]]
    else:
      res += ds[cand[i+1]][elem]
  result += res
print(result / len(cands))

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

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int N, W;
int v[50], w[50];

vector<pii> generate(int s, int n) {
    vector<pii> ret;
    rep(bit,0,1<<n) {
        int value = 0, weight = 0;
        rep(i,0,n) {
            if(bit >> i & 1) {
                value += v[s+i];
                weight += w[s+i];
            }
        }
        if(weight <= W) ret.pb(pii(weight, value));
    }
    sort(ret.begin(), ret.end());
    return ret;
}

void solve() {
    int r1 = N/2, r2 = N - r1;
    vector<pii> tb1 = generate(0,r1), tb2 = generate(r1,r2);

    int ans = 0, t = 0, ma = 0;
    repr(i,tb1.size()-1,0) {
        int nw = tb1[i].fr, nc = tb1[i].sc;
        while(t < tb2.size() && tb2[t].fr + nw <= W) {
            ma = max(ma, tb2[t++].sc);
        }
        ans = max(ans, ma + nc);
    }
    cout << ans << endl;
}

signed main() {
    cin >> N >> W;
    rep(i,0,N) cin >> v[i] >> w[i];
    solve();
    return 0;
}

Measured memory_bytes: 43572
#include<bits/stdc++.h>
using namespace std;
#define first F
#define second S
typedef pair<int,int> P;
typedef vector<int> v;
char mas[1111][1111];
bool a[1001][1001];
int main(){
  char key[2][2];
  int N,M;
  int cnt;
  int ans=-111;
  cin>>M>>N;
  for(int i=0;i<M;i++){
    for(int j=0;j<N;j++){
      cin>>mas[i][j];
    }
  }
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      cin>>key[i][j];
    }
  }
  int a_cnt=0;
  for(int i=0;i<M-1;i++){
    for(int j=0;j<N-1;j++){
      cnt=0;
      for(int k=0;k<2;k++){
	for(int l=0;l<2;l++){
	  if(mas[i+k][j+l]==key[k][l]){
	    cnt++;
	  }
	}
      }
      if(cnt==4) a_cnt++;
    }
  }
 
  int dx[]={-1,-1,0,0};
  int dy[]={-1,0,-1,0};
  char joi[]={'J','O','I'};
  for(int i=0;i<M;i++){
    for(int j=0;j<N;j++){
      for(int mozi=0;mozi<3;mozi++){
	if(mas[i][j]==joi[mozi]) continue;
	char tmp=mas[i][j];
	mas[i][j]=joi[mozi];
	cnt=0;
	for(int k=0;k<4;k++){
	  int nx=i+dx[k];
	  int ny=j+dy[k];
	  int ret=0;
	  if(0<=nx && nx<M-1 && 0<=ny && ny<N-1){
	    
	    for(int m=0;m<2;m++){
	      for(int l=0;l<2;l++){
		if(mas[nx+m][ny+l]==key[m][l]){
		  ret++;
		}
	      }
	    }
	    if(ret==4) cnt++;
	  }
	}
	ans=max(ans,cnt);
	mas[i][j]=tmp;
      }
    }
  }
  cout<<ans+a_cnt<<endl;
  return 0;
}
	

Measured memory_bytes: 2256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    for(int i=0; i<7; ++i){
        int a, b;
        cin >> a >> b;
        cout << (a - b) << endl;
    }
    return 0;
}

Measured memory_bytes: 1164
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int N = S.Length;
		long[] dp = new long[4];
		long mod = (long) 1e9 + 7;
		dp[0] = 1;
		for(int i=0;i<N;i++){
			long[] nxt = new long[4];
			
			if(S[i] == 'A' || S[i] == '?'){
				for(int j=0;j<4;j++){
					nxt[j] += dp[j]; if(nxt[j] >= mod) nxt[j] -= mod;
				}
				nxt[1] += dp[0]; if(nxt[1] >= mod) nxt[1] -= mod;
			}
			if(S[i] == 'B'|| S[i] == '?'){
				for(int j=0;j<4;j++){
					nxt[j] += dp[j]; if(nxt[j] >= mod) nxt[j] -= mod;
				}
				nxt[2] += dp[1]; if(nxt[2] >= mod) nxt[2] -= mod;
			}
			if(S[i] == 'C'|| S[i] == '?'){
				for(int j=0;j<4;j++){
					nxt[j] += dp[j]; if(nxt[j] >= mod) nxt[j] -= mod;
				}
				nxt[3] += dp[2]; if(nxt[3] >= mod) nxt[3] -= mod;
			}
			dp = nxt;
		}
		
		Console.WriteLine(dp[3]);
		
	}
	String S;
	public Sol(){
		S = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int main(){
int n;cin>>n;
vector<int> s(n);
for(int i=0;i<n;i++) cin>>s[i];
sort(s.begin(),s.end());
int q;cin>>q;
int ans=0;
for(int i=0;i<q;i++){
int t;cin>>t;
if(lower_bound(s.begin(),s.end(),t)!=s.end()&&*lower_bound(s.begin(),s.end(),t)==t){
ans++;
}
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> c(h);
    vector<vector<int>> a(h, vector<int>(w));
    for (int i = 0; i < h; i++) {
        cin >> c[i];
    }
    int id = 1;
    int f = -1, lb = -1;
    for (int i = 0; i < h; i++) {
        int co = 0;
        for (int j = 0; j < w; j++) {
            if (c[i][j] == '#') {
                co++;
            }
        }
        if (co == 0) {
            if (f != -1) {
                a[i] = a[i - 1];
            } else {
                lb = i;
            }
        } else {
            int t = 1;
            for (int j = 0; j < w; j++) {
                a[i][j] = id;
                if (c[i][j] == '#' && t < co) {
                    id++;
                    t++;
                }
            }
            if (f == -1) {
                f = i;
            }
            id++;
        }
    }
    for (int i = 0; i <= lb; i++) {
        a[i] = a[f];
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << a[i][j];
            if (j < w - 1) {
                cout << " ";
            } else {
                cout << endl;
            }
        }
    }
}

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

#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define All(obj) (obj).begin(),(obj).end()
#define REP(n) for(int i=0;i<(n);++i)
#define REPR(n) for(int i=(n-1); i>=0;--i)
#define FOR(i,b,n) for(int i=(b);i<(n);++i)

typedef long long ll;

const int M=2e5+5;
const int INF=2e9;
const int MOD=1e9+7; //prime number
/*
vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
vector<int> split_into_num(const string &str, char sep)
{
    vector<int> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(stoi(buffer));
    }
    return v;
}
*/
int gcd(int a, int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
bool isPrime(int a)
{
    if(a==2)
        return true;
    else if(a<=1 or a%2 == 0)
        return false;

    for(int i = 3; i <= sqrt(a); i+=2)
    {
        if(a%i==0)
            return false;
    }
    return true;
}
void BubbleSort(vector<string> &v, int n)
{
    int a,b;
    for(int i = 0; i < n-1; ++i)
    {
        bool swapped = false;
        for(int j = 0; j < n-i-1; ++j)
        {
            a = v[j][1] - '0';
            b = v[j+1][1] - '0';
            if(a > b)
            {
                swap(v[j],v[j+1]);
                swapped = true;
            }
        }
        if(swapped == false)
            break;
    }
}
long long mod(long long val, long long m)
{
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}
void SelectionSort(vector<string> &v, int n)
{
    bool swapped;
    int index,a,b;
    for(int i = 0; i < n-1; ++i)
    {
        swapped = false;
        index = i;
        for(int j = i+1; j < n; ++j)
        {
            a = v[index][1] - '0';
            b = v[j][1] - '0';
            if(a>b)
            {
                index = j;
                swapped = true;
            }
        }
        if(swapped)
        {
            swap(v[i],v[index]);
        }
    }
}

void Solve()
{
    int n;
    cin >> n;
    if(n == 1)
        cout << 0;
    else if( n == 2)
        cout << 2;
    else
    {
        ll num1=1,num2=1,num3=1;
        for(int i = 0; i < n; ++i)
        {
            num1=(num1*10)%MOD;
            num2=(num2*9)%MOD;
            num3=(num3*8)%MOD;
        }
        num2 = ((num2%MOD)*2)%MOD;
        cout << (mod((num1%MOD)-(num2%MOD),MOD) + num3%MOD)%MOD;

    }
}
int main()
{
    fastio;
    Solve();

    return 0;
}



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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  int count = 0, now = 1;
  for(int i = 0; i < n; i++){
    if(a.at(i) == now){
      count++;
      now++;
    }
  }
  
  if(count == 0) cout << -1 << "\n";
  else cout << n - count << "\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define rl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back


#define L_B lower_bound
#define U_B upper_bound

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf (1000*1000*1000+5)
#define mod 1000000007
#define maxn 100009
#define maxr 100009

void solve()
{

	ll h;
	rl(h);
	ll x=log2(h);
	x++;
	x=pow(2LL,x)-1;
	cout<<x<<endl;

}
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	solve();
	return 0;
}

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

using namespace std;

using ll = long long;

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

typedef pair<int, int> P;

const int MOD = (int) 1e9 + 7;

template<class T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}

template<class T>
bool chmin(T &a, const T &b) {
	if (b < a) {
		a = b;
		return 1;
	}
	return 0;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

bool compare(P a, P b) {
	if (a.first * a.first + a.second * a.second == b.first * b.first + b.second * b.second) return a.first < b.first;
	return a.first * a.first + a.second * a.second < b.first * b.first + b.second * b.second;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	while (1) {
		int h, w;
		cin >> h >> w;
		if (h == 0) break;
		
		vector<P> v;
		FOR(i, 1, 151) {
			FOR(j, i + 1, 151) {
				v.push_back(P(i, j));
			}
		}
		
		sort(ALL(v), compare);
		
		int t;
		REP(i, v.size()) {
			if (P(h, w) == v[i]) {
				t = i;
				break;
			}
		}
		
		cout << v[t + 1].first << " " << v[t + 1].second << endl;
		
	}
	
	
	return 0;
}


Measured memory_bytes: 3256
#include <stdio.h>
#include <stdbool.h>

int main(void) {
  char S[5];
  scanf("%s", S);
  bool flag = false;
  for(int i = 0; i < 3; i++) {
    if(S[i] == S[i+1]) {
      flag = true;
      break;
    }
  }
  
  if(flag)
     printf("Bad\n");
  else
     printf("Good\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if (a + b - c >= 0) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100000+10

using namespace std;
char y[MAXN];//0表示x，1表示o
bool an[MAXN];//0表示狼
int n;
void print(){
    for(int i=1;i<=n;i++){
        if(an[i]) printf("S");
        else printf("W");
    }
    printf("\n");
    exit(0);
}
bool fd(){
    for(int i=2;i<=n;i++){//羊说o和狼说x，前后应该相同
        if(an[i]){//羊
            if(y[i]=='o')   an[i+1]=an[i-1];
            else an[i+1]=!an[i-1];
        }
        else {
            if(y[i]=='o')   an[i+1]=!an[i-1];
            else an[i+1]=an[i-1];
        }
    }
    if(an[n]){//n是羊
        if(y[n]=='o'&&an[1]==an[n-1]){//羊说相同确实相同
            if(an[1]){//羊
                if(y[1]=='o'&&an[2]==an[n]) print();
                else if(y[1]=='x'&&an[2]!=an[n])    print();
            }
            else {//狼
                if(y[1]=='o'&&an[2]!=an[n]) print();
                else if(y[1]=='x'&&an[2]==an[n])    print();
            }
        }
        else if(y[n]=='x'&&an[1]!=an[n-1]) {//羊说不同
            if(an[1]){//羊
                if(y[1]=='o'&&an[2]==an[n]) print();
                else if(y[1]=='x'&&an[2]!=an[n])    print();
            }
            else {//狼
                if(y[1]=='o'&&an[2]!=an[n]) print();
                else if(y[1]=='x'&&an[2]==an[n])    print();
            }
        }
    }
    else {//n是狼
        if(y[n]=='o'&&an[1]!=an[n-1]){//羊说相同确实相同
            if(an[1]){//羊
                if(y[1]=='o'&&an[2]==an[n]) print();
                else if(y[1]=='x'&&an[2]!=an[n])    print();
            }
            else {//狼
                if(y[1]=='o'&&an[2]!=an[n]) print();
                else if(y[1]=='x'&&an[2]==an[n])    print();
            }
        }
        else if(y[n]=='x'&&an[1]==an[n-1]) {//羊说不同
            if(an[1]){//羊
                if(y[1]=='o'&&an[2]==an[n]) print();
                else if(y[1]=='x'&&an[2]!=an[n])    print();
            }
            else {//狼
                if(y[1]=='o'&&an[2]!=an[n]) print();
                else if(y[1]=='x'&&an[2]==an[n])    print();
            }
        }
    }
}

int main(){
    char a;
    scanf("%d",&n);
    getchar();
    for(int i=1;i<=n;i++){
        y[i]=getchar();
    }
    an[1]=1,an[2]=1;//都是羊
    fd();
    an[1]=0,an[2]=0;//都是狼
    fd();
    an[1]=1,an[2]=0;//羊 狼
    fd();
    an[1]=0,an[2]=1;//狼 羊
    fd();
    printf("-1");
    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>

int solve(){
  char s[10000];
  int joi = 0,ioi = 0;
  if(scanf("%s",s)==EOF) return 1;
  int l = strlen(s);
  for(int i=1;i<l-1;i++){
    if(s[i]=='O'&&s[i+1]=='I'){
      if(s[i-1]=='J') joi++;
      if(s[i-1]=='I') ioi++;
    }
  }
  printf("%d\n%d\n",joi,ioi);
  return 0;
}

int main(){
  while(true) if(solve()) return 0;
}

Measured memory_bytes: 2616
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

int a,b,c;
int main(void){
    cin >> a >> b >> c;
    cout << c << " " << a  << " " << b << endl;
    return 0;
}



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

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n,ma,mb;
    cin>>n>>ma>>mb;
    vector<vector<int>> dp(500,vector<int>(500,inf));
    dp[0][0] = 0;
    for(int i=0;i<n;++i){
        int a,b,c;
        cin>>a>>b>>c;
        for(int ai=400;ai>=0;--ai){
            for(int bi=400;bi>=0;--bi){
                if(ai - a >=0 and bi - b >= 0)dp[ai][bi] = min(dp[ai][bi],dp[ai-a][bi-b] + c);
            }
        }
    }
    int mi = inf;
    for(int a=1;a<=400;++a){
        for(int b=1;b<=400;++b){
            if(a*mb == b*ma)mi = min(mi,dp[a][b]);
        }
    }
    if(mi == inf)cout << -1 << endl;
    else cout << mi << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

ll ans = 0;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a, b, n;
    cin>>a>>b>>n;
    ll cur = (n+1)/b * b - 1;
    if(cur>0){
        ans = a*cur/b - a*(cur/b);
    }
    ans = max(ans, a*n/b - a*(n/b));
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3652
import java.util.*;

public class Main {

    public static void main(String[] args) {

        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] list = new int[n + 2];
        int[] gaps = new int[n + 2];

        int sum = 0;
        for (int i = 1; i <= n; i++) {
            list[i] = sc.nextInt();
        }
        for (int i = 0; i < n + 1; i++) {
            gaps[i] = Math.abs(list[i] - list[i + 1]);
            sum += gaps[i];
        }


        for (int i = 1; i <= n; i++) {
            System.out.println(sum - gaps[i] - gaps[i - 1] + Math.abs(list[i - 1] - list[i + 1]));
        }
    }
}

Measured memory_bytes: 63960
#include <stdio.h>
 
int main()
{
int n,m,i,g=0;
float sum=0;
  
scanf("%d%d",&n,&m);
int a[n];
for(i=0;i<n;i++){
	scanf("%d",&a[i]);
	sum+=a[i];
}
 
for(i=0;i<n;i++){
	if((float)a[i]>=sum/4/m){g++;}
	if(g>=m){break;}
}
if(g>=m){printf("Yes\n");}
else{printf("No\n");}
return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,M;
    cin >> N >> M;
    int count=0;
    if(N>=2){
        count+=N*(N-1)/2;
    }
    if(M>=2){
        count+=M*(M-1)/2;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define exchange(a,b) {typeof(a) __tmp=a;a=b;b=__tmp;}

int Partition(int A[], int p, int r) {
  int i,j;
  int x;
  x = A[r];
  i = p-1;
  for(j = p; j < r; ++j) {
    if(A[j] <= x) {
      i = i+1;
      exchange(A[i], A[j]);
    }
  }
  exchange(A[i+1], A[r]);
  return i+1;
}


int main() {
  int i;
  int n, p;
  int A[100001];
  scanf("%d", &n);
  for(i = 1; i <= n; ++i)
    scanf("%d", A+i);
  p = Partition(A,1,n);
  for(i = 1; i <= n; ++i) {
    if(i-1) printf(" ");
    if(i == p)
      printf("[%d]", A[i]);
    else
      printf("%d", A[i]);
  }
  printf("\n");
  return 0;
}

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

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
//#define int ll
const int INF = 1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

signed main() {
	ios::sync_with_stdio(true);
	int x;
	cin >> x;
	while (true) {
		if (IsPrime(x)) break;
		x++;
	}
	cout << x << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;

const int MaxN = 1e5;

int n;
int all, pre[2 * MaxN + 5], last[MaxN + 5], other[2 * MaxN + 5];
int dep[MaxN + 5], fa[MaxN + 5], size[MaxN + 5];

void Build(int x, int y) {
	pre[++all] = last[x];
	last[x] = all;
	other[all] = y;
}

void Dfs(int x, int y) {
	size[x] = 1; dep[x] = dep[y] + 1; fa[x] = y;
	int ed = last[x], dr;
	while(ed != -1) {
		dr = other[ed];
		if(dr != y) {
			Dfs(dr, x);
			size[x] += size[dr];
		}
		ed = pre[ed];
	}
}

int main() 
{
	all = -1; memset(last, -1, sizeof(last));
	scanf("%d", &n);
	for(int i = 1; i < n; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		Build(u, v); Build(v, u);
	}
	dep[0] = 0;
	Dfs(1, 0);
	int tot = dep[n] - dep[1] - 1;
	tot /= 2;
	int t = n;
	while(tot > 0) {
		t = fa[t];
		tot--;
	}
	if(size[t] >= n - size[t]) printf("Snuke\n");
	else printf("Fennec\n");
}

Measured memory_bytes: 8064
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long
using namespace std;

int main() {
    string s;
    cin >> s;
    if (s.compare("ABC") == 0) {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
    return 0;
}


Measured memory_bytes: 3580