akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
#define Mx 200001
#define inf 1e15
const int MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


typedef long long  L;
//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a1,a2,a3,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,q,q1,q2,q3,q4,r,s,t,
u,v,x,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id1,id2,id3,id4,lim;

//double rat;
L A[Mx+5],B[Mx+5];

char str[Mx];

// vector<L>V,V1;
// set<L>S;
// map<L,L>Mp;
// priority_queue<L>Pq;

//struct node{L nid,nv;node(L nid_,L nv_){nid=nid_;nv=nv_;}};
//vector<node>V;
void solve(){
    if(n>=10)printf("%lld\n",m);
    else printf("%lld\n",(m)+(100*(10-n)));
}
int main()
{
    scanf("%lld%lld",&n,&m);
    solve();
    return 0;
}
/// lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue 


Measured memory_bytes: 256
#include <bits/stdc++.h>
const double pi = 3.141592653589793238463;
using namespace std;
int main(){
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	double time = h + (double)m/60;
	double angle1_hr = (pi/6)*time;
	double angle1_min = 2*pi*time;
	double angle2_hr = 2*pi - (ceil(time/12)*2*pi - angle1_hr);
	double angle2_min = 2*pi - (ceil(time)*2*pi - angle1_min);
	double angle = abs(angle2_hr - angle2_min);
	if(angle > 2*pi){
		angle = 2*pi - angle;
	}
	double ans = sqrt(pow(a, 2)+pow(b, 2)-2*a*b*cos(angle));
	cout.precision(20);
	cout << fixed << ans;
}


Measured memory_bytes: 4188
import sys
input = sys.stdin.readline

import bisect
from itertools import accumulate

N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
A.sort()

left = -1
right = 1 + 2 * 10 ** 5

def shake(x):
    cnt = 0
    for i in A:
        cnt += N - bisect.bisect_left(A, x - i)
    if cnt >= M:
        return 1
    else:
        return 0

while True:
    mid = (left + right) // 2
    if shake(mid):
        if not shake(mid + 1):
            X = mid
            break
        else:
            left = mid
    else:
        if shake(mid - 1):
            X = mid - 1
            break
        else:
            right = mid

happy = 0
cumsum_A = list(accumulate(A))

for j in A:
    idx = bisect.bisect_right(A, X - j)
    cnt = N - idx
    if cnt == N:
        happy += cumsum_A[-1] + cnt * j
    else:
        happy += cumsum_A[-1] - cumsum_A[idx - 1] + cnt * j
    M -= cnt

happy += M * X

print(happy)


Measured memory_bytes: 59664
using System;
using System.Linq;

namespace Sample
{
	class Program
	{
		static void Main(string[] args)
		{
			var array = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();

			var a = array[0];
			var b = array[1];

			var x = a / b;
			var y = a % b;
			var z = a / (double)b;


			Console.WriteLine("{0} {1} {2:0.#########}", x, y, z);
		}
	}
}



Measured memory_bytes: 18424
#include <bits/stdc++.h>
using namespace std;
struct P
{
    int x,y;
    bool operator<(const P &a)const{
        if(y!=a.y) return y>a.y;
        return x>a.x;

    }

};
vector<int> v[100100],v1[100100];
//bitset<4001000> b;
int i,n,d,m,k,a,b,c,e;
int o[111000];
int l[100003];
int j[3];
int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=1000000007,mod2=1000000009,mod3=2017;
long long x,z[11][5555],y;
double pi=3.14159265;
P u[100111];
stack<int> s;
//set<long long> s;
//priority_queue<int> q;
queue<int> q;
//string r;
char r[551];
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;

/*struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> p;//safe_map;
*/
bool as(P a,P b)
{
    return a.x+a.y<b.x+b.y;
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//rng();

int main()
{
    scanf("%d %d %d",&a,&b,&c);
    n+=min(a+b+1,c)+b;
    printf("%d",n);
}



Measured memory_bytes: 4992
using System;
using System.Linq;

namespace _2440
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] users = new string[n];
            for (int i = 0; i < n; i++) users[i] = Console.ReadLine();
            int m = int.Parse(Console.ReadLine());
            bool close = true;
            for (int i = 0; i < m; i++)
            {
                string s = Console.ReadLine();
                if (users.Contains(s))
                {
                    Console.WriteLine((close ? "Opened" : "Closed") + " by " + s);
                    close = !close;
                }
                else
                {
                    Console.WriteLine("Unknown " + s);
                }
            }
        }
    }
}


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

