akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

ll ll_sqrt(ll x){
  ll l=1,r=1000000001;
  while(l+1<r){
    ll mid=(l+r)/2;
    if(mid*mid<x){
      l=mid;
    }else if(mid*mid==x){
      return mid;
    }else{
      r=mid;
    }
  }
  return l;
}
void solve(long long S){
  ll ans=ll_sqrt(S);
  if(ans*ans==S){
    printf("%lld %lld %lld %lld %lld %lld\n",0LL,0LL,ans,1LL,0LL,ans);
  }else if(ans*(ans+1)<=S){
    printf("%lld %lld %lld %lld %lld %lld\n",0LL,0LL,ans+1,1LL,(ans+1)*(ans+1)-S,ans+1);
  }else{
    printf("%lld %lld %lld %lld %lld %lld\n",0LL,0LL,ans,1LL,(ans)*(ans+1)-S,ans+1);
  }
}

int main(){
    long long S;
    scanf("%lld",&S);
    solve(S);
    return 0;
}


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

int main(){
  int n, a[100005] = {0}, b[100005] = {0};
  long long int suma = 0, sumb = 0;
  int ans = 0, diff[100005] = {0};
  
  cin >> n;
  for( int i = 0; i < n; i++ ){
    cin >> a[i];
    suma += a[i];
  }
  for( int i = 0; i < n; i++ ){
    cin >> b[i];
    sumb += b[i];
  }
  
  if(suma < sumb){
    cout << -1 << endl;
    return 0;
  }
  
  int x;
  long long int abdiff;
  for(int i = 0; i < n; i++){
    x = a[i] - b[i];
    if(x < 0){
      ans ++;
      abdiff -= x;
    }else{
      diff[i] = x;
    }
  }
  
  if(ans == 0){
    cout << ans << endl;
    return 0;
  }
  
  sort(diff, diff + 100005);
  long long int sumx = 0;
    
  for( int i = 100004; i >= 0; i--){
    sumx += diff[i];
    ans ++;
    if(sumx >= abdiff){
      cout << ans << endl;
      return 0;
    }
  }
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,K,Q;
  cin>>N>>K>>Q;
  vector<int>A(Q);
  for(int i=0;i<Q;i++)cin>>A[i];
  vector<int>p(N,0);
  for(int i=0;i<Q;i++)p[A[i]-1]++;
  for(int i=0;i<N;i++){
    p[i]=p[i]+K-Q;
    if(p[i]>0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <math.h>
#include <bitset>
 
using namespace std;
 
 
int main()
{
  int r, g, b;

  cin >> r >> g >> b;

  if ((r*100+g*10+b)%4) {
	  cout << "NO" << endl;
  } else {
	  cout << "YES" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int64_t n;
  cin >> n;
  int64_t a, b;
  int f_min = 10000;
  for (int64_t i = 1; i < 100001; i++) {
    a = i;
    if (n % a == 0) {
      b = n / a;
      //cout << a << " " << b << endl;
      int count_a = 0;
      int count_b = 0;
      while (a>0) {
        count_a++;
        a /= 10;
      }
      while (b>0) {
        count_b++;
        b /= 10;
      }
      int f = max(count_a, count_b);
      if (f_min > f) {
        f_min = f;
      }
    }
  }
  cout << f_min << endl;
}
    


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#pragma O3
using namespace std;
int n,a,b,c,d;
string s;
signed main(){
//	freopen(".inp","r",stdin);
//	freopen(".out","w",stdout);
//	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n>>a>>b>>c>>d>>s;
	a--;
	b--;
	c--;
	d--;
	for(int i=a;i<c;i++){
		if(s[i]=='#'&&s[i+1]=='#'){
			cout<<"No";
			return 0;
		}
	}
	for(int i=b;i<d;i++){
		if(s[i]=='#'&&s[i+1]=='#'){
			cout<<"No";
			return 0;
		}
	}
  	bool check=true;
	if(c>d){
      	check=false;
		for(int i=b;i<=d;i++) if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.'){
			check=true;
			break;
		}
	}
	if(check) cout<<"Yes";
  	else cout<<"No";
}


Measured memory_bytes: 640
#include <stdio.h>

int main()
{
    int n,m,x,xi=0,flag=0;
    scanf("%d %d %d", &n,&m,&x);
    int a[m];
    for(int i = 0; i < m; i++){
        scanf("%d", &a[i]);
        if(a[i]>x&&(flag==0)){
            xi=i;
            flag++;
        }
    }

    printf("%d\n", xi<m-xi?xi:m-xi);
    return 0;
}


Measured memory_bytes: 128
//#include "stdc++.h"
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
typedef long long int ll;
inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0) return 1;ll p=power(a,n/2,m);p=(p*p)%m;if(n%2) return (p*a)%m;else return p; }
#define flush fflush(stdout)
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
#define int long long
int dp[10001][101];
int cal(int n,int md)
{
    return dp[n][md];
}
int32_t main()
{
    IOS;//ifstream fin("input.txt");ofstream fout("output.txt");/*
    string k;
    cin>>k;int d;
    cin>>d;
    dp[0][0]=1;
    for(int i=1;i<=k.length()+1;i++)
    {
        for(int j=0;j<d;j++)
        
        {
            for(int k=0;k<10;k++)
        {
            dp[i][j]=(dp[i][j]%MOD+dp[i-1][(j%d-k%d+d)%d]%MOD)%MOD;
        }
        }
    }
    int s=0,y,x,cnt,ans=0,mx;
    for(int i=0;i<k.length();i++)
    {
        y=k.length()-i-1;
        for(int j=0;j<(k[i]-'0');j++)
        {
            if(y)
            {ans=(ans+cal(y,(d-(s+j)%d)%d)+MOD)%MOD;
               
            }
            else
                if(((s+j)%d)==0)
                    ans=(ans+1)%MOD;
            if(i==0&&j==0)
                ans=ans-1;
        }
        s=s+k[i]-'0';
        s=s%d;
    }
    if((s%d)==0)
        ans=(ans+1)%MOD;
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 8192
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(int argc, char* argv[])
{
	int N,K,i;
	cin>>N>>K;
	vector<int> p(N);
	for (i=0;i<N;i++){
		cin>>p[i];
	}
	sort(p.begin(),p.end());
	int ans=0;
	for (i=0;i<K;i++){
		ans+=p[i];
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main()
{
    int n, m,x,y;

    scanf("%d %d", &n, &m);

    int a[n+1];
    memset(a,0,sizeof(a));

    while(m--)
    {
        scanf("%d %d", &x, &y);
        a[x]++;
        a[y]++;
    }

    for(int i=1; i<=n; i++)
        printf("%d\n", a[i]);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a,b, c;
  cin >> a >> b >> c;
  int d = b / a;
  if(d >= c){
    cout << c;
  }
  else{
    cout << d;
  }
}

Measured memory_bytes: 3596
package main

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

// const (
// 	initialBufSize = 10000
// 	maxBufSize     = 100000000
// )
//
// var sc *bufio.Scanner = func() *bufio.Scanner {
// 	sc := bufio.NewScanner(os.Stdin)
// 	buf := make([]byte, initialBufSize)
// 	sc.Buffer(buf, maxBufSize)
// 	return sc
// }()

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Buffer(buff, 100000000)
	log.SetFlags(log.Lshortfile)
}

func main() {
	input := nextString()
	remSumArray := make([]int, 2019)
	remSumArray[0] = 1
	var num int
	digit := 1
	for i := len(input) - 1; i >= 0; i-- {
		num += int(input[i]-48) * digit
		digit *= 10
		digit %= 2019
		remSumArray[num%2019]++
	}
	var result int
	for _, num := range remSumArray {
		result += num * (num - 1) / 2
	}
	fmt.Println(result)
}

func nextString() (s string) {
	sc.Scan()
	return sc.Text()
}


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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000007;



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

	if (a > b)swap(a, b);

	if (a < c&&c < b) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	

}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	int N;
	cin >> N;
	int A[100100];
	rep(i, N + 1) cin >> A[i];


	ll nokori = 1;
	ll B[100100];

	rep(i, N + 1) {
		B[i] = nokori;

		nokori = (nokori - A[i]) * 2;

		if (nokori > 1e15) nokori = 1e15;
	}
	
	int OK = 1;
	ll kotae = 0;
	ll kari = 0;
	for (int i = N; i >= 0; i--) {
		if (B[i] < A[i]) OK = 0;
		
		kari += A[i];
		kotae += min(kari, B[i]);
	}

	if (OK) co(kotae);
	else co(-1);

	Would you please return 0;
}

Measured memory_bytes: 4828
import re
N = int(input())
S = input()
oldS = S
while 1:
    S = re.sub('a+','a',S)
    S = re.sub('b+','b',S)
    S = re.sub('c+','c',S)
    S = re.sub('d+','d',S)
    S = re.sub('e+','e',S)
    S = re.sub('f+','f',S)
    S = re.sub('g+','g',S)
    S = re.sub('h+','h',S)
    S = re.sub('i+','i',S)
    S = re.sub('j+','j',S)
    S = re.sub('k+','k',S)
    S = re.sub('l+','l',S)
    S = re.sub('m+','m',S)
    S = re.sub('n+','n',S)
    S = re.sub('o+','o',S)
    S = re.sub('p+','p',S)
    S = re.sub('q+','q',S)
    S = re.sub('r+','r',S)
    S = re.sub('s+','s',S)
    S = re.sub('t+','t',S)
    S = re.sub('u+','u',S)
    S = re.sub('x+','x',S)
    S = re.sub('y+','y',S)
    S = re.sub('z+','z',S)
    S = re.sub('v+','v',S)
    S = re.sub('w+','w',S)
    if oldS == S:
        break
    else:
        oldS = S

print(len(S))




Measured memory_bytes: 4468
#include <iostream>
using namespace std;
using llong = long long;

llong n, m;
llong p[20];
string tn[] = {"", "Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko", "Kan", "Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts"};

int main() {
	cin >> m >> n;
	
	while (n != 0 && m != 0) {
		for (int i = 0; i < 20; i++) p[i] = 0;
		
		p[0] = 1ll;
		for (int i = 0; i < n; i++) {
			p[0] *= m;
			
			for (int i = 1; i < 20; i++) {
				p[i] *= m;
				p[i] += p[i - 1] / (llong)(1e4);
				p[i - 1] %= (llong)(1e4);
			}
		}
		
		for (int i = 18; i >= 0; i--) {
			if (p[i] != 0) {
				cout << p[i] << tn[i];
			}
		}
		cout << endl;
		
		cin >> m >> n;
	}
}


Measured memory_bytes: 3192
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y){
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for(int i = 1; i <= m; i++) c[i][0] = 0;
  for(int j = 1; j <= n; j++) c[0][j] = 0;

  for(int i = 1; i <= m; i++){
    for(int j = 1; j <= n; j++){
      if(X[i] == Y[j]){
        c[i][j] = c[i - 1][j - 1] + 1;
      } else {
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      }

      maxl = max(maxl, c[i][j]);
    }
  }

  return maxl;
}

