akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

#include <atcoder/convolution>
#include <atcoder/dsu>
#include <atcoder/fenwicktree>
#include <atcoder/lazysegtree>
#include <atcoder/math>
#include <atcoder/maxflow>
#include <atcoder/mincostflow>
#include <atcoder/modint>
#include <atcoder/scc>
#include <atcoder/segtree>
#include <atcoder/string>
#include <atcoder/twosat>
using namespace atcoder;

int main(){
  int T;
  cin>>T;
  while(T--){
    ll N,M,A,B;
    cin>>N>>M>>A>>B;
    cout<<floor_sum(N, M, A, B)<<endl;
  }
}



Measured memory_bytes: 3512
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;

int main()
{
    fastio;
    int N, x;
    cin >> N >> x;
    vector<int> as;
    copy_n(istream_iterator<int>(cin), N, back_inserter(as));

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

    int total = 0;
    int count = 0;
    for (auto &&a : as)
    {
        total += a;
        if (total > x)
            break;
        count++;
        if (total == x)
            break;
    }
    if (total < x)
    {
        count--;
    }

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


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int H,W,i,j;
	while(1) {
		scanf("%d %d",&H,&W);
		if(H==0 && W==0) break;
		for (i=1; i<=H; i++) {
			for (j=1; j<=W; j++) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    bool ans=false;
    for(int i=1;i<10;i++){
        if(n%i==0&&n/i<10) ans=true;
    }
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main() {
	string s1,s2,s3;
	cin>>s1>>s2>>s3;
	
	cout<<s1[0]<<s2[0]<<s3[0];
	return 0;
}

Measured memory_bytes: 384
n = int(input())
h = list(map(int,input().split()))

dp = [float("inf")]*(n)
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2,n):
  temp_1 = abs(h[i] - h[i-1]) + dp[i-1]
  temp_2 = abs(h[i] - h[i-2]) + dp[i-2]
  if temp_1 < temp_2:
    dp[i] = temp_1
  elif temp_2 <= temp_1:
    dp[i] = temp_2
  
print(dp[n-1])

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

using namespace std;

int main() {
#ifdef  DEBUG
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
#endif  // for local.
  int a;
  int b, c;
  cin >> a;
  b = a / 100;
  c = a % 100;
  cout << (b * 5 >= c) << endl;
  return 0;
}

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

const int MAX_N = 100002;

int par[MAX_N];
int rank_[MAX_N];

void init(int n){
    for(int i = 0; i < n; i++){
        par[i] = i;
        rank_[i] = 0;
    }
}

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]) par[x] = y;
    else{
        par[y] = x;
        if(rank_[x] == rank_[y]) rank_[x]++;
    }
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    init(n);
    int ans = n;
    for(int i = 0; i < m; i++){
        int x, y, z;
        cin >> x >> y >> z;
        x--; y--;
        if(!same(x, y)){
            ans--;
            unite(x, y);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static int modulo = (int) Math.pow(10,9) + 7;
    public static int solve(int i,int j,int x,int y,char grid[][],int dp[][]){
        if(i > x || j > y) return 0;
        if(i == x && j == y) return 1;
        if(dp[i][j] != -1) return dp[i][j];
        if(grid[i][j] == '#'){
            return 0;
        }
        int ans = solve(i+1,j,x,y,grid,dp)%modulo + solve(i,j+1,x,y,grid,dp)%modulo;
        return dp[i][j] = ans%modulo;
    }

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int r,c;
        r = sc.nextInt();
        c = sc.nextInt();
        char grid[][] = new char[r][c];

        for(int i=0;i<r;i++){
                 grid[i] = sc.next().toCharArray();
        }

        int dp[][] = new int[r][c];
        for(int i=0;i<r;i++){
            for(int j=0;j<c;j++){
                dp[i][j] = -1;
            }
        }

        int ans = solve(0,0,r-1,c-1,grid,dp);
        System.out.println(ans);
    }
}