using namespace std;

bool solve(const vector<string>& W) {
  const int n = W.size();
  // condition 1
  for (int i = 0; i < n-1; ++i) {
    if (W[i].back() != W[i+1].front()) {
      return false;
    }
  }
  // condition 2
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      if (W[i] == W[j]) {
        return false;
      }
    }
  }
  return true;
}

vector<string> input() {
  int n; cin >> n;
  vector<string> W(n);
  for (int i = 0; i < n; ++i) {
    cin >> W[i];
  }
  return W;
}

int main() {
  const vector<string> W = input();
  if (solve(W)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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


int counta=0;
int countb=0;
void checkA(int a){
    counta++;
    if(a/10!=0)checkA(a/10);
}
void checkB(int a){
    countb++;
    if(a/10!=0)checkB(a/10);
}
int main(){
    long n;
    cin>>n;
    long ans=100;
    for (int i=1; i<=(int)sqrt(n)+1; i++){
        if(n%i==0){
            counta=0;
            countb=0;
            int a=i;
            int b=n/i;
            checkA(a);
            checkB(b);
            long f=max(counta,countb);
            ans=min(ans,f);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string a; cin >> a;
	int s = 0;
	for(int i = 0; i < a.size(); i++) s += a[i] - '0';
	cout << (s % 9 ? "No" : "Yes");

	return 0;
}

Measured memory_bytes: 3748
#include <stdio.h>

int A[1000000],n;
int binarysearch(int key)
{
  int left = 0;
  int right = n;
  int mid;
  while( left < right )
  {
    mid = (left + right)/2 ;
    if(key == A[mid])return 1;
    if(key > A[mid])left = mid+1;
    else if(key < A[mid]) right = mid;
  }
  return 0;
}

int main()
{
  int i,q,k,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++)
  {
    scanf("%d",&k);
    if( binarysearch( k ))sum++;
  }
  printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 2108
from collections import defaultdict
n,p = [int(x) for x in input().split()]
s = input()
if p!=2 and p!=5:
  r = defaultdict(int)
  a = int(s)
  r[a%p]+=1
  for i in range(n):
    a = (a%p-int(s[i])%p*pow(10,(n-1-i),p))%p
    r[a]+=1
  #print(r)
  ans = 0
  cnt=1
  for i in r.values():
    ans+=i*(i-1)//2
  print(ans)
elif p==2:
  ans = 0
  for i in range(n):
    if int(s[i])%2==0:
      ans +=i+1
  print(ans)
elif p==5:
  ans = 0
  for i in range(n):
    if int(s[i])%5==0:
      ans +=i+1
  print(ans)

Measured memory_bytes: 46380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,ans;
  cin>>a>>b;
  if (a<=5) {
    ans=0;
  }
  else if (a<=12) {
    ans = b/2;
  }
  else {
    ans=b;
  }
  cout << ans << endl;
}

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

using namespace std;

#define INF int(1e9)
#define ii pair<int, int>
#define vi vector<int>
#define mp make_pair
#define pb push_back
#define x first
#define y second

#define LL long long int 

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


int main () {
    ios_base::sync_with_stdio(false);

    LL a, b;
    cin >> a >> b;
    cout << (a*b)/gcd(a, b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int INF=0x3f3f3f3f;

int main()
{
    int n;
    cin>>n;
    if(n%10==3)
        cout<<"bon";
    else if(n%10==0||n%10==1||n%10==6||n%10==8)
        cout<<"pon";
    else
        cout<<"hon"<<endl;
    return 0;
}




Measured memory_bytes: 3620
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,q=map(int,input().split())
    E=[[] for _ in range(n)]
    for _ in range(n-1):
        a,b=map(int,input().split())
        a-=1; b-=1
        E[a].append(b)
        E[b].append(a)

    C=[0]*n
    for _ in range(q):
        p,x=map(int,input().split())
        p-=1
        C[p]+=x

    Q=[(0,-1)]
    while(Q):
        v,p=Q.pop()
        for nv in E[v]:
            if(p==nv): continue
            C[nv]+=C[v]
            Q.append((nv,v))

    print(*C)
resolve()

Measured memory_bytes: 97024
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    ll n,m;
    cin>>n>>m;
    ll q;
    cin>>q;
    vi a(q),b(q),c(q),d(q);
    rep(i,0,q)cin>>a[i]>>b[i]>>c[i]>>d[i],a[i]--,b[i]--;
    vi res(n+m-1,1);
    rep(i,0,m-1)res[i]=0;
    ll ans=0;
    do{
        vi A(n,1);
        int cnt=0;
        int Ai=0;
        rep(i,0,n+m-1){
            if(!res[i])cnt++;
            else A[Ai++]+=cnt;
        }
        ll tmp=0;
        rep(i,0,q){
            if(A[b[i]]-A[a[i]]==c[i])tmp+=d[i];
        }
        chmax(ans,tmp);
    }while(next_permutation(res.begin(),res.end()));
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    string n;
    cin>>n;
    if(n[0]==n[2]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using namespace std;

typedef long long LL;

const int N = 1e5 + 10;
int a[N];

int main() {
    int n;
    scanf("%d", &n);
    LL sum = 0;
    for (int i = 0; i < n; i++) scanf("%d", a + i), sum += a[i];
    if (sum % (1ll * n * (n + 1) / 2)) {
        puts("NO");
        return 0;
    }
    sum /= 1ll * n * (n + 1) / 2;
    LL cnt = 0;
    for (int i = 1; i < n; i++) {
        int t = a[i] - a[i-1];
        if (t > sum || (sum - t) % n) {
            puts("NO");
            return 0;
        }
        cnt += (sum - t) / n;
    }
    if (cnt <= sum) puts("YES");
    else puts("NO");
    return 0;
}


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

using namespace std;

#define bug(x) do{cerr<<#x<<": "<<x;}while(0) 
#define bugv(x) do{for(auto&e:x)cerr<<e<<" ";cerr<<"\n";}while(0) 
#define rep(i, a,b) for(int i=(a);i<=(b);++i)
#define _rep(i, a,b) for(int i=(a);i>=(b);--i)
#define fn1(e) [&](int p1){return (e);}
#define fn2(e) [&](int p1, int p2){return (e);}
#define iter(it) begin(it),end(it)
#define INF (0x3f3f3f3f)

#define MOD ((int)(1e9+7))
#define LIM (100*1000+10)

using ll=long long;


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

    long long n, m; cin>>n >>m;

    int ans=1;


    for(int i=1; i*i<=m; i++) {
        if (m %i == 0) {
            int j = m / i;
            // i, j
            if (j>=n) ans = max(ans, i);
            if (i>=n) ans = max(ans, j);
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n, a, b, p[100];
	cin >> n >> a >> b;
	int cnt[3] = {0,0,0};
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		if(p[i] <= a) cnt[0]++;
		elif(p[i] <= b) cnt[1]++;
		else cnt[2]++;
	}
	cout << min({cnt[0], cnt[1], cnt[2]}) << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	//"math"
)

func main() {
	var a,b,c int
	fmt.Scanf("%d %d %d", &a,&b,&c)
	if a-b > c{
		fmt.Print(0)
	}else{
		fmt.Print(c-(a-b))
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int ai[105];
int main()
{
    int n,d,x;
    scanf("%d %d %d",&n,&d,&x);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&ai[i]);
        long long  sum=1,su=0;
        while(sum<=d)
        {
            sum+=ai[i];
            su++;
        }
        ai[i]=su;
        //printf("f%d\n",su);
    }
    long long  sum=0;
    for(int i=0;i<n;i++)
        sum+=ai[i];
    printf("%lld\n",sum+x);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n, m, x;
  cin >> n >> m >> x;
  int l = 0, r = 0;
  rep(i,m) {
    int a;
    cin >> a;
    if (a < x) l++;
    else r++;
  }
  cout << min(l,r) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        double sum = 0;
        int num = sc.nextInt();

        for (int i = 0; i < num; i++) {
            double amount = sc.nextDouble();
            String unit = sc.next();
            if (unit.equals("BTC")) {
                sum += amount * 380000.0;
            } else {
                sum += amount;
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9+7;
const int maxn = 100005;

void go() {
    int n, m;
    cin >> n >> m;
    vector<ll>v(n);
    f(n) {
        cin >> v[i];
    }
    sort(all(v));
    int l = 0, r = v.back() + 1;
    while (r - l > 1) {
        int mid = (l + r) >> 1;
        ll cnt = 0;
        for (auto &j : v) {
            cnt += (j - 1) / mid;
        }
        if (cnt <= m) {
            r = mid;
        }
        else {
            l = mid;
        }
    }
    cout << r << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
    
}

Measured memory_bytes: 4768
#include<stdio.h>
void quicksort(int a[], int left, int right){
    int p;
	int L = left, R = right;
	int temp;
	p = a[(left + right) / 2];

	while (1){
		while (a[L] < p) L++; while (a[R] > p)
			R--;
		
		if (L >= R)
			break;

		temp = a[R];
		a[R] = a[L];
		a[L] = temp;

		L++;
		R--;
	}
	if (left < L - 1) quicksort(a, left, L - 1);
    if (right > R + 1)quicksort(a, R + 1, right); 
	
}
int main(){
    int a, b, c, n, i;
    c = 0;
    a = 0;
    int A[200001];
    int B[200001];
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &A[i]);
        B[i] = A[i];
    }
    quicksort(A, 0 , n-1);
    for(i = 0; i< n; i++){
        if(B[i] != A[n-1]){
            B[i] = A[n-1];
        }else if(B[i] == A[n-1] && A[n-1] == A[n-2]){
            B[i] = A[n-1];
        }else{
            B[i] = A[n-2];
        }
    }
    for(i = 0 ; i < n; i++){
        printf("%d\n", B[i]);
    }    
    return 0;
}

Measured memory_bytes: 3072
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = ReadIntArray();
            if (AB[0] == AB[1])
            {
                Console.WriteLine("Draw");
            }else if (AB[0] == 1 || (AB[0] > AB[1] && AB[1] != 1))
            {
                Console.WriteLine("Alice");
            }
            else
            {
                Console.WriteLine("Bob");
            }
        }
        private static readonly Func<string> Read = () => Console.ReadLine();
        private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split();
        private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine());
        private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine());
        private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
        private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
        private static readonly Action<string> Cw = str => Console.WriteLine(str);
    }
}

Measured memory_bytes: 13396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public int minJumps(int[] heights, int K) {
        int n = heights.length;
        int[] dp = new int[n];
        for (int i = 1; i < n; i++) {
            dp[i] = 1_000_000_000;
            for (int jumps = 1; jumps <= K; jumps++) {
               if (i - jumps < 0) {
                   continue;
               }
               dp[i] = Math.min(dp[i], Math.abs(heights[i - jumps] - heights[i]) + dp[i - jumps]);
            }
        }
        return dp[n - 1];
    }

    public static void main(String[] args)  {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String[] strs = br.readLine().split(" ");
            int n = Integer.parseInt(strs[0]);
            int K = Integer.parseInt(strs[1]);
            String heightsStr = br.readLine();
            String[] split = heightsStr.split(" ");
          	int[] heights = new int[n];
            for (int i = 0; i < n; i++) {
              	heights[i] = Integer.parseInt(split[i]);
            }
          	Main app = new Main();
            int result = app.minJumps(heights, K);
            System.out.println(result);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 35540
arr = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
for i in range(N):
    b = int(input())
    for k in range(3):
        for l in range(3):
            if arr[k][l] == b:
                arr[k][l] = 0
flg = False
for i in arr:
    if sum(i) == 0:
        flg = True
for i in range(3):
    if arr[0][i] + arr[1][i] + arr[2][i] == 0:
        flg = True
if arr[0][0] + arr[1][1] + arr[2][2] == 0:
    flg = True
if arr[0][2] + arr[1][1] + arr[2][0] == 0:
    flg = True
if flg:
    print('Yes')
else:
    print('No')

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

typedef long long ll;

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

	vector<pair<ll, ll>> x(n);
	for (int i = 0; i < n; i++) cin >> x.at(i).first >> x.at(i).second;

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

	ll ans = 4e18 + 1;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			if (j - i + 1 < k) continue;

			vector<ll> y;
			for (int l = i; l <= j; l++) y.push_back(x.at(l).second);

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

			for (int l = 0; l <= j - i + 1 - k; l++) {
				ans = min(ans, (x.at(j).first - x.at(i).first) * (y.at(l + k - 1) - y.at(l)));
			}
		}
	}

	cout << ans << '\n';
  
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b==c+d){
  cout<<"Balanced"<<endl;
  }
  else if(a+b<c+d){
  cout<<"Right"<<endl;
  }
  else cout<<"Left"<<endl;
}

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