int main(){
  string s1, s2;
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
  return 0;
}

Measured memory_bytes: 5128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int x, y, z; cin >> x >> y >> z;

	int cnt = 0;
	for (int i = x; i < y + 1; cnt+=z%i++==0);

	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3136
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,K=MAP()

cnt=[0]*N
for i in range(1, N+1):
    j=i
    while j<K:
        j*=2
        cnt[i-1]+=1

ans=0
for i in range(N):
    ans+=(1/N)*(1/2)**cnt[i]
print(ans)


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repR(i, n) for(int i = n; i >= 0; ++i)
#define FDS(i, n) for(int i = 0; i < n; ++i)
#define FDSR(i, n) for(int i = n; i >= 0; ++i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b-c>=0&&a<=c){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

// cond: a>b
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main()
{
  ll a,b;
  cin>>a>>b;
  if(a<b) swap(a,b);
  ll n = gcd(a,b);
  vecll v;
  for(ll i=2;i*i <= n;++i) {
    if ((n%i) == 0) {
      v.push_back(i);
      while ((n%i) == 0) n /= i;
    }
  }
  if (n > 1) v.push_back(n);
  cout << v.size() + 1<< endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int modulo(1e9 + 7);
int main() {
	int n;
	scanf("%d", &n);
	int cnt(0);
	int ans(1);
	for(int i(1); i <= n; i++) {
		int x;
		scanf("%d", &x);
		if(x >= cnt * 2 + 1) {
			cnt++;
		}else {
			ans = (long long)ans * (cnt + 1) % modulo;
		}
	}
	while(cnt) {
		ans = (long long)ans * cnt % modulo;
		cnt--;
	}
	cout << ans << endl;
}

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

int main(){
	ll n,m; cin >> n >> m;
	cout << n*(n-1) / 2 + m*(m-1)/2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int64_t x;
    cin >> x;
    for(int64_t a=-200; a<200; a++){
        for(int64_t b=-200; b<200; b++){
            if(a*a*a*a*a - b*b*b*b*b == x){
                cout << a << ' ' <<  b << endl;
                return 0;
            }
        }
    }
}


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

template <typename T>
class BIT {
  int n; vector<T> bit;
public:
  BIT(int _n) : n(_n) {
    bit = vector<T>(n+1,(T)0);  
  }
  T sum(int i) {
    T s = 0;
    while(i > 0){
      s += bit[i];
      i -= i & -i;
    }
    return s;
  }
  void add(int i, T x) {
    while(i <= n){
    bit[i] += x;
    i += i & -i;
    }
  }
  T lowerbound(T w) {
    if(w <= 0) return 0;
    int x = 0; int p = 1;
    while(true){
      if(p*2 > n) break;
      p *= 2;
    }
    for(int k = p; k > 0; k /= 2){
      if(x+k <= n && bit[x+k] < w){
        w -= bit[x+k];
        x += k;
      }
    }
    return x+1;
  }
};

int main(){
  int q, f;
  cin >> q;
  vector<P> v;
  vector<bool> query(q,false);
  vector<ll> c(q,0);
  ll p = 0, a, b;
  rep(i,q) {
    cin >> f;
    if(f == 1) {
      query[i] = true;
      cin >> a >> b;
      if(i == 0) c[i] = b;
      else c[i] = c[i-1] + b;
      v.push_back(P(a,p++));
    } else {
      if(i > 0) c[i] = c[i-1];
    }
  }
  sort(v.begin(),v.end());
  vector<P> m(p);
  rep(i,p) m[v[i].second] = P(i+1,v[i].first);
  BIT<ll> bit(p), sum(p);
  vector<P> ans;
  ll cur = 0;
  rep(i,q) {
    if(query[i]) {
      bit.add(m[cur].first,1);
      sum.add(m[cur].first,m[cur].second);
      cur++;
    } else {
      ll r = (cur+1)/2;
      ll k = bit.lowerbound(r);
      ans.push_back(P(v[k-1].first,-2*sum.sum(k)+sum.sum(p)+(2*r-cur)*v[k-1].first+c[i]));
    }
  }
  for(auto x : ans) cout << x.first << " " << x.second << endl;
  return 0;
}

Measured memory_bytes: 11248
N, K = map(int, input().split())
V_list = list(map(int, input().split()))

ans = 0
for A in range(min(N, K)+1):
    for B in range(min(N, K)-A+1):
        count = K - (A + B)
        v = []
        for i in range(A):
            v.append(V_list[i])
        for j in range(B):
            v.append(V_list[-(j+1)])
        v.sort()
        for k in range(min(count, len(v))):
            if v[k] < 0: 
                v[k] = 0
            else: 
                break
        if ans < sum(v):
            ans = sum(v)

print(ans)

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

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

	if (a <= c && c <= b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
		
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  private static void solve(String s) {
    int count = 0;
    int n = s.length();
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      if (s.charAt(i) == 'R') {
        count++;
        continue;
      }
      a[i] += count / 2;
      a[i - 1] += count - count / 2;
      count = 0;
    }
    count = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (s.charAt(i) == 'L') {
        count++;
        continue;
      }
      a[i] += count / 2;
      a[i + 1] += count - count / 2;
      count = 0;
    }
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < n; i++) {
      if (i > 0) sb.append(" ");
      sb.append(a[i]);
    }
    System.out.println(sb.toString());
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    sc.close();
    solve(s);
  }
}

