akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int 
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define pqmin priority_queue<ll,vector<ll>,greater<ll>>
#define pqmax priority_queue<ll>
using namespace std;
ll power(ll a,ll n){
	if(n==0)
	  return 1;
	if((n%2)==0)
	  return (power((a*a)%mod,n/2))%mod;
	else
	  return (a*(power((a*a)%mod,n/2))%mod)%mod;    
}


int main()
 {
      IOS;
  ll n;
  cin>>n;
  ll a[n];
  ll s[n];
  for(int i=0;i<n;i++)
  {
  	cin>>a[i];
  	s[i]=a[i];
  }
  for(int i=n-2;i>=0;i--)
  {
  	s[i]=(s[i]+s[i+1])%mod;
  }
  ll ans=0;
  for(int i=0;i<n-1;i++)
  {
  	ans=(ans+(a[i]*s[i+1])%mod)%mod;
  }
  cout<<ans<<endl;
  
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

int dp[105][10][10], s, n;
int f(int a, int b, int c) {
  if(dp[a][b][c] != -1) return dp[a][b][c];
  if(a == s && c == n && b <= 10) return 1;
  if(a > s || c > n || b == 10) return 0;
  int res = 0;
  res += f(a+b, b+1, c+1);
  res += f(a, b+1, c);
  return dp[a][b][c] = res;
}

signed main(void)
{
  while(1) {
    cin >> n >> s;
    if(!n && !s) break;
    REP(i, 105) REP(j, 10) REP(k, 10) dp[i][j][k] = -1;
    cout << f(0, 0, 0) << endl;
  }
  return 0;
}

Measured memory_bytes: 3044
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){
  string S; cin >> S;

  bool flag = true;
  for (int i = 0; i < S.length(); i++){
    if (i % 2 == 0 && S[i] == 'L'){
      flag = false;
    }else if(i % 2 != 0 && S[i] == 'R'){
      flag = false;
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0; i<n ; ++i)
#define lpx(i,x,n) for(int i=x; i<n ; ++i)
#define all(v) v.begin() , v.end()
#define sz(v) (int(v.size()))
typedef unsigned long long ul;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<char, int> pci;
typedef vector<pii> vp;
typedef vector<pci> vpc;
typedef pair<int,pii> piii;

int OO = 2e9;
const double eps = 1e-9 ;
const int N = 500000;
int mx = -1e9 , mn = 1e9 ;
int arr[N] ;

int dcmp(double x, double y)
{
    return fabs(x - y) <= eps ? 0 : x > y ? -1 : 1;
}
ul fac(int n)
{
    if(n > 1)
        return n * fac(n - 1);
    else
        return 1;
}



int main()
{

    int a, b , ans = 1;cin>> a>> b;
    int x=a-1;
    if(b == 1)cout<<" 0\n";
    else{
        while(a<b){
            a+= x;
            ++ans;
        }
        cout << ans << endl;
    }


    return 0;
}












Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//Get the highest value and key from a map.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

int main() {
  ll a;
  double b;
  cin >> a >> b;

  ll xb = b * 100 + 0.1;
  cout << (a * xb) / 100 << endl;


  return 0;
}


Measured memory_bytes: 3736
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int h,w;
string fie[11];
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};
map<string,int> cnt;
bool used[11][21];
vector<string> index2;

void dfs(int y,int x,int k,string str){
	if(used[y][x])return;
	used[y][x]=true;
	str+=fie[y][x];
	cnt[str]++;
	index2.push_back(str);
	dfs((y+dy[k]+h)%h,(x+dx[k]+w)%w,k,str);
}

int main(void){
	while(1){
		scanf("%d %d",&h,&w);
		if(h+w==0)break;
		cnt.clear();
		index2.clear();
		for(int i=0;i<h;i++){
			cin >> fie[i];
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				for(int k=0;k<8;k++){
					memset(used,false,sizeof(used));
					dfs(i,j,k,"");
				}
			}
		}
		sort(index2.begin(),index2.end());
		index2.erase(unique(index2.begin(),index2.end()),index2.end());
		string res="0";
		for(int i=0;i<index2.size();i++){
			if(cnt[index2[i]]>=2 && index2[i].size()>=2){
				if(res.size()<index2[i].size() || (res.size()==index2[i].size() && index2[i]<res)){
					res=index2[i];
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int r;
    cin >> r;
    cout << 3 * r * r << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define MOD 998244353
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
typedef unsigned short int usi;

// 昇順
int cmp(const void *a, const void *b) {
    return *(int*)a - *(int*)b;
}

int GCD(int a, int b) {
    if(a<b) {
        int tmp = a;
        a = b;
        b = tmp;
    }
    while(a%b) {
        int temp = b;
        b = a%b;
        a = temp;
    }
    return b;
}

int main()
{
    int n, i, gcd;
    scanf("%d",&n);
    int a[n];
    for(i=0; i<n; i++) {
        scanf("%d",a+i);
    }
    gcd = a[0];
    //puts("init");
    for(i=1; i<n; i++) {
        gcd = GCD(gcd, a[i]);
        //puts("ok");
    }
    printf("%d", gcd);
    return 0;
}


Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

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

		int n = sc.nextInt();
		int k = sc.nextInt();
		List<Integer> a = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			a.add(sc.nextInt());
		}
		sc.close();

		Collections.sort(a);

		int result = 0;
		for (int i = 0; i < k; i++) {
			result += a.get(i);
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 30424
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){
  int i,j,k;
  int p,c,r,s[1000000],t[78500];
  memset(s,0,sizeof(s));
  s[2]=1;
  t[0]=2;
  j=1;
  for(i=3;i<1000000;i+=2){
    r=(int)sqrt(i)+1;
    for(k=3;k<r;k+=2){
      if(i%k==0)
	break;
    }
    if(k>=r){
      s[i]=1;
      t[j]=i;
      j++;
    }
  }
  for(;;){
    scanf("%d",&p);
    if(p==0)
      break;
    c=0;
    for(i=0;t[i]<p/2+1;i++){
      if(s[p-t[i]])
	c++;
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 4564
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 入力(S)
      	String S = sc.next();
        //入力(T)
      	String T = sc.next();
        //カウント
        int count=0;

      	for(int i=0;i<S.length();i++){
          if(S.charAt(i) != (T.charAt(i))){
          	count ++;
          }
        }

		// 出力
		System.out.println(count);
	}
}

Measured memory_bytes: 41276
#include <bits/stdc++.h>
using namespace std;
int main() {
	int X[3][3];
	int A, B, C;
	cin >> A >> B >> C;
	X[0][0] = A, X[0][1] = B, X[1][1] = C;
	int S = 3 * C;
	X[0][2] = 3 * C - A - B;
	X[1][0] = 4 * C - 2 * A - B;
	X[1][2] = 2 * A + B - 2 * C;
	X[2][0] = A + B - C;
	X[2][1] = S - B - C;
	X[2][2] = S - A - C;
	for(int i = 0; i < 3; i++) {
		for(int j = 0; j < 3; j++) {
			cout << X[i][j] << (j != 2 ? " ": "");
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
cnt = 0

n, m = gets.chomp.split(" ").map{|i|i.to_i}
h = gets.chomp.split(" ").map{|i|i.to_i}
a=[]; b=[]
m.times do |i|
  a[i], b[i] = gets.chomp.split(" ").map{|j|j.to_i}
end

max=Array.new(n+1, 0)
0.upto(a.size-1) do |i|
  max[a[i]] = [h[b[i]-1], max[a[i]]].max
  max[b[i]] = [h[a[i]-1], max[b[i]]].max
end
1.upto(n) do |i|
  cnt += 1 if max[i] < h[i-1]
end
puts cnt

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

using namespace std;

void getDigits(long long n, vector<int>& v)
{
    // cout << "getting digits of: " << n << " ==> ";
    v.clear();
    while (n > 0)
    {
        v.push_back(n%10);
        n /= 10;
    }
    reverse(v.begin(), v.end());
    // for( auto& i : v) cout << i << " ";
    // cout << endl;
}

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

    int n;
    int found = 0;
    vector<int> digits;

    cin >> n;

    long long i=1;
    while(found < n)
    {
        // cout << "testing i=" << i << endl;
        getDigits(i, digits);
        bool is_lun = true;

        // test if number i is lunlun number
        for(int j=0; j<digits.size()-1; j++)
        {
            if (digits[j+1] < digits[j] -1)
            {
                i += (digits[j] - digits[j+1] -1) * pow(10, digits.size()-j-2);
                is_lun = false;
            }
            else if (digits[j+1] > digits[j] + 1)
            {
                i -= i % (int) pow(10, digits.size()-j-1);
                i += pow(10, digits.size()-j-1);
                is_lun = false;
                break;
            }
        }

        // update number of lunlun found
        if (is_lun) 
        {
            found++;
            i++;
        }
    }

    cout << i-1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int ans = 0;
    rep(i, n) {
        if (s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}


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

using namespace std;

/*------------------------------<Debugging Stuff>---------------------------------*/

template<class L, class R> ostream& operator<<(ostream &os, pair<L , R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R , class M> ostream& operator<<(ostream &os, tuple<L , R , M> P) {
    return os << "(" << get<0>(P) << "," << get<1>(P) << "," << get<2>(P) << ")";
}
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "{ "; for(auto v : V) os << v << " "; return os << "}";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

/*------------------------------</Debugging Stuff>--------------------------------*/

#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define double long double
#define endl '\n'

// dp[i][j] = after processing first (i + 1) elements and total w = j : max possible value
// Case 1 - taking ith element : dp[i][j] = dp[i - 1][j - w[i]] + v[i];
// Case 2 - not taking ith element : dp[i][j] = dp[i - 1][j]

const int INF = (int) 1e18 + 18;

signed main() {
    fio;
    int N , W; cin >> N >> W;
    vector<int> w(N) , v(N);
    for(int i = 0; i < N; i++) cin >> w[i] >> v[i];
    vector<vector<int>> dp(N + 1 , vector<int>(W + 1));
    dp[0][w[0]] = v[0];
    for(int i = 1; i < N; i++) {
        for(int j = 0; j <= W; j++) {
            if(j >= w[i]) {
                dp[i][j] = max(dp[i][j] , dp[i - 1][j - w[i]] + v[i]);
            }
            dp[i][j] = max(dp[i][j] , dp[i - 1][j]);
        }
    }
    
    cout << *max_element(dp[N - 1].begin() , dp[N - 1].end()) << endl;
    
    return 0;
}



Measured memory_bytes: 80256
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MOD = 1e9+7;

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

    int a,b,c,k;
    cin >> a >> b >> c >> k;

    if(k<=a){cout << k << endl; return 0;}
    if(k>a && k<=a+b){cout << a << endl; return 0;}
    else{cout << a-(k-a-b) << endl; return 0;}

    return 0;
}

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


const int mod = 1000000007;
struct mint {
  long long x;
  mint(long long x = 0):x((x % mod + mod) % mod) {}
  mint operator-() const {return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};


int main() {

  int N;
  cin >> N;

  mint answer = 1;

  for (int i = 1; i <= N; i++) {
    answer *= i;
  }

  cout << answer.x << endl;

}

Measured memory_bytes: 256
class Dice:
    def __init__(self,top,front,right,left,back,bottom):
        self.top, self.bottom=top,bottom
        self.right, self.left=right,left
        self.front, self.back=front,back
    def turn(self,order):
        if order=="N":
            self.top,self.front,self.bottom,self.back=self.front,self.bottom,self.back,self.top
        if order=="S":
            self.top,self.front,self.bottom,self.back=self.back,self.top,self.front,self.bottom
        if order=="E":
            self.top,self.right,self.bottom,self.left=self.left,self.top,self.right,self.bottom
        if order=="W":
            self.top,self.right,self.bottom,self.left=self.right,self.bottom,self.left,self.top

d=map(int,raw_input().split())
dice=Dice(d[0],d[1],d[2],d[3],d[4],d[5])
q=input()
for i in range(q):
    t,f=map(int,raw_input().split())
    if t==d[0]:
        if f==d[1]:
            print d[2]
        elif f==d[2]:
            print d[4]
        elif f==d[4]:
            print d[3]
        elif f==d[3]:
            print d[1]
    elif t==d[1]:
        if f==d[0]:
            print d[3]
        elif f==d[3]:
            print d[5]
        elif f==d[5]:
            print d[2]
        elif f==d[2]:
            print d[0]
    elif t==d[2]:
        if f==d[0]:
            print d[1]
        elif f==d[1]:
            print d[5]
        elif f==d[5]:
            print d[4]
        elif f==d[4]:
            print d[0]
    elif t==d[3]:
        if f==d[0]:
            print d[4]
        elif f==d[4]:
            print d[5]
        elif f==d[5]:
            print d[1]
        elif f==d[1]:
            print d[0]
    elif t==d[4]:
        if f==d[0]:
            print d[2]
        elif f==d[2]:
            print d[5]
        elif f==d[5]:
            print d[3]
        elif f==d[3]:
            print d[0]
    elif t==d[5]:
        if f==d[1]:
            print d[3]
        elif f==d[3]:
            print d[4]
        elif f==d[4]:
            print d[2]
        elif f==d[2]:
            print d[1]
    else:
        print "no answer"


Measured memory_bytes: 4744
#include <iostream>
#include <stdint.h>
#include <vector>

using namespace std;

static vector<int64_t> array;

int32_t main()
{
  int64_t N, x;
  cin >> N >> x;

  for (uint32_t i = 0; i < N; i++) {
    uint64_t a;
    cin >> a;
    array.push_back(a);
  }

  uint64_t count = 0;
  for (uint32_t i = 0; i < array.size() - 1; i++) {
    int64_t sum = array[i] + array[i + 1];
    if (sum > x) {
      int64_t diff = sum - x;
      array[i + 1] -= min(array[i + 1], diff);
      count += diff;
    }
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 1400
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

    string s; cin>>s;


   vi cnt(2019);
   int base = 1, sum, n = s.length();  
    
    cnt[0]++ ,cnt[sum = s[n-1]-'0']++;

    for(int i = n-2; i>= 0; --i){
        cnt[sum = (sum + (s[i]-'0')*(base = base * 10 %2019))%2019]++;
    }
    ll ans = 0;
    for(int i = 0; i < 2019; i++){
        if(cnt[i] > 1)ans += (cnt[i])*(cnt[i] - 1)/2;
        
    }
    cout<<ans<<"\n";








}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



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

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

Measured memory_bytes: 1024
def D_Unbalanced():
    from collections import Counter
    s = list(input())
    xx = []
    xyx = []
    ans = [-1, -1]
    if s[0] == s[1]:
        ans = [1, 2]
    for x in range(len(s)-2):
        if s[x] == s[x+1]:
            xx.append(s[x])
            ans = [x+1, x+2]
            break
        if s[x] == s[x+2]:
            xyx.append(s[x])
            ans = [x+1, x+3]
            break

    print(*ans)
    
if __name__ == "__main__":
    D_Unbalanced()

Measured memory_bytes: 4340
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = int.Parse(ReadLine());
        long i = 1;
        for(; ; i++)
        {
            if(i * (i + 1) / 2 >= n)
            {
                WriteLine(i);
                return;
            }
        }
    }
}


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

int main()
{
  int n;
  cin >> n;
  int m = n;
  int c = 0;
  while(n > 0){
    c += n % 10;
    n /= 10;
  }
  
  
  
  cout << (m % c == 0 ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 3560
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int[] v = new int[N];
		for (int i = 0; i < N; ++i) {
			v[i] = sc.nextInt();
		}
		ArrayList<Integer> ans = new ArrayList<Integer>();
		for (int i = 1; i <= (int) Math.sqrt(v[0]); ++i) {
			if (v[0] % i != 0) continue;
			boolean ok = true;
			for (int j = 1; j < N; ++j) {
				if (v[j] % i != 0) {
					ok = false;
					break;
				}
			}
			if (ok) ans.add(i);
			if (i * i != v[0]) {
				ok = true;
				for (int j = 1; j < N; ++j) {
					if (v[j] % (v[0] / i) != 0) {
						ok = false;
						break;
					}
				}
				if (ok) ans.add(v[0] / i);
			}
		}
		Collections.sort(ans);
		for (int a : ans) {
			System.out.println(a);
		}
	}

}

Measured memory_bytes: 17340
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main(){
    int r;cin >> r;
    cout << 3*r*r << endl;
    return 0;
}


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

using namespace std;

int main() {
	int n;
	int a = 0;
	int w = 0;
	int t = 0;
	int r = 0;

	cin >> n;
	string s;

	for(int i = 0; i < n; i++) {
		cin >> s;
		if (s == "AC")
				a++;
		if (s == "WA") w++;
		if (s == "TLE") t++;
		if (s == "RE") r++;
	}


		
cout << "AC x " <<  a << endl;
	cout << "WA x " << w << endl;
cout << "TLE x "  <<  t << endl;
	cout << "RE x " <<   r <<  endl;
	
	return 0;
}
	


Measured memory_bytes: 3628
import java.io.*;
import java.util.*;
 
public class Main{
	class Pair{
		int idx;
		int value;
		public Pair(int idx, int value){
			this.idx = idx;
			this.value = value;
		}
	}
	int N;
	Pair[] A;
	public void solve(){
		N = nextInt();
		A = new Pair[N];
		for(int i = 0; i < N; i++){
			A[i] = new Pair(i, nextInt());
		}
		Arrays.sort(A, (a,b) -> Integer.compare(a.value, b.value));
		int ans = 0;
		for(int i = 0; i < N; i += 2){
			if(A[i].idx % 2 != 0){
				ans++;
			}
		}
		out.println(ans);
	}
	
	private static PrintWriter out;
	public static void main(String[] args){
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	
	
	
	public static int nextInt(){
		int num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10 + (c - '0');
		}
		return minus ? -num : num;
	}
	
	public static long nextLong(){
		long num = 0;
		String str = next();
		boolean minus = false;
		int i = 0;
		if(str.charAt(0) == '-'){
			minus = true;
			i++;
		}
		int len = str.length();
		for(;i < len; i++){
			char c = str.charAt(i);
			if(!('0' <= c && c <= '9')) throw new RuntimeException();
			num = num * 10l + (c - '0');
		}
		return minus ? -num : num;
	}
	public static String next(){
		int c;
		while(!isAlNum(c = read())){}
		StringBuilder build = new StringBuilder();
		build.append((char)c);
		while(isAlNum(c = read())){
			build.append((char)c);
		}
		return build.toString();
	}
	
	
	private static byte[] inputBuffer = new byte[1024];
	private static int bufferLength = 0;
	private static int bufferIndex = 0;
	private static int read(){
		if(bufferLength < 0) throw new RuntimeException();
		if(bufferIndex >= bufferLength){
			try{
				bufferLength = System.in.read(inputBuffer);
				bufferIndex = 0;
			}catch(IOException e){
				throw new RuntimeException(e);
			}
			if(bufferLength <= 0) return (bufferLength = -1);
		}
		return inputBuffer[bufferIndex++];
	}
	
	private static boolean isAlNum(int c){
		return '!' <= c && c <= '~';
	}
}

Measured memory_bytes: 24936
#include<stdio.h>
main()
{
    int n,a,i,b,c=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a);
        if((a%2==0&&a&3!=0&&a%5!=0)||(a%3!=0&&a%2==0&&a%5!=0))
        {

            c=1;
            printf("DENIED");
            break;
        }

    }
        if(c==0)
        printf("APPROVED");

}


Measured memory_bytes: 128
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
	ll dp[110][100010];
int main(){
	ll n,w;
	cin>>n>>w;
	ll a[110],b[110];
	rep(i,0,n)cin>>a[i]>>b[i];
	rrep(i,n,0){
		rep(j,0,w+1){
			if(j<a[i])dp[i][j]=dp[i+1][j];
			else dp[i][j]=max(dp[i+1][j],dp[i+1][j-a[i]]+b[i]);
		}
	}
	ll ans=0;
	rep(j,0,w+1)ans=max(ans,dp[0][j]);
	cout<<ans<<endl;
}

Measured memory_bytes: 80128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

class union_find {
public:
vector<int> par,rank,lsize;
union_find(int n): par(n),rank(n),lsize(n)
{
   for (int i=0;i < n;i++){
      par[i]=i;
      rank[i]=0;
      lsize[i]=1;
   }
}

int find(int x){
   if (par[x]==x){
      return x;
   }
   else{
      return par[x] = find(par[x]); 
   }
}

void unite(int x ,int y){
   x=find(x);
   y=find(y);
   if (x==y) return;
   if (rank[x] < rank[y]){
      lsize[y] += lsize[x];
      lsize[x] = -1;
      par[x] = y;
   }else{
      lsize[x] += lsize[y];
      lsize[y] = -1;
      par[y]=x;
      if (rank[x]==rank[y]) rank[x]++;
   }   
}

bool same(int x, int y){
   return find(x) == find(y);
}

int size(int x){
   if (lsize[x] == -1){
      x=find(x);
   }
   return lsize[x];
}
};

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    union_find tree(n);
    vector<int> f(n,0);
    vector<int> b(n,0);
    rep(i,m){
       int x,y;
       cin >> x >> y;
       x--;y--;
       tree.unite(x,y);
       f[x]+=1;
       f[y]+=1;
    }
    rep(i,k){
       int x,y;
       cin >> x >> y;
       x--;y--;
       if (tree.same(x,y)){
         b[x]+=1;
         b[y]+=1;
       }
    }
    rep(i,n){
       cout << tree.size(i)-1-f[i]-b[i] << " ";
    }
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
bool IsSquare(int n) {
    for(int i = sqrt(n) + 1;i > 0;i--) {
        if(i * i == n) {
            return true;
        }
        if(i * i < n) {
            return false;
        }
    }
    return false;
}
int main() {
  int n;
  cin >> n;
  for(int i = n;i > 0;i--) {
    if(IsSquare(i)) {
      cout << i << endl;
      return 0;
    }
  }
}

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

int main(void){
    int S;
    cin >> S; 
    cout << S/3600;
    cout << ":";
    S %= 3600;
    cout << S/60;
    cout << ":";
    S %= 60;
    cout << S%60;
    cout << endl;
}



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

int main(void){
    int a,b;
    string s,t,u;

    cin >> s >> t >> a >> b >> u;

    if(s == u){
        cout << a - 1 << " " << b << endl;
    }else if(t == u){
        cout << a << " " << b - 1 << endl;
    }else{
        cout << " " << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[7]:


import numpy as np


# In[21]:


N,M,C = map(int, input().split())
B = list(map(int, input().split()))
A = []
for i in range(N):
    A.append(list(map(int, input().split())))


# In[22]:


B = np.array(B)
A = np.array(A)


# In[23]:


print(sum(np.sum(A * B, axis=-1) + C > 0))


# In[ ]:






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

using namespace std;

const int M = 1e9+7;
typedef long long ll;

long long mpow(long long a, long long b)
{
    if (b == 0) return 1;
    if (b % 2 == 0) {
        long long memo = mpow(a, b/2);
        return memo * memo % M;
    } else {
        return a * mpow(a, b-1) % M;
    }
}

long long nCr(long long n, long long r)
{
    long long an = 1;
    for (long long i = 0; i < r; ++i) {
        an *= (n-i);
        an %= M;
        an *= mpow(r-i, M-2);
        an %= M;
    }
    return an;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long n, a, b;
    cin >> n >> a >> b;
    long an = mpow(2, n) - 1;
    an -= nCr(n, a);
    an %= M;
    if (an < 0) an += M;
    an -= nCr(n, b);
    an %= M;
    if (an < 0) an += M;
    cout << an << endl;

    return 0;
}


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

using namespace std;

typedef pair<int,int> ii;

#define X first
#define Y second

const int N=1e5+10;
const int inf=1e9+10;

int n;
vector <int> v[N];

int pa[N];
int q[N];
void BFS(int st){
        q[1]=st;
        pa[st]=-1;
        int top=1,bot=1;
        while (top<=bot){
                int x=q[top++];
                for(auto y:v[x]) if (y!=pa[x]){
                        pa[y]=x;
                        q[++bot]=y;
                }
        }
}

int f[N][2];
int solve(){
        for(int i=n;i>=1;i--){
                int x=q[i];
                if (v[x].size()==1){
                        f[x][1]=1;
                        f[x][0]=0;
                        continue;
                }
                int n1=v[x].size();
                int nson=n1-(i!=1);
                if (nson==1){
                        for(auto y:v[x]) if (y!=pa[x])
                                f[x][0]=f[y][0],f[x][1]=f[y][1];
                        continue;
                }
                int sum=0;
                for(int j=0;j<n1;j++) if (v[x][j]!=pa[x])
                        sum+=f[v[x][j]][1];
                f[x][1]=sum;
                f[x][0]=inf;
                for(int j=0;j<n1;j++) if (v[x][j]!=pa[x]){
                        f[x][1]=min(f[x][1],sum-f[v[x][j]][1]+f[v[x][j]][0]);
                }
        }
        return min(f[q[1]][1],f[q[1]][0]);
}
int main(){
        cin>>n;
        for(int i=1;i<n;i++) {
                int x,y;
                cin>>x>>y;
                v[x].push_back(y);
                v[y].push_back(x);
        }
        int st=0;
        while (st<n&&v[st].size()<=2) st++;
        if (st==n){
                cout<<"1";
                return 0;
        }
        BFS(st);
        cout<<solve();
}


Measured memory_bytes: 7808
#include <iostream>
using namespace std;
int main(){
	int n,i,sum=0;
	cin>>n;
	int b[n];
	for(i=1;i<n;i++)cin>>b[i];
	sum+=b[1]+b[n-1];
	for(i=1;i<n-1;i++)sum+=min(b[i],b[i+1]);
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int main()
{
  string S;

  cin >> S ;

  if (S[S.size()-1] == 's')
    S += "es";
  else
    S += "s";
  cout << S << endl;
  return 0;
}


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

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

using namespace std;

int main(){
  int n, a, b;
  long long grandy = 0;
  cin >> n >> a >> b;
  int piles[n];
  int over = 0;
  REP(i, n) cin >> piles[i];

  if (a == b){
    REP(i, n) grandy ^= piles[i] % (a+1);
    cout << (grandy == 0 ? "Jiro" : "Hanako") << endl;
    return 0;
  }

  if (a > b){
    REP(i, n) {
      grandy ^= piles[i] % (b+1);
      if(piles[i] > b) over++;
    }
    if (grandy != 0 or over != 0){
      cout << "Hanako" << endl;
    } else cout << "Jiro" << endl;
    return 0;
  }

  int maxim;
  REP(i, n){
    grandy ^= piles[i] % (a+1);
    if(piles[i] > a) { over++; maxim = piles[i]; }
  }
  if(over > 1) cout << "Jiro" << endl;
  else if(over == 0) cout << (grandy == 0 ? "Jiro" : "Hanako") << endl;
  else {
    grandy ^= maxim % (a+1);
    if(maxim - grandy <= a and grandy <= a)
      cout << "Hanako" << endl;
    else
      cout << "Jiro" << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	int n, m;
	cin>>n>>m;
	vector<int> d(n, -1);
	for (int i = 0; i < m; i++) {
		int s, c;
		cin>>s>>c;
		if (s == 1 && c == 0 && n > 1) {
			cout<<-1<<endl;
			return 0;
		}
		if (d[s-1] == -1 || d[s-1] == c) {
			d[s-1] = c;
		} else {
			cout<<-1<<endl;
			return 0;
		}
	}
	for (int i = 0; i < n; i++) {
		if (d[i] == -1) {
			if (i == 0) {
				if (n == 1) {
					d[i] = 0;
				} else {
					d[i] = 1;
				}
			} else {
				d[i] = 0;
			}
		}
	}
	int res = 0;
	for (auto &i : d) {
		res = res*10 + i;
	}
	cout<<res<<endl;
	return 0;
}

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

#define endl '\n'
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
#define ALL(v) v.begin(), v.end()
#define ALLR(v) v.rbegin(), v.rend()
#define deb cout<<"HOLA\n";
#define UNIQUE(v) (v).resize(unique(ALL(v))-(v).begin())
#define forn(i,n) for (ll i = 0; i < n; i++)
#define forr(i,a,b) for (ll i = a; i <= b; i++)
#define bs(v,f) binary_search(ALL(v),f)
#define lb(v,f) lower_bound(ALL(v),f)
#define ub(v,f) upper_bound(ALL(v),f)
#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<ii> vii;

vi a;int n;
vl dp(100005,-1);
ll ans(ll x){
    if(x==n-1)return 0;
    if(x>n-1)return INT_MAX;
    if(dp[x]!=-1)return dp[x];
    ll a1,a2;
    a1=ans(x+1)+abs(a[x]-a[x+1]);
    a2=ans(x+2)+abs(a[x]-a[x+2]);
    return dp[x]=min(a1,a2);
}

void solve(){
	cin>>n;
    a.resize(n+5);
    forn(i,n)cin>>a[i];
    cout<<ans(0);
}
int main(){
    fast
	/*int t;
	cin>>t;
	while(t--)*/
		solve();
	return 0;
}


Measured memory_bytes: 4608
n=int(input())
a=list(map(int,input().split()))
ash=0
brown=0
green=0
lightblue=0
blue=0
yellow=0
orange=0
red=0
ans=0
for i in a:
    if i<=399:
        if ash==0:
            ash+=1
    elif 400<=i<=799:
        if brown==0:
            brown+=1
    elif 800<=i<=1199:
        if green==0:
            green+=1
    elif 1200<=i<=1599:
        if lightblue==0:
            lightblue+=1
    elif 1600<=i<=1999:
        if blue==0:
            blue+=1
    elif 2000<=i<=2399:
        if yellow==0:
            yellow+=1
    elif 2400<=i<=2799:
        if orange==0:
            orange+=1
    elif 2800<=i<=3199:
        if red==0:
            red+=1
    else:
        ans+=1
v=ash+brown+green+lightblue+blue+yellow+orange+red
if v==0:
    print(1,ans)
else:
    print(v,v+ans)

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

const int INF = 1e9;

class min_cost_flow {
	using pii = pair<int, int>;
	struct edge {
		int to, cap, cost, rev;
		edge(int to_, int cap_, int cost_, int rev_)
			: to(to_), cap(cap_), cost(cost_), rev(rev_) {}
	};
	int V;
	vector<vector<edge>> G;
	vector<int> h, dist, prevv, preve;
public:
	min_cost_flow(int _V) : V(_V), G(_V), h(_V), dist(_V), prevv(_V), preve(_V) {}
	void add(int from, int to, int cap, int cost) {
		G[from].push_back(edge(to, cap, cost, G[to].size()));
		G[to].push_back(edge(from, 0, -cost, G[from].size() - 1));
	}
	int calc(int s, int t, int f) {
		int res = 0;
		fill(h.begin(), h.end(), 0);
		while (f > 0) {
			priority_queue<pii, vector<pii>, greater<pii>> que;
			fill(dist.begin(), dist.end(), INF);
			dist[s] = 0;
			que.push(pii(0, s));
			while (!que.empty()) {
				pii p = que.top(); que.pop();
				int v = p.second;
				if (dist[v] < p.first) continue;
				for (size_t i = 0; i < G[v].size(); i++) {
					edge &e = G[v][i];
					if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
						dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
						prevv[e.to] = v;
						preve[e.to] = i;
						que.push(pii(dist[e.to], e.to));
					}
				}
			}
			if (dist[t] == INF) return -1;
			for (int v = 0; v < V; v++)
				h[v] += dist[v];
			int d = f;
			for (int v = t; v != s; v = prevv[v]) {
				d = min(d, G[prevv[v]][preve[v]].cap);
			}
			f -= d;
			res += d * h[t];
			for (int v = t; v != s; v = prevv[v]) {
				edge &e = G[prevv[v]][preve[v]];
				e.cap -= d;
				G[v][e.rev].cap += d;
			}
		}
		return res;
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int N;
	cin >> N;
	vector<int> A(N), B(N), xs;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
		xs.push_back(A[i]);
		xs.push_back(B[i]);
	}
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());
	int V = xs.size();
	min_cost_flow mcf(N + V + 2);
	int s = N + V, t = N + V + 1;
	mcf.add(s, t, INF, 0);
	for (int i = 0; i < N; i++) {
		mcf.add(s, i, 1, 0);
	}
	for (int i = 0; i < N; i++) {
		int a = lower_bound(xs.begin(), xs.end(), A[i]) - xs.begin();
		int b = lower_bound(xs.begin(), xs.end(), B[i]) - xs.begin();
		mcf.add(i, N + a, 1, -B[i]);
		mcf.add(i, N + b, 1, -A[i]);
	}
	for (int i = 0; i < V; i++) {
		mcf.add(N + i, t, 1, 0);
	}
	cout << -mcf.calc(s, t, INF) << endl;
	return 0;
}



Measured memory_bytes: 3452
/**Bismillahir Rahmanir Raheem
    Author:Refatul Fahad**/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
#define IOS  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define sz(s)  (int)s.size()
#define all(s)  s.begin(),s.end()
const int N = 1e5 + 5;
const ll M = (ll)1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}

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

int ar[105];
int main() {

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

    int test=1;
    //cin>>test;
    for(int cs=1; cs<=test; ++cs) {
        ll n,cnt=0;
        cin>>n;
        for(int i=1;i<=n;++i)cin>>ar[i];
        for(int i=1;i<=n;++i){
            for(int j=i+1;j<=n;++j){
                if(i==j)continue;
                for(int k=j+1;k<=n;++k){
                    if(i==k||j==k)continue;
                    set<int>st;
                    st.insert(ar[i]);
                    st.insert(ar[j]);
                    st.insert(ar[k]);
                    if(ar[i]+ar[j]>ar[k]&&ar[j]+ar[k]>ar[i]&&ar[i]+ar[k]>ar[j]&&sz(st)==3){
                        ++cnt;
                    }st.clear();
                }
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}



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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer n;
  for(n = nil->next; n != nil && n->key != key; n = n->next);
  return n;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur;
  int isf = 1;
  for(cur = nil->next;cur != nil; cur = cur->next){
    if(isf == 0) printf(" ");
    printf("%d", cur->key);
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  NodePointer delnode;
  delnode = t;
  delnode->prev->next = delnode->next;
  delnode->next->prev = delnode->prev;
  free(delnode);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if(t == nil) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if(t == nil) return;
  deleteNode(t);
}

void delete(int key){
  NodePointer t;
  t = listSearch(key);
  if(t == nil) return;
  deleteNode(t);
}

void insert(int key){
  NodePointer newnode;
  newnode = malloc(sizeof(struct node));
  newnode->key = key;
  newnode->next = nil->next;
  nil->next->prev = newnode;
  nil->next = newnode;
  newnode->prev = nil;
}

int main(){
  int key,n,i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d",&n);
  init();
  for(i = 0; i < n; i++){
    scanf("%s%d",com,&key);
    if(com[0] == 'i'){
      insert(key);
      np++;
      size++;
    }
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
        if(com[6] == 'F') deleteFirst();
        else if(com[6] == 'L') deleteLast();
      }
      else{
        delete(key);
        nd++;
      }
      size--;
    }
  }

  printList();
  return 0;
}

Measured memory_bytes: 31788
n , m = map(int, input().split())
# ab = [list(map(int, input().split())) for _ in range(m)]
ranges = [[] for _ in range(m)]
for i in range(m):
    a,b = map(int,input().split())
    ranges[i] = [a,b]
ranges = sorted(ranges, key = lambda x:x[1])
MAX = - float("inf")
ans = 0
for i in range(m):
    if MAX <= ranges[i][0]:
        MAX = ranges[i][1]
        ans += 1
print(ans)

Measured memory_bytes: 22116
import sys
n,y=map(int,input().split())
if n*10000<y:
    print("-1 -1 -1")
    sys.exit()
if y//1000<n:
    print("-1 -1 -1")
    sys.exit()
m=y//10000
for i in range(m+1):
    g=(y-i*10000)//5000
    for j in range(g+1):
        s=(y-10000*i-5000*j)//1000
        if i+j+s==n and s>=0:
            print(i,j,s)
            sys.exit()
print("-1 -1 -1")

Measured memory_bytes: 3064
console.log((args=>{
  const X = args.trim()|0;
  if ( X < 600 ) return '8';
  else if ( X < 800 ) return '7';
  else if ( X < 1000 ) return '6';
  else if ( X < 1200 ) return '5';
  else if ( X < 1400 ) return '4';
  else if ( X < 1600 ) return '3';
  else if ( X < 1800 ) return '2';
  return '1';
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 29676
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	string s, ss = "CODEFESTIVAL2016";
	cin >> s;
	int ct = 0, i;
	for (i = 0; i < 16; i++) {
		if (s[i] != ss[i])ct++;
	}
	cout << ct << "\n";

	return 0;
}



Measured memory_bytes: 256
h,w = map(int,input().split())

ans = float('inf')

if h%3==0 or w%3==0:
    print(0)
    exit()

#縦割り
ans = min(ans, w)

#横割り
ans = min(ans, h)

#縦割り+横半分
for x in range(1, w+1):
    tate_area = x*h
    yoko_min_area = (w-x)*(h//2)
    yoko_max_area = (w-x)*(h-h//2)
    area_max = max(tate_area, yoko_min_area, yoko_max_area)
    area_min = min(tate_area, yoko_min_area, yoko_max_area)
    ans = min(ans, area_max-area_min)
    #print(ans, tate_area, yoko_min_area, yoko_max_area)

#横割り+縦半分
for y in range(h//3, h+1):
    yoko_area = y*w
    tate_min_area = (h-y)*(w//2)
    tate_max_area = (h-y)*(w-w//2)
    area_max = max(yoko_area, tate_min_area, tate_max_area)
    area_min = min(yoko_area, tate_min_area, tate_max_area)
    ans = min(ans, area_max-area_min)

print(ans)

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

using namespace std;

int main() {
  string S, T;
  cin >> S >> T;
  for (int i = S.length() - T.length(); i >= 0; i--) {
    bool ok = true;
    for (int j = 0; j < T.length(); j++) {
      if (S[i + j] != '?' and S[i + j] != T[j]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      for (int ii = 0; ii < i; ii++) {
        cout << (S[ii] == '?' ? 'a' : S[ii]);
      }
      for (int ii = i; ii < i + T.length(); ii++) {
        cout << T[ii - i];
      }
      for (int ii = i + T.length(); ii < S.length(); ii++) {
        cout << (S[ii] == '?' ? 'a' : S[ii]);
      }
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int oo = 1e9;
const int MOD = 1000000007;
const int BASE = 26;
const int N = 200001;
#define pb push_back
#define mp make_pair
#define x first
#define y second

int n , c , a[401], b[401], sum[401][401], dp[401][401], cur[401];

int calc(int idx , int rem) {
	if (idx == n)return (rem == 0) ? 1 : 0;
	int &ret = dp[idx][rem];
	if (ret != -1)return ret;
	ret = 0;
	for (int f = 0 ; f <= rem ; ++f) {
		ret = (1ll*ret+(1ll*sum[f][b[idx]]-sum[f][a[idx]-1]+MOD)%MOD*calc(idx+1,rem-f))%MOD;
	}
	return ret;
}
int main() {
	memset(dp, -1, sizeof dp);
	scanf("%d%d", &n, &c);
	for (int i = 0; i < n; ++i)
		scanf("%d", &a[i]);
	for (int i = 0; i < n; ++i)
		scanf("%d", &b[i]);
	for (int i = 0; i <= 400; ++i)cur[i] = 1;
	for (int f = 0; f <= 400 ; ++f) {
		for (int u = 1; u <= 400 ; ++u) {
			sum[f][u] = (1ll * sum[f][u - 1] + cur[u])%MOD;
			cur[u] = (1ll * u * cur[u]) % MOD;
		}
	}
	printf("%d\n", calc(0,c));
	return 0;
}


Measured memory_bytes: 1536
#include <cstdio>
#include <queue>
using namespace std;

int main() {

    priority_queue<int> pq;
    priority_queue<int> pq2;
    int tmp, sum = 0;
    for (int i = 0; i < 10; i++) {
        std::scanf("%d", &tmp); pq.push(tmp);
    }
    for (int i = 0; i < 10; i++) {
        std::scanf("%d", &tmp); pq2.push(tmp);
    }
    for (int i = 0; i < 3; i++) {
        sum += pq.top(); pq.pop();
    }
    std::printf("%d ", sum); sum = 0;
    for (int i = 0; i < 3; i++) {
        sum += pq2.top(); pq2.pop();
    }
    std::printf("%d\n", sum); sum = 0;
    return 0;
}



Measured memory_bytes: 2788
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef pair<int,int> pi;
typedef long long int ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n,k;
    cin>>n>>k;
    int a[n][k],h[n],v[k];
    memset(h,0,sizeof(h));
    memset(v,0,sizeof(v));
    string s;
    for (int i=0;i<n;i++) {
        cin>>s;
        for (int j=0;j<k;j++) {
            a[i][j] = (s[j]=='.')?0:1;
            if (a[i][j]) h[i]++,v[j]++;
        }
    }
    for (int i=0;i<n;i++) {
        if (!h[i]) continue;
        for (int j=0;j<k;j++) {
            if (!v[j]) continue;
            if (a[i][j]) cout<<"#";
            else cout<<".";
        }
        cout<<"\n";
    }
}


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

using namespace std;

using ll= long long;

#define sz(x) (int)x.size()
#define all(x) (x).begin(),(x).end()
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void solve(){
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if(a>=k){
		cout<<k<<"\n";
	}else{
		cout<<a-(k-a-b)<<"\n";
	}
}

int32_t main(){
	IOS

	int t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}

/*
   check for overflows int long long
   correct size of array
*/

Measured memory_bytes: 3652
import java.util.*;
 
public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a=sc.nextDouble();
        double b=sc.nextDouble();
        double t=sc.nextDouble()+0.5;
        System.out.println((int)((int)(t/a)*b));
    }
}

Measured memory_bytes: 23124