namespace CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine()
                .Split(' ')
                .Select(s => int.Parse(s))
                .ToArray();
            var n = inputs[0];
            var dimension = inputs[1];
            var positions = new int[n, dimension];
            foreach (var i in Enumerable.Range(0, n))
            {
                var poss = Console.ReadLine()
                .Split(' ')
                .Select(s => int.Parse(s))
                .ToArray();
                foreach(var j in Enumerable.Range(0, dimension))
                {
                    positions[i, j] = poss[j];
                }
            }
            var integerDistancePairs = 0;
            foreach (var i in Enumerable.Range(0, n))
            {
                foreach (var j in Enumerable.Range(0, n))
                {
                    if (i >= j) continue;

                    var distanceSquare =
                        Enumerable.Range(0, dimension)
                        .Select(index => positions[i, index] - positions[j, index])
                        .Select(diff => diff * diff)
                        .Sum();
                    var sqrt = Math.Sqrt(distanceSquare);
                    var intSqrt = (int)sqrt;
                    if (Math.Abs(sqrt - intSqrt) < 1e-6) integerDistancePairs++;
                }
            }
            Console.WriteLine(integerDistancePairs);
        }
    }
}


Measured memory_bytes: 13396
a,b = map(int,input().split())
def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x%y)
def waru(max_gcd,x):
    if max_gcd%x != 0:
        return max_gcd
    else:
        return waru(max_gcd//i,x)

count = 0
max_gcd = gcd(a,b)

for i in range(2,max_gcd+1):
    if i*i > max_gcd:
        break
    if max_gcd%i == 0:
        count += 1
        max_gcd = waru(max_gcd,i)
if max_gcd == 1:
    print(count+1)
else:
    print(count+2)


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

const int64_t MAX = 2e+6 + 10;
const int64_t MOD = 1e+9 + 7;

int64_t factorial ( int64_t x ){
    int64_t res = 1;
    for ( int64_t i = 1; i <= x; ++i ){
        res *= i;
        res = res % MOD;
    }
    return res;
}


int64_t fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
int64_t COM(int64_t n, int64_t k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    int64_t X,Y;
    cin >> X >> Y;
    
    int64_t n,m;
    n = ( - X + 2 * Y ) / 3;
    m = ( 2 * X - Y ) / 3;
    
    //cout << n << m << endl;
    COMinit();
    int64_t res = 0;
    if ( ( - X + 2 * Y ) % 3 != 0 or ( 2 * X - Y ) % 3 != 0 ){
        res = 0;
    } else {
        res = COM(n+m,m);
    }
    
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 47104
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

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

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

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

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

void solve() {
    string s;
    cin >> s;
    int n = s.size();
    int index = 0;
    int cnt = 0;
    while (index < n - 1) {
        if (s[index] != s[index+1]) {
            s = s.substr(0,index) + s.substr(index+2);
            n -= 2;
            ++cnt;
            index = max(0, index - 1);
        } else {
            ++index;
        }
    }
    cout << cnt * 2 << endl;
}

int main() {
    solve();
    
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define For(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
typedef vector<long long> vlint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<vector<long long>> vlint2;

lint powint(lint x, lint y){
    int ret = 1;
    for (int i=0; i < y; i++) ret *= x;
    return ret;
};

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

map<char, long long> counter(string s){
    map<char, long long> count;
    rep(i, s.size()){
        count[s[i]] ++;
    }
    return count;
};

lint powmod(lint a, lint b, lint mod = 1000000007) {
   lint res = 1;
   for (a %= mod; b; a = a * a % mod, b >>= 1)
     if (b & 1) res = res * a % mod;
   return res;
 }

int main() {
    lint n; cin >> n;
    lint max_a = 0;
    vlint a(n);
    rep(i, n){
        cin >> a[i];
        max_a = max(a[i], max_a);
    }

    lint max_bit = 60;
    vector<unsigned long int> cnt(max_bit); rep(i, max_bit) cnt[i] = 0;

    rep(i, n){
        lint r = a[i];
        rep(j, max_bit){
            if (r & 1) cnt[j] ++;
            r >>= 1;
        }
    }

    unsigned long int ans = 0;
    rep(i, max_bit){
        unsigned long int t = powmod(2, i, mod);
        t *= cnt[i]; t %= mod;
        t *= (n-cnt[i]); t %= mod;
        ans = (ans + t) % mod;
    }
    cout << ans << endl;
}



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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int L[100] = { 0 };
	L[0] = 2;
	L[1] = 1;
	int N;
	cin >> N;
	rep(i, 2, N + 1)
	{
		L[i] = L[i - 1] + L[i - 2];
	}

	cout << L[N] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
  #define DUMP(i) 
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

struct Edge{
public:
  int from,to,cost;
  Edge(){}
  Edge(int _from,int _to,int _cost){
    from = _from;
    to = _to;
    cost = _cost;
  }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
const int EPS = 1e-9;
const int MOD = 1e9+7;

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



Measured memory_bytes: 256
n, c = map(int, input().split())
arrD = list(list(map(int, input().split())) for i in range(c))
arrC = list(list(map(int, input().split())) for i in range(n))
 
##剰余r=0,1,2で、
    ##色の出現数を確認する -> いずれかの色に統一する
        ##どの色に統一するか全パターンを実施して、違和感を算出
##和を取る

 ## arrCCnt[r][c]: 剰余rグループにおける初期色cのマス数
arrCCnt = []
for r in range(3):
    arrCCnt.append([0] * (c + 1))
for i in range(1, n + 1):
    for j in range(1, n + 1):
        r = (i + j) % 3
        oriC = arrC[i - 1][j - 1]
        arrCCnt[r][oriC] += 1

ret = float('inf')
for c0 in range(1, c + 1):
    for c1 in range(1, c + 1):
        if (c0 != c1):
            for c2 in range(1, c + 1):
                 if (c1 != c2) and (c2 != c0):
                    arrToC = [c0, c1, c2]
                    buf = 0
                    for r in range(3):
                        for oriC in range(1, c + 1):
                            buf += arrD[oriC - 1][arrToC[r] - 1] * arrCCnt[r][oriC]
                    ret = min(ret, buf)
print(ret)

Measured memory_bytes: 7540
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_asc(const void* a, const void* b) {
	return *((size_t*)a) < *((size_t*)b) ? -1 : 1;
}

int compare_sz_desc(const void* a, const void* b) {
	return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
	return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_i64_desc(const void* a, const void* b) {
	return *((int64_t*)a) > * ((int64_t*)b) ? -1 : 1;
}

int compare_c_asc(const void* a, const void* b) {
	return *((char*)a) < *((char*)b) ? -1 : 1;
}

int compare_c_desc(const void* a, const void* b) {
	return *((char*)a) > * ((char*)b) ? -1 : 1;
}

static size_t powSz(const size_t base, const size_t exp) {
	if (exp == 0) {
		return 1;
	}

	if (exp == 1) {
		return base;
	}

	if (exp % 2 == 0) {
		return powSz(base * base, exp / 2);
	}
	else {
		return base * powSz(base, exp - 1);
	}
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
	uint64_t result = 1;

	for (uint64_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static size_t gcdZu(size_t m, size_t n) {
	size_t temp;

	while (m % n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m % n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

int main(void) {
	size_t N, A, B;

	scanf("%zu %zu %zu", &N, &A, &B);

	printf("%zu", MIN(N * A, B));

	return 0;
}


Measured memory_bytes: 128
Scanf.scanf "%d" (fun n ->
    let len = Array.make n 0 in
    for i = 1 to n do
        Scanf.scanf " %d" (fun p ->
            let p = p - 1 in
            len.(p) <- 1;
            if p > 0 && len.(p - 1) > 0 then (
                len.(p) <- len.(p - 1) + 1;
                len.(p - 1) <- 0
            )
        )
    done;
    Printf.printf "%d\n" @@ n - Array.fold_left max 0 len
)

Measured memory_bytes: 7556
<?php

$s = trim(fgets(STDIN));

$odd = ['R' => true, 'U' => true, 'D' => true];
$even = ['L' => true, 'U' => true, 'D' => true];

$i = 0;
$no = false;
while (isset($s[$i])) {
    if ($i % 2 === 0 && $s[$i] === 'L' || $i % 2 === 1 && $s[$i] === 'R') {
        $no = true;
        break;
    }
    $i++;
}

echo $no ? 'No' : 'Yes';

Measured memory_bytes: 4728
use proconio::input;
use proconio::marker::*;
use std::cmp::*;

fn main() {
    input! {
        n: u32,
        s: Bytes,
        t: Bytes,
    }
    for i in 0..n{
        print!("{}{}",
            s[i as usize] as char,
            t[i as usize] as char
        );
    }
    println!();
}


Measured memory_bytes: 2136
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 5010
using namespace std;

int n,m,i,a[N],ans[N],cnt,last,mi,mip;

int main()
{
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++) scanf("%d",&a[i]);
    m++;
    while(m--)
    {
        mi=1e9;
        for(i=1;i<=n;i++)
            if(i!=last&&a[i]<mi)
            {
                mip=i;
                mi=a[i];
            }
        for(i=1;i<=n;i++)
            if(i!=last&&i!=mip)
            {
                ans[++cnt]=i;
                a[i]--;
            }
        last=mip;
        ans[++cnt]=last;
        a[last]--;
        if(a[last]<0)
        {
            printf("-1");
            return 0;
        }
    }
    printf("%d\n",cnt);
    for(i=1;i<=cnt;i++)
        printf("%d ",ans[i]);
    return 0;
}


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

#define int long long
#define fs first
#define sc second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define len(v) ((int)v.size())
#define vc vector
#define pr pair
#define endl "\n"
#define endd "\n"; return 0;
#define all(v) v.begin(), v.end()

using namespace std;

const int MAXN = 1e5;
const int INF = 1e10;
const int MOD = 1e9 + 7;

main() {
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    int a[n];
    int ans1 = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    {
        int prefsum[n];
        prefsum[0] = a[0];
        int ans = 0;
        if (a[0] <= 0){
            ans += 1 - a[0];
            prefsum[0] = 1;
        }
        for (int i = 1; i < n; i++) {
            prefsum[i] = prefsum[i - 1] + a[i];
            if (prefsum[i] == 0) {
                if (i % 2 == 0){
                    ans++;
                    prefsum[i] = 1;
                }
                else{
                    ans++;
                    prefsum[i] = -1;
                }
            }
            else{
                if (i % 2 == 0){
                    if (prefsum[i] < 0){
                        ans += 1 - prefsum[i];
                        prefsum[i] = 1;
                    }
                }
                else{
                    if (prefsum[i] > 0){
                        ans += prefsum[i] + 1;
                        prefsum[i] = -1;
                    }
                }
            }
        }
        ans1 = ans;
    }
    {
        for (int i = 0; i < n; i++){
            a[i] *= -1;
        }
        int prefsum[n];
        prefsum[0] = a[0];
        int ans = 0;
        if (a[0] <= 0){
            ans += 1 - a[0];
            prefsum[0] = 1;
        }
        for (int i = 1; i < n; i++) {
            prefsum[i] = prefsum[i - 1] + a[i];
            if (prefsum[i] == 0) {
                if (i % 2 == 0){
                    ans++;
                    prefsum[i] = 1;
                }
                else{
                    ans++;
                    prefsum[i] = -1;
                }
            }
            else{
                if (i % 2 == 0){
                    if (prefsum[i] < 0){
                        ans += 1 - prefsum[i];
                        prefsum[i] = 1;
                    }
                }
                else{
                    if (prefsum[i] > 0){
                        ans += prefsum[i] + 1;
                        prefsum[i] = -1;
                    }
                }
            }
        }
        ans1 = min(ans, ans1);
    }
    cout << ans1;

}


Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
struct P{
  int y; 
  int x;
  char c; // 持ってるやつ
  P(int y,int x,char c):y(y),x(x),c(c){}
};
char g[111][111];
int d[111][111];
int dy[]={0,0,1,-1};
int dx[]={1,-1,0,0};
void dfs(int y,int x,char c);
int h,w;
int main(){
  while(1){
    cin >> h >> w;
    if(!h && !w)break;
    for(int i=0;i<h;i++){
      cin >> g[i];
    }
    memset( d , 0 , sizeof(d) );
    int ret = 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(g[i][j] == '@' || g[i][j] == '#' || g[i][j] == '*'){
	  dfs( i , j , g[i][j] );
	  ret++;
	}
      }
    }
    cout << ret << endl;
  }
}
void dfs(int y,int x,char c){
  queue<P> que;
  que.push(P(y,x,c));
  d[y][x] = 1;
  while(!que.empty()){
    P p = que.front();que.pop();
    g[p.y][p.x] = '\0';
    for(int i=0;i<4;i++){
      int ty = p.y + dy[i];
      int tx = p.x + dx[i];
      if(g[ty][tx] == c && d[ty][tx] == 0){
	d[ty][tx] = 1;
	g[ty][tx] = '\0';
	que.push(P(ty,tx,c));
      }
    }
  }
}

Measured memory_bytes: 1288
#include<bits/stdc++.h>
#define maxn 100100
#define inf 1000000007
using namespace std;
struct edge{int r,nxt;}e[maxn<<1];
int head[maxn],K,esz,n,ans,dp[maxn];
void addedge(int u,int v){
	e[++esz].r=v;e[esz].nxt=head[u];head[u]=esz;
	e[++esz].r=u;e[esz].nxt=head[v];head[v]=esz;
}
void dfs(int u,int f){
	for(int t=head[u];t;t=e[t].nxt)if(e[t].r!=f)
		dfs(e[t].r,u),dp[u]=max(dp[u],dp[e[t].r]+1);
	if(dp[u]>=K-1&&u!=1&&f!=1)ans++,dp[u]=-inf;
}
int main(){
	scanf("%d%d",&n,&K);
	for(int i=1,ai;i<=n;++i){
		scanf("%d",&ai);
		if(i==1&&ai!=1)ans++;
		else if(i!=1)addedge(ai,i);
	}
	dfs(1,0);
	printf("%d",ans);
}

Measured memory_bytes: 7296
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <list>
#include <unordered_map>
#include <string>
using namespace std;
#define ll long long
#define pb push_back
using vi = vector<int>;
using vvi = vector<vector<int>>;

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

	vi heights(n);
	vvi costs(n);
	for (int i = 0; i < n; i++) {
		cin >> heights[i];
	}

	costs[0].pb(0);
	costs[1].pb(abs(heights[1] - heights[0]));
	for (int rock = 2; rock < n; rock++) {
		for (int i = 1; i <= min(k, rock); i++) {
			int cost = abs(heights[rock] - heights[rock-i]);
			int prevCost = costs[rock-i][0];

			for (int j = 1; j < costs[rock-i].size(); j++) {
				prevCost = min(prevCost, costs[rock-i][j]);
			}
			costs[rock].pb(prevCost + cost);
		}	
	}
	int minCost = costs[n-1][0];
	for (int i = 0; i < costs[n-1].size(); i++) {
		minCost = min(minCost, costs[n-1][i]);
	}

	cout << minCost << endl;
	return 0;
}

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

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            var ls=RL2IE();
            var px = RL2IE().ToList();
            var N = ls.First();
            var K = ls.Last();
            px.Sort();
            long ret = 0;
            for (int i = 0; i < K; i++)
            {
                ret += px[i];
            }
            Console.WriteLine(ret);
            Console.ReadLine();

        }

        static IEnumerable<Int64> RL2IE() { return spr(RL()).Select(x => c2i(x)); }
        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static Int64 c2i(string c) { return Int64.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}

Measured memory_bytes: 28484
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int x,y,z;
	
	cin >> x >> y;
	
	while (y != 0){
		if (x < y){
			swap(x,y);
		}
		z = x % y;
		x = y;
		y = z;
	}
	
	cout << x << "\n";
	
	return (0);
}



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

using namespace std;
typedef long long ll;

#define MAX 100001
vector<int> V[MAX];
int dp[MAX][11], color[MAX];

int main(void) {
    int i, n, m, q;
    scanf("%d%d", &n, &m);
    for(i=0; i<m; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        V[a].emplace_back(b);
        V[b].emplace_back(a);
    }

    scanf("%d", &q);
    for(i=1; i<=q; i++) {
        int v, d;
        scanf("%d%d%d", &v, &d, color+i);
        dp[v][d] = i;
    }

    for(i=9; i>=0; i--) {
        for(int j=1; j<=n; j++) {
            dp[j][i] = max(dp[j][i], dp[j][i+1]);
            for(int next : V[j]) {
                dp[j][i] = max(dp[j][i], dp[next][i+1]);
            }
        }
    }

    for(i=1; i<=n; i++) printf("%d\n", color[dp[i][0]]);
    return 0;
}

Measured memory_bytes: 11128
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define pr_arr(name, a, b) \
  for (int i = (a); i < (b); i++) { \
    for (int j = (a); j < (b); j++) {\
      if (j > (a)) printf(" "); \
      printf("%lld", name[i][j]); \
    }\
    printf("\n");\
  }\

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

int ans;
int X;

// 10012



int main(void) {
    scanf("%d", &X);

    int x = X % 100;

    int c = 0;
    for (int i = 5; i >= 1; i--) {
      while ( x-i >= 0) {
        x -= i;
        c++;
      }
    }
    int y = (X - (X % 100)) - 100 * c;

    if (y < 0) {
      puts("0");
    } else {
      puts("1");
    }

   

  
 

	return 0;
}


Measured memory_bytes: 256