Measured memory_bytes: 29036
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    int N, M;   cin >> N >> M;
    Graph G(N);
    for(int i = 0; i<M; i++){
        int A, B;   cin >> A >> B;
        G[A-1].push_back(B);
        G[B-1].push_back(A);
    }

    vector<int> dist(N, -1);
    queue<int> que;

    dist[0] = 0;
    que.push(0);

    while(!que.empty()){
        int v = que.front();
        que.pop();

        for(int i : G.at(v)){
            if(dist[i-1] != -1){
                continue;
            }else{
                dist[i-1] = v;
                que.push(i-1);
            }
        }
    }
    cout << "Yes" << '\n';
    for(int v=1; v<N; v++)
        cout << dist[v]+1 << endl;
}

Measured memory_bytes: 10224
def is_prime(num):
    limit = int(num ** 0.5) + 1
    for i in range(2, limit):
        if num % i == 0:
            return False
    return True


n = int(input())
ans = [2]

for num in range(3, 55555, 2):
    if num % 5 == 2 and is_prime(num):
        ans.append(num)

    if len(ans) == n:
        break

print(' '.join(map(str, ans)))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int main()
{
    fast;

    ll a,b,c,d,i,j,mul=1;
    cin >> a >> c;
    vector<ll>vec,vec2;
    while(a--)
    {
        cin >> b;
        vec.push_back(b);


    }

    for(i=0;i<vec.size()-c;i++)
    {
        if(vec[i]<vec[i+c])
        {
            cout << "Yes" << endl;
        }else{
        cout << "No"<<endl;
        }
    }



}