Measured memory_bytes: 39756
#include<stdio.h>
int main(void){
int N, dig, sum=0, NN;
scanf("%d", &N);
NN=N;
while(N){
    dig=N%10;
    sum+=dig;
    N/=10;
}
if(NN%sum==0) printf("Yes\n");
else printf("No\n");
return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    int N;
    int K;
    cin >> N >> K;
    int x =1;
    for (int i=0; i<N; i++){
        if(2 * x < x + K){
            x = 2*x;
        }
        else if(2 * x >= x + K){
            x += K;
        }
    }
    cout << x << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"

int main()
{
	string a, b = "";
	cin >> a >> b;
	string ans = "EQUAL";
	if (a.size() > b.size())
	{
		ans = "GREATER";
	}
	if (a.size() < b.size())
	{
		ans = "LESS";
	}
	else
	{
		for(int i = 0; i < min(a.size(), b.size()); i++)
		{
			if (a[i] > b[i])
			{
				ans = "GREATER";
				break;
			}
			else if (a[i] < b[i])
			{
				ans = "LESS";
				break;
			}
		}
	}

	COUT(ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
using namespace std;
int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b == c+d)
      cout << "Balanced\n";
    else
      if(a+b < c+d)
        cout << "Right\n";
      else
        cout << "Left\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<pair<string, int>> v(n);
    int S = 0;
    for (int i = 0; i < n; ++i) {
        cin >> v[i].first >> v[i].second;
        S += v[i].second;
    }
    string s;
    cin >> s;
    int val = 0;
    for (int i = 0; i < n; ++i) {
        if(v[i].first == s){
            cout << S - val - v[i].second << "\n";
            return 0;
        }
        val += v[i].second;
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [list(input().split()) for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    n=int(input())
    s=list(input())
    if len(set(s)) < 3:
      print(0)
      return 0
    from collections import Counter
    c=Counter(s)
    res=c['R']*c['G']*c['B']

    for j in range(1,n):
      for w in range(0,n+1):
        i=j-w
        k=j+w

        if i<0 or k>=n:
          continue
        if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:
          res-=1
    print(res)
    return 0

if __name__ == '__main__':
    main()



Measured memory_bytes: 74356
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    int ans = 0;
    while(1){
        bool pro = true;
        for(int i = 0; i < N; i++){
            if(A.at(i) % 2 == 0){
                A.at(i) /= 2;
            }
            else{
                pro = false;
            }
        }
        if(!pro){
            break;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3568
def main():
    a, b, k = map(int, input().split())

    if a + k - 1 < b - k + 1:
        for i in range(a, a + k):
            print(i)
        for i in range(b - k + 1, b + 1):
            print(i)
    else:
        for i in range(a, b + 1):
            print(i)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61980
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {

	int n, count = 0, power = 1, x; 

	scanf("%d", &n);

	while (power <= n) {
		power *= 2;
		count++;
	}
	
	printf("%d", power/2);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    int ans[n];
    int h[n];
    for(int i=0;i<n;i++)
        cin>>h[i];
    ans[0]=0;
    ans[1]=abs(h[1]-h[0]);

    for(int i=2;i<n;i++)
        ans[i]=min(ans[i-1]+abs(h[i]-h[i-1]),ans[i-2]+abs(h[i]-h[i-2]));
    
    cout<<ans[n-1];
}


Measured memory_bytes: 4384
n = int(input())
s = [[]]*n
for i in range(n):
    x, l = map(int,input().split())
    s[i] = [x-l, x+l]
s.sort(key = lambda x : x[1])

n = len(s)
cnt = 1

for i in range(1,n):
    if s[i-1][1] > s[i][0]:
        s[i][1] = s[i-1][1]
    else:
        cnt += 1

print(cnt)

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

int main()
{
    long long int a,b,c,d,ans;
    cin>>a>>b>>c>>d;
     long long int k[4];
     k[0]=a*c;
     k[1]=a*d;
     k[2]=b*c;
     k[3]=b*d;
    sort(k,k+4);
    cout<<k[3]<<endl;

    return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
const in mdl=1000000007LL;
in p2(in a){
  return (1LL<<a);
}
in pw(in a, in b, in lm=62){
  a%=mdl;
  if(a<0)
    a+=mdl;
  in r=1;
  for(in i=lm;i>=0;--i){
    r=r*r%mdl;
    if(b&p2(i))
      r=r*a%mdl;
  }
  return r;
}
in inv(in a){
  a%=mdl;
  if(a<0)
    a+=mdl;
  assert(a!=0);
  return pw(a,mdl-2,30);
}
VI fc,invfc;
in ncr(in a, in b){
  if(b==0 || b==a)
    return 1;//even if a<0
  if(b<0 || b>a)
    return 0;
  return fc[a]*invfc[b]%mdl*invfc[a-b]%mdl;
}
void inifc(){
  const in mxfc=30000;
  fc.resize(mxfc);
  invfc.resize(mxfc);
  fc[0]=fc[1]=invfc[0]=invfc[1]=1;
  for(in i=2;i<mxfc;++i){
    fc[i]=fc[i-1]*i%mdl;
    invfc[i]=invfc[mdl%i]*(mdl-mdl/i)%mdl;
  }
  for(in i=2;i<mxfc;++i){
    invfc[i]*=invfc[i-1];
    invfc[i]%=mdl;
  }
}

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,a,b,c;
  cin>>n>>a>>b>>c;
  inifc();
  if(b%2){
    cout<<0<<endl;
    return 0;
  }
  b/=2;
  in w=ncr(a+b,a);
  in tf=0;
  for(in ca=0;ca<=a;++ca){
    for(in cc=0;3*cc+ca<=c;++cc){
      if(b==0 && 3*cc+ca!=c)
	continue;
      tf+=ncr(a+b+cc,cc)*ncr(a,ca)%mdl*ncr(b-1+(c-(3*cc+ca)),b-1)%mdl;
    }
  }
  tf%=mdl;
  tf*=w;
  tf%=mdl;
  cout<<tf<<endl;
  return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int h = sc.nextInt();
			int w = sc.nextInt();
			for (int i = 0; i <= h - 1; i++) {
				String tmp = sc.next();
				for (int j = 0; j < 2; j++) {
					System.out.println(tmp);
				}
			}
		}
	}
}


Measured memory_bytes: 11296
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>

using namespace std;

int main() 
{
	int r, D, x2000;
	cin >> r >> D >> x2000;
	
	int x = x2000;
	for (int i = 0; i < 10; ++i){
		x = r * x - D;
		cout << x << endl;
	}
}

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long n; scan(n);
      LI xs(n); rep(i, n) scan(xs[i]);
      std::sort(xs.begin(), xs.end());
      long y = xs.front();
      long z = xs.back();
      dumpll(y, z);
      if( std::abs(z - y) > 1 ) {
         puts("No");
         return;
      }
      long left = 0, right = 0;
      rep(i, n) {
         if( xs[i] == y and y != z ) left += 1;
         else right += 1;
      }
      dumpll(left, right);
      bool res = false;
      if( y == z ) {
         if( right - 1 == z ) res = true;
         if( left + 1 <= z and z <= left + right / 2 ) res = true;
      }
      else {
         if( left <= y and y <= left - 1 + right / 2  and
             left + 1 <= z and z <= left + right / 2      ) res = true;
      }
      puts(res ? "Yes" : "No");
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 1024
#include <stdio.h>
int count;
void muki(int *gyo,int *retu,int top,int front1,int front2[6][6]){
	static int i = 6;
	if(count == 2){
		count = 0;
		i = 6;
	}
	*gyo = 0; *retu = 0;
	for(;i >= 4&&*gyo == 0&&*retu == 0;i--){
		if(front1 == i)
			*gyo = 1;
		else if(front1 == 7 - i)
			*gyo = -1;
		else if(front2[top - 1][front1 - 1] == i)
			*retu = 1;
		else if(front2[top - 1][front1 - 1] == 7 - i)
			*retu = -1;
	}
	count++;
}
int main(void){
	int i, j, k, n, retu, gyo, top, front1, x, y, tmp;
	int space[5][5], alltop[5][5];
	int front2[6][6] ={{0,3,5,2,4,0},{4,0,1,6,0,3},{2,6,0,0,1,5},{5,1,0,0,6,2},{3,0,6,1,0,4},{0,4,2,5,3,0}};
	scanf("%d",&n);
	while(n != 0){
		for(i = 0;i < 5;i++){
			for(j = 0;j < 5;j++){
				space[i][j] = 0;
				alltop[i][j] = 0;
			}
		}
		count = 0;
		for(i = 0;i < n;i++){
			y = x = 2;
			scanf("%d%d",&top,&front1);
			space[y][x]++;
			muki(&gyo,&retu,top,front1,front2);
			if(space[y + gyo][x + retu] >= space[y][x] - 1)
				muki(&gyo,&retu,top,front1,front2);
			else
				count++;
			while(space[y + gyo][x + retu] < space[y][x] - 1){
				space[y][x]--; space[y + gyo][x + retu]++;
				x += retu; y += gyo;
				if(gyo == -1){				/* サイコロの状態を変える */
					tmp = top;
					top = front1;
					front1 = 7 - tmp;
				}
				else if(gyo == 1){
					tmp = front1;
					front1 = top;
					top = 7 - tmp;
				}
				else if(retu == 1)
					top = 7 - front2[top - 1][front1 - 1];
				else if(retu == -1)
					top = front2[top - 1][front1 - 1];
				muki(&gyo,&retu,top,front1,front2);
				if(space[y + gyo][x + retu] >= space[y][x] - 1)
					muki(&gyo,&retu,top,front1,front2);
				else
					count++;
			}
			alltop[y][x] = top;
		}
		for(i = 1;i <= 6;i++){
			count = 0;
			for(j = 0;j < 5;j++){
				for(k = 0;k < 5;k++){
					if(alltop[j][k] == i)
						count++;
				}
			}
			if(i < 6)
				printf("%d ",count);
			else
				printf("%d\n",count);
		}
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1028
import java.util.Scanner;

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

    int N = scanner.nextInt();
    long[][] freq = new long[9][9];
    for (int i = 1; i <= N; i++) {
      int h = highest(i) - 1;
      int l = lowest(i) - 1;
      if (l < 0) continue;
      freq[h][l]++;
    }
    long res = 0;
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        res += freq[i][j] * freq[j][i];
      }
    }
    System.out.println(res);
  }

  private static int highest(int n) {
    int d = 0;
    while (n > 0) {
      d = n % 10;
      n /= 10;
    }
    return d;
  }

  private static int lowest(int n) {
    return n % 10;
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
typedef long long lint;
const int N=131080;
int n;
class pair{
	public:
		lint x,y;
		friend bool operator < (const pair &a,const pair &b);
};

bool operator < (const pair &a,const pair &b){
	return a.x==b.x?a.y<b.y:a.x<b.x;
}

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

inline int x_bound(std::vector <pair> &vt,const lint _lim){
	int l=0,r=vt.size()-1,mid;
	while(l!=r){
		mid=(l+r+1)>>1;
		if(vt[mid].x>_lim) r=mid-1;
		else l=mid;
	}
	return l;
}

inline int y_bound(std::vector <pair> &vt,const lint _lim){
	int l=0,r=vt.size()-1,mid;
	while(l!=r){
		mid=(l+r)>>1;
		if(vt[mid].y>_lim) l=mid+1;
		else r=mid;
	}
	return l;
}

inline void sanitize_seq(std::vector <pair> &vt){
	const int sz=vt.size();
	int p1=1,p2=1;
	for(; p1<sz; ++p1){
		if(vt[p1].x!=vt[p1-1].x) vt[p2++]=vt[p1];
	}
	while((int)vt.size()>p2) vt.pop_back();
}

namespace G{
	int cnt,nxt[N][2],wt[N][2];
	lint lim_w;
	std::vector <pair> vt[N];

	inline void add(const int a,const int b,const int v){
		bool f=nxt[a][0]>0;
		nxt[a][f]=b,wt[a][f]=v;
	}

	void dfs(const int x){
		if(!nxt[x][0]){
			vt[x].push_back((pair){0,0});
			return;
		}
		dfs(nxt[x][0]);
		dfs(nxt[x][1]);
		if(vt[nxt[x][0]].size()>vt[nxt[x][1]].size()){
			std::swap(nxt[x][0],nxt[x][1]);
			std::swap(wt[x][0],wt[x][1]);
		}

		const int c0=nxt[x][0],c1=nxt[x][1];
		const lint v0=wt[x][0],v1=wt[x][1];
		const int lim_l=vt[c0].size();

		for(int i=0,j,lst_j=-1; i<lim_l; ++i){
			const lint _lim=lim_w-vt[c0][i].y-v0-v1;
			j=x_bound(vt[c1],_lim);
			if(vt[c1][j].x>_lim) continue;
			if(j!=lst_j){
				lst_j=j;
				vt[x].push_back((pair){vt[c0][i].x+v0,vt[c1][j].y+v1});
			}
		}
		for(int i=lim_l-1,j,lst_j=-1; i>=0; --i){
			const lint _lim=lim_w-vt[c0][i].x-v0-v1;
			j=y_bound(vt[c1],_lim);
			if(vt[c1][j].y>_lim) continue;
			if(j!=lst_j){
				lst_j=j;
				vt[x].push_back((pair){vt[c1][j].x+v1,vt[c0][i].y+v0});
			}
		}
		std::sort(vt[x].begin(),vt[x].end());
		sanitize_seq(vt[x]);
	}

	bool jdg(const lint tgt){
		lim_w=tgt;
		for(int i=1; i<=n; ++i){
			vt[i].clear();
		}
		dfs(1);
		return !vt[1].empty();
	}
}

inline lint solve(){
	lint l=0,r=2e10,mid;
	while(l!=r){
		mid=(l+r)>>1;
		if(G::jdg(mid)) r=mid;
		else l=mid+1;
	}
	return l;
}

int main(){
	n=nxi();
	for(int i=2; i<=n; ++i){
		int fr=nxi();
		G::add(fr,i,nxi());
	}
	printf("%lld\n",solve());
	return 0;
}

Measured memory_bytes: 27892
#include<stdio.h>
#include<math.h>
#define DEBT 100000
int main(){
int n,i;
double x=DEBT;
int y;

scanf("%d",&n);

for(i=0;i<n;i++){
  x=x*1.05;
  x=x/1000;
  x=ceil(x);
  y=x;
  y=y*1000;
  x=y;}




printf("%d\n",y);

return 0;
}

Measured memory_bytes: 1740
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
int main()
{

    int i,n,k,c=0;
    cin>>n>>k;
    int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
        if(a[i]>=k)
            c++;
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 3948
program main
   implicit none
   integer n,i,j
   real:: t,a,d=10000,re
   real,allocatable,dimension(:)::h
   reaD(*,*)n,t,a
   allocate(h(1:n))
   read(*,*)h(1:n)
   do i=1,n
      re=t-h(i)*0.006
      if(abs(re-a)<d)then
        d=abs(re-a)
        j=i
      endif
   enddo
   write(*,*)j
end program main


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

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

#define INF 10000000
#define MOD 998244353
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

int main(){
  int N;
  cin>>N;
  vector<int>p(N);
  for(int i=0;i<N;i++)cin>>p[i];
  int ans=0;
  for(int i=1;i<N;i++){
    if(p[i-1]==i-1+1&&p[i]==i+1){
      swap(p[i-1],p[i]);
      ans++;
    }
  }
  for(int i=0;i<N;i++)if(p[i]==i+1)ans++;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=300+50;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int n,m,maxd,f[N][N],g[N][N];

namespace My_Math{
    #define N 100000

    int fac[N+100],invfac[N+100];

    int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
    int dec(int x,int y) {return x<y?x-y+maxd:x-y;}
    int mul(int x,int y) {return 1ll*x*y%maxd;}
    ll qpow(ll x,int y)
    {
        ll ans=1;
        while (y)
        {
            if (y&1) ans=mul(ans,x);
            x=mul(x,x);y>>=1;
        }
        return ans;
    }
    int getinv(int x) {return qpow(x,maxd-2);}

    int C(int n,int m)
    {
        if ((n<m) || (n<0) || (m<0)) return 0;
        return mul(mul(fac[n],invfac[m]),invfac[n-m]);
    }

    void math_init()
    {
        fac[0]=invfac[0]=1;
        rep(i,1,N) fac[i]=mul(fac[i-1],i);
        invfac[N]=getinv(fac[N]);
        per(i,N-1,1) invfac[i]=mul(invfac[i+1],i+1);
    }
    #undef N
}
using namespace My_Math;

int main()
{
    n=read();m=read();maxd=read();
    f[0][0]=1;g[0][0]=1;
    rep(i,0,n) rep(j,0,n)
    {
        if (i) g[i][j]=add(g[i][j],g[i-1][j]);
        if (j) g[i][j]=add(g[i][j],mul(i+1,g[i][j-1]));
    }
    rep(i,1,m) rep(j,0,n) rep(k,0,j)
    {
        f[i][j]=add(f[i][j],mul(f[i-1][j-k],g[j-k][k]));
    }
    printf("%d",f[m][n]);
    return 0;
}



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

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

int main(void) {
    const int INF = 1e9;
    int n, m, a[50], b[50], c[50], d[50], min_dist, ans;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    REP(i, n) {
        cin >> a[i] >> b[i];
    }
    REP(i, m) {
        cin >> c[i] >> d[i];
    }

    REP(i, n) {
        min_dist = INF;
        REP(j, m) {
            if (min_dist > abs(a[i] - c[j]) + abs(b[i] - d[j])) {
                ans = j + 1;
                min_dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            }
        }

        cout << ans << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 998244353
eps = 10**-7


def inp(): return int(sys.stdin.readline())


def inpl(): return list(map(int, sys.stdin.readline().split()))


def inpl_str(): return list(sys.stdin.readline().split())


N, S = inpl()
aa = inpl()

dp = [0 for _ in range(3010)]
dp[0] = 0

ans = 0
for i, a in enumerate(aa):

    if S == a:
        ans += (i+1) * (N-i) % mod
    else:
        ans += dp[S-a] * (N-i) % mod
    ans %= mod

    for s in reversed(range(a, S)):
        if s == a:
            dp[s] += i+1
        else:
            dp[s] += dp[s-a]
        dp[s] %= mod


print(ans)


Measured memory_bytes: 45160
import java.util.*;

public class Main{
	Scanner sc = new Scanner(System.in);
	int [][] data = {
			{0,300,500,600, 700, 1350, 1650},
			{6,0,350,450,600,1150,1500},
			{13,7,0,250,400,1000,1350},
			{18,12,5,0,250,850,1300},
			{23,17,10,5,0,600,1150},
			{43,37,30,25,20,0,500},
			{58,52,45,40,35,15,0},
	};
	
	private void doit(){
		while(true){
			int a = sc.nextInt() - 1;
			if(a == -1) break;
			int timeA = sc.nextInt() * 100 + sc.nextInt();
			int b = sc.nextInt() - 1;
			int timeB = sc.nextInt() * 100 + sc.nextInt();
			boolean ishalf = isOK(timeA) || isOK(timeB);
			int min = Math.min(a, b);
			int max = Math.max(a, b);
			if(data[max][min] > 40 ){
				ishalf = false;
			}
			if(ishalf){
				int res = data[min][max];
				if(data[min][max] % 100 != 0){
					res += 50;
				}
				System.out.println(res / 2);
			}
			else{
				System.out.println(data[min][max]);
			}
		}
	}
	
	private boolean isOK(int timeA) {
		if(1730 <= timeA && timeA <= 1930){
			return true;
		}
		return false;
	}

	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

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

Measured memory_bytes: 20456
#include <stdio.h>

int gcd(int a, int b) {
   int r;
   if(a >= b){
      do{
       r=a%b;
       a=b;
       b=r;
   }while(r != 0);
   
   return a;
   }
   else if(a < b){
      do{
       r=b%a;
       b=a;
       a=r;
   }while(r != 0);
   
   return b;
   }
}

   int main(void){
   int a,b;
   while(scanf("%d %d",&a,&b) != EOF) {
      int lcm = a/gcd(a,b)*b;
     
      printf("%d %d\n",gcd(a,b),lcm);
   }
   return 0;
}



Measured memory_bytes: 2032
import java.util.Scanner;

public class Main {
    static Scanner sc  = new Scanner(System.in);

    public static void main(String[] args) {
        String s = sc.next();
        if(s.equals("hi") || s.equals("hihi") || s.equals("hihihi") || s.equals("hihihihi") || s.equals("hihihihihi")){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
        
    }
}

Measured memory_bytes: 23764
import Foundation
 
let a=Int(readLine()!)!
var array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
]
print(array[a-1]) //5

Measured memory_bytes: 6632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int n;
string s;

bool exist(int x) {
    string str = to_string(x);
    if (x <= 9) str = "00" + str;
    else if (x <= 99) str = "0" + str;
    rep(i, 0, n) {
        if (s[i] == str[0]) {
            rep(j, i + 1, n) {
                if (s[j] == str[1]) {
                    rep(k, j + 1, n) {
                        if (s[k] == str[2]) {
                            return true;
                        }
                    }
                    return false;
                }
            }
            return false;
        }
    }
    return false;
}

int main() {
    cin >> n;
    cin >> s;
    int ans = 0;
    for (int i = 0; i <= 999; i++) {
        if (exist(i) == true) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
s = "".join(list(reversed(input())))
n = len(s)

ans = 0
for i in range(1, n):
    if (n - i) % 2 == 0:
        now = s[i:]
        if now[(n-i)//2:] == now[:(n-i)//2]:
            ans = n - i
            break
print(ans)



Measured memory_bytes: 2940
def main():
    n = int(input())
    a = set([int(a) for a in input().split()])
    m = int(input())
    b = set([int(a) for a in input().split()])

    c = a.intersection(b)
    sorted_c = sorted(c)
    for i in sorted_c:
        print(i)
main()



Measured memory_bytes: 44900
import sys

n, y = map(int, input().split())

for i in range(n+1):
  for j in range(n+1):
    k = n - i - j
    if k < 0:
      break
    t = i * 10000 + j * 5000 + k * 1000
    if t == y:
      print('{} {} {}'.format(i, j, k))
      sys.exit()
print('-1 -1 -1');


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
using namespace std;
int k,l;
vector<string> v;
string s,a;
int main(){
	cin>>a>>k;
	l=a.size();
	for(int i=0;i<l;i++)
	{
		s="";
		for(int j=i;j<l;j++)
		{
			if(s.size()>5)
				break;
			s+=a[j];
			v.push_back(s); 
		}
	}
	sort(v.begin(),v.end());
	int i=0;
	while(i<k)
	{
		if(i==k-1)
			break;
		if(v[i]<v[i+1])
			i++;
		else
			i++,k++;
	}
	cout<<v[i];
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
    int n, x;
    cin >> n >> x;
    V<int> a(n);
    rep(i,n) cin >> a[i];
    int idx = -1;
    Rep(i,n-1) {
        if(a[i] + a[i-1] >= x) idx = i;
    }
    if(idx == -1) 
        cout << "Impossible" << endl;
    else {
        cout << "Possible" << endl;
        for(int i = 1; i < idx; i++) cout << i << endl;
        for(int i = n-1; i > idx; i--) cout << i << endl;
        cout << idx << endl;
    }
}

Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, ll> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;

const char c[4] = {'L', 'R', 'U', 'D'};
// 手番, 文字, 変化量 (left, right, up, down)
// 手番 : (0, 1) = (先手, 後手)
const int delta[2][4][4]
    = {{{1,0,0,0},{0,-1,0,0},{0,0,1,0},{0,0,0,-1}},
       {{0,1,0,0},{-1,0,0,0},{0,0,0,1},{0,0,-1,0}}};

int get_id(char ch){
    for(int i = 0; i < 4; ++i){
        if(ch == c[i])  return i;
    }
    return -1;
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int h, w, n, sx, sy;
    string s, t;
    cin >> h >> w >> n >> sx >> sy >> s >> t;
    --sx, --sy;
    int left = 0, right = w, up = 0, down = h;
    for(int i = n-1; i >= 0; --i){
        int dir = get_id(t[i]);
        int t_left = left + delta[1][dir][0];
        int t_right = right + delta[1][dir][1];
        int t_up = up + delta[1][dir][2];
        int t_down = down + delta[1][dir][3];

        // 変化させずに先手の手番
        if(t_left < 0 || t_right > w || t_up < 0 || t_down > h) ;
        // 変化させてから先手の手番
        else{
            left = t_left, right = t_right, up = t_up, down = t_down;
        }

        dir = get_id(s[i]);
        t_left = left + delta[0][dir][0];
        t_right = right + delta[0][dir][1];
        t_up = up + delta[0][dir][2];
        t_down = down + delta[0][dir][3];

        if(t_left >= t_right || t_up >= t_down){
            cout << "NO\n";
            return 0;
        }
        left = t_left, right = t_right, up = t_up, down = t_down;
    }

    if(sy < left || sy >= right || sx < up || sx >= down){
        cout << "NO\n";
    }
    else{
        cout << "YES\n";
    }
}

Measured memory_bytes: 920
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B;
    cin >>A>>B;
    if(A==B){
        cout<<"Draw"<<endl;
    }else if(A>B){
        if(B==1){
            cout<<"Bob"<<endl;
        }else{
            cout<<"Alice"<<endl;
        }
    }else{
        if(A==1){
            cout<<"Alice"<<endl;
        }else{
            cout<<"Bob"<<endl;
        }
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value > obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value < obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  cin >> N;
  ll x, y, h;
  vector<HOGE<pair<ll, ll>, ll>> Inform(N);
  REP(i, N){
    cin >> x >> y >> h;
    pair<ll, ll> tmp1(x, y);
    HOGE<pair<ll, ll>, ll> tmp2(tmp1, h);
    Inform[i] = tmp2;
  }

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

  FOR(X, 0, 101){
    FOR(Y, 0, 101){
      ll x = Inform[0].key.first;
      ll y = Inform[0].key.second;
      ll h = Inform[0].value;
      ll H_tmp = h + abs(X-x) + abs(Y-y);
      if(H_tmp<1) continue;
      bool flag=true;
      FOR(i, 1, N){
        x = Inform[i].key.first;
        y = Inform[i].key.second;
        h = Inform[i].value;
        if(max(H_tmp -  abs(X-x) - abs(Y-y), (ll)0) != h){
          flag=false;
          break;
        }
      }
      if(flag){
        cout << X << " " << Y << " " << H_tmp << "\n";
        return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
   int n, ret;
   while(cin >> n && n > 0){
	    vector<int> v;
	    int sum = 0;
	    for(int i = 0; i < n; i++){
		   int x;
		   cin >> x;
     	   v.push_back(x);	
     	   sum += x;
	     }
	    ret = 0;
	    for(auto it : v)
	      if (it * n <= sum) ret++; 
	    cout << ret << endl;	
	  }	
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;

typedef long long ll;
const int INF = 1e8;
// const ll INF = 1LL << 60;
typedef pair<int, int> P;

ll N, M;
int main() {
    cin >> N >> M;
    if (N == 1 && M == 1) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    if (N >= 2) {
        ans += N * (N - 1) / 2;
    }
    if (M >= 2) {
        ans += M * (M - 1) / 2;
    }
    cout << ans << endl;
}

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

int main()
{
  long long int n,k;
  cin >> n >> k;
  for(long long int i=k+1-n;i<k+n;i++)
  {
    if(i>=-1000000 && i<=1000000)
    {
      cout << i << " ";
    }
  }
}

Measured memory_bytes: 256
import java.util.ArrayList;
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();
		ArrayList<List<Integer>> A = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			ArrayList<Integer> B = new ArrayList<>();
			A.add(B);
		}
		int q = sc.nextInt();

		for (int i = 0; i < q; i++) {
			int x = sc.nextInt();
			if (x == 0) {
				int y = sc.nextInt();
				int z = sc.nextInt();
				A.get(y).add(z);

			} else if (x == 1) {
				int y = sc.nextInt();
				for (int j = 0; j < A.get(y).size(); j++) {
					System.out.print(A.get(y).get(j));
                    if(j!=A.get(y).size()-1)System.out.print(" ");

				}
                System.out.println();

			} else if (x == 2) {
				int y = sc.nextInt();
				A.get(y).clear();
			}
		}
		sc.close();

	}

}



Measured memory_bytes: 309912
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cmath>
#include<cstring>
using namespace std;

int main(){
  double n,temp;

  while(1){
    scanf("%lf",&n);
    if(n<0) break;

    if((int)(n*10000)%625!=0) printf("NA\n");
    else{
      for(int i=7;i>=-4;i--){
	temp=pow(2,(double)i);
	if(n>=temp){
	  n-=temp;
	  printf("1");
	}else{
	  printf("0");
	}
	if(i==0) printf(".");
      }
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 3364
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main()
{
	int n;
	cin>>n;
	vector<int> height(n);
	for(int i =0; i < n; i++){
		cin>>height[i];
	}
	ll ans = 0;
	for(int i = 1; i < n; i ++){
		int offset = max(0, height[i-1] - height[i]);
		ans += offset;
		height[i] += offset;
		//cout<<offset<<endl;
	}
	cout<<ans<<endl;
	return 0;
}



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

int main()
{
  int A, B, X;
  cin >> A >> B >> X;
  if (X - A < 0)
    cout << "NO" << endl;
  else if (X - A <= B)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define pi pair<int,int>
#define vi vector<int>
#define pL pair<ll,ll>
#define vL vector<ll>
#define vp vector<pi>
#define vpL vector<pL>

const int MX=300000;

int main()
{
    FasterIO;

    int n, m, k;
    string A, B, C;
    cin>>A;
    for(int i=0; i<A.size(); i++) A[i]='x';
    cout<<A<<endl;
    return 0;
}


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

int main(){

    int n,x,square=0;
    cin>>n;
    for (int i = 0; i < n; i++){
        cin >>x;
        if ( (i+1)%2 == 1 && x%2 == 1 )
            square++;
    }
    cout << square <<endl;


}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto& e : a) {
    cin >> e;
  }
  vector<pair<int, int>> u, v;
  for (int i = 0; i < n; i++) {
    v.push_back({a[i], i + 1});
  }
  vector<int> r;
  int c = 0;
  sort(rbegin(v), rend(v));
  r.push_back(v.front().second);
  v.front().first--;
  while (c < k + 1) {
    int t = r.back();
    sort(rbegin(v), rend(v));
    bool ng = false;
    for (auto& e : v) {
      if (e.second == t) continue;
      r.push_back(e.second);
      e.first--;
      ng |= e.first < 0;
    }
    if (ng) break;
    c++;
  }
  if (c == k + 1) {
    cout << r.size() << endl;
    for (auto e : r) {
      cout << e << " ";
    }
    cout << endl;
  } else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<utility>
#include<set>
#include<vector>
#define REP(i,n) for(int i = 0;i < n;i++)
#define mp make_pair
#define FI first
#define SE second
using namespace std;

typedef pair<int,int> ip;
typedef pair<int,ip> iip;
typedef vector<iip> iipv;

int dx[] = {-1,0,1,0},dy[]= {0,-1,0,1};
int n;
int a,b;
int xma,xmi,yma,ymi;

int main()
{
	for(;;)
	{
		cin >> n;
		if(n == 0)break;
		xma = yma = 0;
		xmi = ymi = 1e5;
		iipv p;
		p.push_back(mp(0,mp(0,0)));
		REP(i,n-1)
		{
			cin >> a >> b;
			p.push_back(mp(i+1,mp(p[a].SE.FI+dx[b],p[a].SE.SE+dy[b])));
		}
		
		//REP(i,n)
		//cout << p[i].FI << ' ' << p[i].SE.FI <<  ' ' << p[i].SE.SE << endl;
		
		REP(i,n)
		{
			xma = max(xma,p[i].SE.FI);
			xmi = min(xmi,p[i].SE.FI);
			yma = max(yma,p[i].SE.SE);
			ymi = min(ymi,p[i].SE.SE);
		}
		
		cout << xma - xmi + 1 << ' ' << yma - ymi + 1 << endl;
	}
	
	return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld PI = acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
//const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    int n; cin >> n;
    int cnt = 0;
    vii p(10, vi(10));
    string s;
    for(int i = 1; i <= n; ++i) {
        s = to_string(i);
        int x = s[0]-'0';
        int y = s[s.size()-1]-'0';
        p[x][y]++;
    }
    rep(i,10) {
        rep(j,10) {
            cnt += p[i][j] * p[j][i];
        }
    }
    cout << cnt << '\n';
}

Measured memory_bytes: 256
N =int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans_max = sum(A)

for i in range(N+1):
    if i == 0:
        if B[i] <= A[i]:
            A[i] -= B[i]
            B[i] = 0
        elif B[i] > A[i]:
            B[i] -= A[i]
            A[i] = 0
            
    
    elif i == N:
        if B[i-1] <= A[i]:
            A[i] -= B[i-1]
            B[i-1] = 0
        elif B[i-1] > A[i]:
            B[i-1] -= A[i]
            A[i] = 0
            

    else:
        if B[i-1] <= A[i]:
            A[i] -= B[i-1]
            B[i-1] = 0
        elif B[i-1] > A[i]:
            B[i-1] -= A[i]
            A[i] = 0
            
        
        if B[i] <= A[i]:
            A[i] -= B[i]
            B[i] = 0
        elif B[i] > A[i]:
            B[i] -= A[i]
            A[i] = 0

ans_min = sum(A)

ans = ans_max - ans_min

print(ans)

Measured memory_bytes: 18476
# coding: utf-8
# Your code here!

s = list(input())
c = 0
n = [] 
ans = [] 
for i in range(len(s)):
    if s[i] == "," or s[i] == "." or s[i] == " ":
        if c >= 3 and c <= 6:
            ans = ans + n + [" "] 
        n.clear()
        c = 0
    else:
        n.append(s[i])
        c += 1

del ans[-1] 
for i in range(len(ans)):
   print(ans[i], end = "")
print("")


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	long long int n, k, q;
	long long int sanka[100001] = {};
	cin >> n >> k >> q;
	long long int a;
	for (long long int i = 0; i < q; ++i)
	{
		cin >> a;
		++sanka[a];
	}
	for (long long int i = 1; i <= n; ++i)
	{
		cout << (sanka[i] - q + k > 0 ? "Yes" : "No") << endl;
	}
	return 0;
}

Measured memory_bytes: 1408