Measured memory_bytes: 5324
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;

fn main() {
    let (a, b, c): (i32, i32, i32);
    input!(a, b, c);

    if a == b {
        p(c);
    } else if a == c {
        p(b);
    } else {
        p(a);
    }
}

Measured memory_bytes: 4352
#include<stdio.h>
#define N 1200 

int main(void){
	char mo[N],moout[N]={'0'};
	int i=0;
	
	for(i=0;i<N;i++){
		scanf("%c",&mo[i]);
		if(mo[i]=='\n'){
			mo[i]='\0';
			break;
		}
	}
	for(i=0;i<N;i++){
		if((mo[i]>=0x41)&&(mo[i]<=0x5a)){
			moout[i]=mo[i]+0x20;
		}
		else if((mo[i]>=0x61)&&(mo[i]<=0x7a)){
			moout[i]=mo[i]-0x20;
		}
		else moout[i]=mo[i];
		if(moout[i]=='\0'){
			moout[i]='\n';
			break;
		}
	}
		printf("%s",moout);
	return 0;
}


Measured memory_bytes: 2036
#include <stdio.h>


int main(void) {

	int a, b, i, m;



	while (1) {
		scanf("%d %d", &a, &b);
		if (a == 0 && b == 0) {
			break;
		}
		for (i = 1; i <= a; i++) {
			for (m = 1; m <= b; m++) {
				if (i % 2 != 0) {
					if (m % 2 != 0) {
						printf("#");
					}
					else {
						printf(".");
					}
				}
				else if (i % 2 == 0) {
					if (m % 2 != 0) {
						printf(".");
					}
					else printf("#");
				}
				}
			printf("\n");
			}
			printf("\n");
		}
		

	return 0;
}


Measured memory_bytes: 2044
use std::io::prelude::BufRead;
use std::io::StdinLock;

pub fn read_line(locked_stdin: &mut StdinLock) -> std::io::Result<String> {
    let mut buf = String::new();
    locked_stdin.read_line(&mut buf).map(|_| buf)
}

pub fn read_to_string(locked_stdin: &mut StdinLock) -> std::io::Result<String> {
    read_line(locked_stdin).map(|s| s.trim().to_string())
}

fn main() {
    let s;

    {
        let stdin = std::io::stdin();
        let mut lkin = stdin.lock();
        s = read_to_string(&mut lkin).unwrap();
    }

    let s = s.into_bytes();

    println!("{}",
        if (s.first().unwrap() == s.last().unwrap())
            ^ (s.len() % 2 == 1) {"First"}
        else {"Second"});
}


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

int del_Recipies(int del,int count,int n,int m,int p[],int Recipies[500][500]);

int main()
{
	int n,m,Recipies[500][500]={0},MAX[500],min_del_Recipies,c,flag,*p,count;
	
	while(1)
	{
		scanf("%d %d",&n,&m);
		if(n==0&&m==0) break;
		min_del_Recipies=-1;
		for(int i=0;i<m;i++) MAX[i]=0;
		for(int i=0;i<n;i++)
		{
			for(int t=0;t<m;)
			{
				Recipies[i][t]=getchar();
				if(Recipies[i][t] != '\n'&& Recipies[i][t] != ' ')
				{
					Recipies[i][t]-='0';
					MAX[t]+=Recipies[i][t];
					t++;
				}
			}
		}
		flag=1;
		//作る際に必要な材料数がすべての材料で2で割り切れたなら、その時のレシピ数になる
		for(int t=0;t<m;t++)
		{
			if(MAX[t]%2)
			{
				flag=0;
				break;
			}
		}
		if(flag) min_del_Recipies=0;
		else
		{
			p=(int*)malloc(m*sizeof(int));
			//すべて作った時に必要な材料からレシピを減らしていく
			//減らしていく数を順に増やしていき、その減らす数の時のすべての減らし方を試す
			
			for(int del=1;del<n;del++)//何個引くか del個 引いた個数 count
			{
				for(int i=0;i<m;i++) p[i]=MAX[i];
				count=0;
				flag=del_Recipies(del,count,n,m,p,Recipies);//何個引くか del個 引いた個数 count
				//del個減らしたときにすべての材料が2で割り切れるものがあったら 1を返す なかったら 0を返す
				if(flag)
				{
					min_del_Recipies = del;//delで割り切れたとき
					break;
				}
			}
			if(min_del_Recipies==-1)min_del_Recipies=n;//どれも割り切れなかったとき
			free(p);
		}
		printf("%d\n",n-min_del_Recipies);//全体から割り切れるまでに引いた個数を引くと求まる
	}
	return 0;
}

int del_Recipies(int del,int count,int n,int m,int p[],int Recipies[500][500])
{
	//引く個数=del 引いた個数=count何種類目 i
	int flag=1;
	for(;count<n && n-count>=del;count++)
	{
		
		if(del==1)
		{
			flag=1;
			for(int t=0;t<m;t++)
			{
				p[t]-=Recipies[count][t];
				if(p[t]%2!=0)
				{
					flag=0;
					p[t]+=Recipies[count][t];
					break;
				}
				p[t] += Recipies[count][t];
			}
			if(flag) return 1;
			else continue;
		}
		else 
		{
			//残りの引く個数が1になるまで再起
			//pから今回引くRecipiesを引いてから次に渡す
			for(int t=0;t<m;t++) p[t]-=Recipies[count][t];
			//引く個数delを一つ減らす　引いた個数countを一つ増やす
			if(del_Recipies(del-1,count+1,n,m,p,Recipies)) return 1;
			for (int t = 0; t<m; t++) p[t] += Recipies[count][t];
		}
		
	}
	return 0;
}


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

using namespace std;

int main() {
  int n = 0;
  vector < int > a;
  cin >> n;
  n += n;
  for (int i = 0; i < n; i++) {
    int x = 0;
    cin >> x;
    a.push_back(x);
  }
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 1; i < a.size(); i += 2) {
    ans += a[i - 1];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
N=int(input())
D=list(map(int,input().split()))
D.sort()
mi=D[0]
ma=D[N-1]
point=0
for j in range(mi,ma+1): #Kはj
    if D[N//2-1]<j<=D[N//2]:
        point+=1
print(point)
    

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

nn = n
f = 0

while nn != 0:#10で割った商が0になったらループ終了
		f +=  int(nn % 10)#一の位(10で割った余り)を加算
		nn = int(nn/10)	#10で割る

if n%f == 0:
	print('Yes')
else:
	print('No')

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

int main() {
  int N, a, b, c, d;
  cin >> N;
  a = N / 1000;
  b = ( N - 1000 * a ) / 100;
  c = ( N - 1000 * a - 100 * b ) / 10;
  d = N - 1000 * a - 100 * b - 10 * c;
  if ( ( a == b && b == c ) || ( b == c && c == d ) ){
  cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x; cin >> x;
    if(x == 0) cout << 1 << '\n';
    else cout << 0 << '\n';
    return 0;
}

Measured memory_bytes: 3636
#include <cstdlib>
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;

class generator {
	int g, w;

public:
	generator(int s, int w_):g(s), w(w_) {}

	inline int next() {
		int res = (g / 7) % 10;
		if(g & 1) g = (g >> 1) ^ w;
		else      g = (g >> 1);
		return res;
	}
};

inline int solve(int n, int s, int w, int q) {
	generator g(s, w);
	int res = 0;

	if(q == 2 || q == 5) {
		int cnt = 0;

		for(int i = 0; i < n; ++i) {
			const int a = g.next();
			if(a) ++cnt;
			if(a % q == 0) res += cnt;
		}

		return res;
	}

	vector<int> a(n);
	for(int i = n - 1; i >= 0; --i) {
		a[i] = g.next();
	}

	unordered_map<int, int> cnt;
	cnt.insert({0, 1});

	int current = 0;
	int coefficient = 1;

	for(int i = 0; i < n; ++i) {
		current = (a[i] * coefficient + current) % q;
		if(a[i]) res += cnt[current];
		++cnt[current];
		coefficient = (coefficient * 10) % q;
	}

	return res;
}

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

	for(int n, s, w, q; cin >> n >> s >> w >> q && n;) {
		cout << solve(n, s, w, q) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 5248
H,W,K = map(int,input().split())

A = []
for i in range(H):

    a = list(map(int,list(input())))
    A.append(a)

#print (A)
ans = float("inf")

for i in range(2**(H-1)):

    wtk = [0]
    cut = 0

    for j in range(H-1):

        if i & 2**j > 0:
            wtk.append(wtk[-1]+1)
            cut += 1
        else:
            wtk.append(wtk[-1])

    now = [0] * (H)

    for y in range(W):

        flag = True
        nnow = []
        for ll in now:
            nnow.append(ll)
        save = [0] * (H)

        for x in range(H):

            nnow[wtk[x]] += A[x][y]
            save[wtk[x]] += A[x][y]

        if max(save) > K:
            cut = float("inf")
            break
        if max(nnow) > K:
            cut += 1
            nnow = save

        now = nnow

    ans = min(ans,cut)
            
print (ans)


Measured memory_bytes: 45788
/*2019/07/29 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
typedef long long int ll;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}
/*
int asc_t(const void *a,const void *b){return ((user_t*)a)->score - ((user_t*)b)->score;}
int desc_t(const void *a,const void *b){return ((user_t*)b)->score - ((user_t*)a)->score;}
*/

int main(){
    int n,k,x[200];

    scanf("%d",&n);
    scanf("%d",&k);
    for(int i=0;i<n;i++){
        scanf("%d",&x[i]);
    }

    int ans=0;
    for(int i=0;i<n;i++){
        if(abs(x[i]-0)>abs(x[i]-k)){
            ans+=2*abs(x[i]-k);
        }else{
            ans+=2*abs(x[i]-0);
        }
    }

    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
/*input
3
0 1 1
1 0 1
1 1 1
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<ld,ld>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e18;
const int INF=1e6+1;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll sub(ll a,ll b){
    ll x=a-b;
    while(x<0) x+=MOD;
    while(x>MOD) x-=MOD;
    return x;
}
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=(res*a);
        if(res>1e10) return 1e11;
        a=(a*a);
        b>>=1;
    }
    return res;
}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;

int n;
vector<int> G[maxn];
long long dp[maxn][2];

long long f(int u, int flag, int p) {
    auto &ans = dp[u][flag];
    if(ans != -1) return ans;
    ans = 1;
    for (int v: G[u]) {
        if(v == p) continue;
        if(flag) {
            ans *= (f(v, !flag, u));
            ans %= MOD;
        } else {
            ans *= (f(v, flag, u) + f(v, !flag, u)) % MOD;
            ans %= MOD;
        }
    }
    return ans;
}

int main() {
    memset(dp, -1, sizeof dp);
    cin >> n;

    REP(i,n-1){
        int x,y;
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    cout << (f(1,0,1) + f(1,1,1)) %MOD;
    return 0;
}


Measured memory_bytes: 18432
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    string s,t;
    cin >> s >> t;
    bool ans=true;
    if(s.size()+1!=t.size()) ans=false;
    if(s!=t.substr(0,s.size())) ans=false;
    puts(ans?"Yes":"No");
}

Measured memory_bytes: 3616
n = int(input())
l = [int(i + 1 == e) for i, e in enumerate(map(int, input().split()))]
res = 0
for i in range(n):
    if l[i]:
        if i + 1 < n and l[i + 1]: l[i + 1] = 0
        res += 1
print(res)

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

int main(){
    int x,y,z;
    cin >>  x >> y >> z;
    cout << z << ' ' << x << ' ' << y << endl;
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

const int INF = 1 << 29;

int red[100000];
int write[100000];
bool flg[100000];

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

    flg[0] = 1;
    red[0] = 1;
    REP (i, 1, n) write[i] = 1;

    rep (i, m) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        if (red[x] == 0 && write[x] == 0) continue;
        if (write[x] != 0) {
            write[x]--;
            if (red[x] != 0) {
                red[y]++;
                flg[y] = 1;
            } else {
                write[y]++;
            }
        } else {
            red[x]--;
            red[y]++;
            flg[y] = 1;
            if (red[x] == 0) flg[x] = 0;
        }
    }

    int ans = 0;
    rep (i, n) if (flg[i]) ans++;

    cout << ans << endl;
}


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

int main()
{    long long n,D,X,Y,c,e,count=0;
 
    cin>>n>>D;
    
    for(long long i=0;i<n;i++)
    {
        cin>>X>>Y;
    
        if(X * X + Y * Y <= D * D)
        {
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll m, n, x, y, z, p, q, r;
ll koybarpressed1[300000];
ll koybarpressed2[300000];
ll ultimatepressed[300000];
ll flgshuru[300000];
ll flgsesh[300000];

ll ara[300000];
ll cur;
ll ans;


int main()
{
    cin >> n >> m;
    for(ll i = 1; i <= n; i++) scanf("%lld", &ara[i]);

    for(ll i = 2; i <= n; i++){
        ll tmp1 = ara[i - 1];
        ll tmp2 = ara[i];


        if(tmp1 < tmp2){

            ll mxstp = tmp2 - tmp1;

            koybarpressed1[1] += mxstp;
            koybarpressed1[tmp1 + 1] -= mxstp;

            koybarpressed1[tmp2 + 1] += mxstp;
            koybarpressed1[m + 1] -= mxstp;

            koybarpressed2[tmp1 + 1] += mxstp;
            flgshuru[tmp1 + 1]++;
            flgsesh[tmp2 + 1]++;

        }

        else{

            ll mxstp = (tmp2 + m) - tmp1;

            koybarpressed1[tmp2 + 1] += mxstp;
            koybarpressed1[tmp1 + 1] -= mxstp;

            koybarpressed2[tmp1 + 1] += mxstp;
            flgshuru[tmp1 + 1]++;
            flgsesh[m + 1]++;

            koybarpressed2[1] += (tmp2);
            flgshuru[1]++;
            flgsesh[tmp2 + 1]++;

        }

    }

    ll cur = 0;

    for(ll i = 1; i <= m; i++){
        cur += koybarpressed1[i];
        ultimatepressed[i] += cur;
    }


    cur = 0;
    ll liveevent = 0;

    for(ll i = 1; i <= m; i++){

//        cout << i << ' ' << koybarpressed2[i] << endl;

        cur += koybarpressed2[i];
        cur -= liveevent;

        ultimatepressed[i] += cur;

        liveevent = liveevent + flgshuru[i] - flgsesh[i];
//        cout << i << ' ' << ultimatepressed[i] << endl;
        if(i == 1) ans = ultimatepressed[i];
        else ans = min(ans, ultimatepressed[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11520
#include<bits/stdc++.h>
#include<queue>
#include<deque>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<set>
//#define ll long long
#define MOD 1000000007
#define INF 214748364
using namespace std;
long long read()
{
	long long kk(0);
	bool fh=true;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')fh=false;
		ch=getchar();
	}
	while(ch<='9'&&ch>='0')
	{
		kk=(kk<<3)+(kk<<1)+(ch^48);
		ch=getchar();
	}
	return fh?kk:-kk;
}
int n,m,k,pos,ans[101010],p[101010];
struct city
{
	int p,num,y;
	bool operator < (const city &b) const
	{
		if(p==b.p)return y<b.y;
		else return p<b.p;
	}
}c[101010];
int main()
{
	n=read(),m=read();
	for(int i=1;i<=m;++i)
		c[i].p=read(),c[i].y=read(),c[i].num=i,p[i]=c[i].p;
	sort(c+1,c+m+1);
	c[0].p=0;
	for(int i=1;i<=m;++i)
	{
		if(c[i].p!=c[i-1].p)pos=1;
		else pos++;
		ans[c[i].num]=pos;
	}
	for(int i=1;i<=m;++i)
	{
		k=99999;
		for(;p[i]<=k;)k/=10,putchar('0');
		printf("%d",p[i]);
		k=99999;
		for(;ans[i]<=k;)k/=10,putchar('0');
		printf("%d",ans[i]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 3456
#include <stdio.h>

int main(){
  int N,i,count=0;;
  scanf("%d",&N);
  int A[N];
  for(i=0; i<N; i++)
    scanf("%d",&A[i]);
  int flag = 1;
  while(flag){
    flag = 0;
    for(int j=N-1; j>=1;j--){
      if(A[j] < A[j-1]){
	int v;
	v = A[j];
	A[j] = A[j-1];
	A[j-1] = v;
	flag = 1;
	count++;
      }
    }
  }
  for(i=0; i<N-1; i++)
    printf("%d ",A[i]);
  printf("%d\n",A[N-1]);
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1828
import copy

N,M,V,P=map(int,input().split())
A=list(map(int,input().split()))

def condition(num):
    test=copy.copy(A)
    x=test[num]+M
    test[num]+=M
    test.sort(reverse=True)
    k=test.index(x)
    index=k+1
    if index>P:
        return False

    test=test[P:]
    yoyuu=0
    for i in range(0,len(test)):
        if x-test[i]>M:
            yoyuu+=M
        else:
            yoyuu+=x-test[i]

    return yoyuu>=M*(V-P)

A.sort()
start=0
end=N-1
while end-start>1:
    t=(end+start)//2
    if condition(t):
        end=t
    else:
        start=t

if condition(start):
    print(N-start)
else:
    print(N-end)

Measured memory_bytes: 87532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  long long a,b;
  cin >> a >> b;
  if((b-a)%2){
    cout << "IMPOSSIBLE\n";
  }else{
    cout << a+(b-a)/2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
#define ALL(x) x.begin(),x.end()
#define P pair<int,int>
#define MOD 1000000007

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> undergcd(n);
  vector<ll> overgcd(n);
  vector<ll> allgcd(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  undergcd[0] = a[0];
  overgcd[n - 1] = a[n - 1];
  for (int i = 1; i < n; i++) {
    undergcd[i] = __gcd(undergcd[i - 1], a[i]);
    overgcd[n - 1 - i] = __gcd(overgcd[n - i], a[n - 1 - i]);
  }
  allgcd[0] = overgcd[1];
  allgcd[n - 1] = undergcd[n - 2];
  for (int i = 1; i < n - 1; i++) {
    allgcd[i] = __gcd(undergcd[i - 1], overgcd[i + 1]);
  }
  sort(ALL(allgcd));
  cout << allgcd[n - 1] << endl;

  return 0;
}


Measured memory_bytes: 6184
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
sum = 0
n.times{|t|
  if a[t]>=b[t] then
    sum += b[t]
  else
    amari = b[t] - a[t]
    sum += a[t]
    if amari >= a[t+1] then
      sum += a[t+1]
      a[t+1] = 0
    else
      a[t+1] -= amari
      sum += amari
    end
  end
}
print sum   

Measured memory_bytes: 15508
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int h,w,i,j,k,cnt,flg,hw[100][100];
	char a[100][101];
	cin>>h>>w;
	for(i=0;i<h;i++) cin>>a[i];
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(a[i][j]=='c') hw[i][j]=0;
			else {
				cnt=1; flg=0;
				for(k=j-1;k>=0;k--){
					if(a[i][k]=='c'){
						flg=1;
						break;
					}
					cnt++;
				}
				if(flg==1) hw[i][j]=cnt;
				else hw[i][j]=-1;
			}
		}
	}
	for(i=0;i<h;i++){
		for(j=0;j<w-1;j++) cout<<hw[i][j]<<' ';
		cout<<hw[i][j]<<endl;
	}
	return 0;
}

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

int main(void)
{
  int sales_amount=0,sales_quantity=0,sum=0,count=0;
  double average=0;

  while(scanf("%d,%d",&sales_amount,&sales_quantity) != EOF){
    count++;
    sum += sales_amount*sales_quantity;
    average += sales_quantity;
  }


  printf("%d\n",sum);
  printf("%d\n",(int)(ceil(average/count)));

  return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int gcd(int x, int y) {
	return y == 0 ? x : gcd(y, x%y);
}

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

	int N, Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	vector<int> dp(N + 1);
	dp[0] = 0;
	dp[1] = 0;
	FOR(i, 2, N + 1) {
		if (S[i - 1] == 'C' && S[i - 2] == 'A') dp[i] = dp[i - 1] + 1;
		else dp[i] = dp[i - 1];
	}

	REP(i, Q) {
		int l, r;
		cin >> l >> r;
		cout << dp[r] - dp[l] << "\n";
	}
	
	return 0;
}

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

using MI = unsigned long;
using MLL = unsigned long long;

static const MI b7 = 1000000007u;
MI mul(MI a, MI b) { return (MI)(((MLL)a * (MLL)b) % b7); }

int main() {
	int n, k; cin >> n >> k;
	MI ans = 1u;
	vector<vector<int>> e;
	e.resize(n);
	vector<int> p; p.assign(n, 0);
	bool d[100000] = {};
	for (int i = 0; i < n - 1; i++) {
		int a, b; cin >> a >> b;
		e[a - 1].push_back(b - 1);
		e[b - 1].push_back(a - 1);
	}
	queue<int> q; q.push(0);
	while(!q.empty()) {
		int i = q.front(); q.pop();
		if (d[i]) continue;
		d[i] = true;
		int c = k - p[i];
		for (int j = 0; j < e[i].size(); j++) {
			c -= p[e[i][j]]; p[e[i][j]]++;
			q.push(e[i][j]);
		}
		if (c <= 0) { cout << 0; return 0; }
		ans = mul(ans, (MI)c);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7032
import sys
from heapq import heappush, heappop, heapify
input = sys.stdin.readline

def main():
    N = int(input())
    g = [[] for i in range(N)]
    
    for i in range(N-1):
        a, b, c = map(int, input().split())
        a -= 1; b -= 1
        g[a].append((c, b))
        g[b].append((c, a))
        
    Q, K = map(int, input().split())
    K -= 1
    dist = [0] * N
    visited = [False] * N
    
    q = [(c, v) for c, v in g[K]]
    heapify(q)
    
    dist[K], visited[K] = 0, True
    
    while q:
        c, v = heappop(q)
        
        if visited[v]: continue
        dist[v], visited[v] = c, True
        
        for d, u in g[v]:
            if visited[u]: continue
            heappush(q, (c+d, u))
        
    for i in range(Q):
        x, y = map(int, input().split())
        
        print(dist[x-1]+dist[y-1])
        
if __name__ == '__main__':
    main()

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

int main() {
    int n;
    cin>>n;
    vector<int>x(n);
    int sum=0;
    for (int i = 0; i<n; i++) {
        cin >> x[i];
        sum += x[i];
    }
    sum/=n;
    int res=0, res1=0;
    for (int i = 0; i < n; i++) {
        res += (x[i] - sum) * (x[i] - sum);
        res1 += (x[i]-sum-1)*(x[i]-sum-1);
    }
    cout<<min(res,res1);
    return 0;
}


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

const int MOD = 998244353;
const int INF = 1e9;

int main(){
  int n,k;
  const int max_n = 2 * 1e5;
  cin >> n >> k;
  int l[11], r[11];
  for(int i = 0; i < k; i++) cin >> l[i] >> r[i];

  vector<long long> dp(max_n + 1, 0);
  vector<long long> dpsum(max_n + 1, 0);
  // vector<vector<int>> dp(max_n + 1, vector<int>(11, 0));
  dp[1] = 1;
  dpsum[1] = dp[1];
  for(int i = 2; i <= n; i++){
    for(int j = 0; j < k; j++){
      if(i-l[j] < 1) dp[i] += 0;
      else if(i - r[j] < 2) dp[i] += dpsum[i - l[j]];
      else dp[i] += dpsum[i-l[j]] - dpsum[i-r[j]-1];
    }
    dp[i] %= MOD;
    if(dp[i] < 0) dp[i] += MOD;
    dpsum[i] = dpsum[i-1] + dp[i];
    dpsum[i] %= MOD;
    if(dpsum[i] < 0) dpsum[i] += MOD;
    // cout << dp[i] << endl;
  }

  cout << dp[n] << endl;


  return 0;
}

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

int main (){
        int a,b,d,r;
        double f;
        cin >> a >> b;

        d = a/b;
        r = a%b;
        f = (double)a/(double)b;

        cout<<fixed<<setprecision(10);
        cout << d << " " << r << " "<< f ;

        return 0;
}

Measured memory_bytes: 3220