akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
  int score[2][5]= {{0},{0}}, i, j;

  for(i = 0; i < 2;i++){
    for(j = 0; j < 4;j++){
      scanf("%d", &score[i][j]);
      score[i][4] += score[i][j];
    }
  }

  if(score[0][4] > score[1][4])
    printf("%d\n", score[0][4]);
  else
    printf("%d\n", score[1][4]);

  return 0;
}

Measured memory_bytes: 592
/*
  文字列変換(文字列strに対して、与えられた命令の列を実行するプログラム)
  2018/03/05
*/

#include<stdio.h>
#include<string.h>

/*strのa文字目からb文字目までを出力する*/
void print(char *s,int a,int b)
{
  while(a<=b){
    printf("%c",s[a]);
    a++;
  }
  printf("\n");
  return;
}

/*strのa文字目からb文字目までを逆順にする*/
void reverse(char *s,int right,int left){
  char temp;
  while(right <= left){
    temp = s[right];
    s[right] = s[left];
    s[left] = temp;
    right++;
    left--;
  }
  return;
}
/*strのa文字目からb文字目までをpに置き換える*/
void replace(char *s,int a,int b)
{
  int n = b-a+1;
  char p[1000] = {'\0'};
  int i;
  scanf(" %s",p);
  for(i=0;i<n;i++){
    s[a] = p[i];
    a++;
  }
  return;
}

int main(void)
{
  char str[1001]={'\0'};
  char order[9] = {'\0'};
  int q;/*命令数*/
  int a,b;/*strのa文字目からb文字目(0<=a<=b<1000)*/
  int i;
  
  scanf("%s",str);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%s %d %d",order,&a,&b);
    if(strcmp(order,"print") == 0)
      print(str,a,b);
    if(strcmp(order,"reverse") == 0)
      reverse(str,a,b);
    if(strcmp(order,"replace") == 0)
      replace(str,a,b);
  }
  return 0;
}


Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while (true) {
        String x = scan.nextLine();
            if (x.equals("0")) break;
            int sum = 0;
            for (int i = 0; i < x.length(); i++) {
                sum += x.charAt(i) - '0';
            }
            System.out.println(sum);
        }
    }
}

Measured memory_bytes: 26732
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // int n = Integer.parseInt(sc.next());
        // int m = Integer.parseInt(sc.next());
        String s = sc.next();
        int n = s.length();
        // int[] s = new int[n];

        // for (int i = 0; i < n; i++) {
        // s[i] = Integer.parseInt(sc.next());

        // }
        boolean flag = true;

        for (int i = 0; i < n; i++) {
            if (s.charAt(i) != s.charAt(n - 1 - i)) {
                flag = false;
                break;
            }
        }

        int m = (n - 1) / 2;
        for (int i = 0; i < m; i++) {
            if (s.charAt(i) != s.charAt(m - 1 - i)) {
                flag = false;
                break;
            }
        }

        if (flag) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

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

#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rrep(i,m,n) for(int i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]); if(i!=n-1) cout << " ";} cout << endl;
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll H,W;
string S[410];
ll checked[410][410] = {};
ll parent[200010];

ll root(ll x){
    if(x == parent[x]){
        return x;
    }else{
        return parent[x] = root(parent[x]);
    }
}

void unite(ll a, ll b){
    a = root(a);
    b = root(b);
    if(a == b){
        return;
    }
    parent[a] = b;
}

bool same(ll a, ll b){
    return root(a) == root(b);
}
ll cc(ll h, ll w){
    return w + h*W;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W;
    rep(i,0,H){
        cin >> S[i];
    }
    rep(i,0,H){
        rep(j,0,W){
            parent[cc(i,j)] = cc(i,j);
        }
    }
    rep(i,0,H){
        rep(j,0,W){
            if(S[i][j] == '.'){
                if(i != 0){
                    if(S[i-1][j] == '#') unite(cc(i,j), cc(i-1,j));
                }
                if(i != H-1){
                    if(S[i+1][j] == '#') unite(cc(i,j), cc(i+1,j));
                }
                if(j != 0){
                    if(S[i][j-1] == '#') unite(cc(i,j), cc(i,j-1));
                }
                if(j != W-1){
                    if(S[i][j+1] == '#') unite(cc(i,j), cc(i,j+1));
                }
            }else{
                if(i != 0){
                    if(S[i-1][j] == '.') unite(cc(i,j), cc(i-1,j));
                }
                if(i != H-1){
                    if(S[i+1][j] == '.') unite(cc(i,j), cc(i+1,j));
                }
                if(j != 0){
                    if(S[i][j-1] == '.') unite(cc(i,j), cc(i,j-1));
                }
                if(j != W-1){
                    if(S[i][j+1] == '.') unite(cc(i,j), cc(i,j+1));
                }
            }
        }
    }
    map<ll,ll> mp1, mp2;
    rep(i,0,H){
        rep(j,0,W){
            ll roots = root(cc(i,j));
            if(S[i][j] == '#'){
                mp1[roots]++;
            }else{
                mp2[roots]++;
            }
        }
    }
    ll ans = 0;
    for(auto &e: mp1){
        ll pos = e.first;
        ll val = e.second;
        ans += val * mp2[pos];
    }
    print(ans);
}


Measured memory_bytes: 18944
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static long INF64 = 1 << 60;
    public static void main(String[] args) {
        int h = Integer.parseInt(sc.next());
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        int[] b = new int[n];
        int aMax = 0;
        for(int i = 0; i < n; ++i) {
            a[i] = Integer.parseInt(sc.next());
            b[i] = Integer.parseInt(sc.next());
            aMax = Math.max(aMax, a[i]);
        }
        
        long[] dp = new long[h + aMax];
        Arrays.fill(dp, 1, h + aMax, INF64);
        for(int i = 1; i < h + aMax; ++i) {
            for(int j = 0; j < n; ++j) {
                int hpIndex = Math.max(0, i - a[j]);
                dp[i] = Math.min(dp[hpIndex] + b[j], dp[i]);
            }
        }
        
        long ans = INF64;
        for(int i = h; i < h + aMax; ++i) {
            ans = Math.min(ans, dp[i]);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 26808
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int t[n],x[n],y[n];
  for(int i=0;i<n;i++){
    cin >> t[i] >> x[i] >> y[i];
  }
  for(int i=0;i<n;i++){
    if(i==0){
      if(abs(x[i])+abs(y[i])>t[i]||(abs(x[i])+abs(y[i]))%2!=(t[i])%2){
        cout << "No" << endl;
        return 0;
      }
    }else{
      if((abs(x[i])-abs(x[i-1])+abs(y[i])-abs(y[i-1])>(t[i]-t[i-1]))||(abs(x[i]-x[i-1]+y[i]-y[i-1])%2!=(t[i]-t[i-1])%2)){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

using namespace std;

using int64 = long long;


bool check(vector< int > &vs, int p, bool f)
{
  bitset< 16001 > bit;
  const int S = 8000;
  bit[S] = 1;

  for(int i = 0; i < vs.size(); i++) {
    if(f == false && i == 0) bit = bit << vs[i];
    else bit = (bit << vs[i]) | (bit >> vs[i]);
  }
  return (bit[p + S]);
}

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

  vector< int > vs;
  vs.push_back(0);
  for(auto &c : S) {
    if(c == 'F') {
      vs.back()++;
    } else {
      vs.push_back(0);
    }
  }
  int x, y;
  cin >> x >> y;

  vector< int > latte, malta;
  for(int i = 0; i < vs.size(); i++) {
    if(i % 2 == 0) latte.emplace_back(vs[i]);
    else malta.emplace_back(vs[i]);
  }
  if(check(latte, x, false) && check(malta, y, true)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 384
import sys

N = int(sys.stdin.readline())
Hs = sys.stdin.readline().strip().split()
Hs = [int(h) for h in Hs]
curr_max = 0
count = 0 
for i in range(len(Hs) - 1):
    if Hs[i + 1] <= Hs[i]:
        count += 1
    else:
        curr_max = max(curr_max, count)
        count = 0
else:
    curr_max = max(curr_max, count)
print(curr_max)

Measured memory_bytes: 14252
main = do
  w <-  getLine
  putStrLn $ ans $ last w

ans n 
 | n == '0' = "pon"
 | n == '1' = "pon"
 | n == '2' = "hon"
 | n == '3' = "bon"
 | n == '4' = "hon"
 | n == '5' = "hon"
 | n == '6' = "pon"
 | n == '7' = "hon"
 | n == '8' = "pon"
 | n == '9' = "hon"

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

int main(){

  string w;
  cin >> w;
  string words = "abcdefghijklmnopqrstuvwxyz";
  vector<int> vec(26,0);
  vector<int> vecc(26,0);
  
  for(int i=0; i<w.size(); i++){
  	for(int j=0; j<26; j++){
    	if(w.at(i) == words.at(j)){
        	vec.at(j) +=1;
        }
    }     
  }
  
    if(((vec.at(0) % 2) == 0) && ((vec.at(1) % 2) == 0) && ((vec.at(2) % 2) == 0) && ((vec.at(3) % 2) == 0) && ((vec.at(4) % 2) == 0) && ((vec.at(5) % 2) == 0) && ((vec.at(6) % 2) == 0) && ((vec.at(7) % 2) == 0) && ((vec.at(8) % 2) == 0) && ((vec.at(9) % 2) == 0) && ((vec.at(10) % 2) == 0) && ((vec.at(11) % 2) == 0) && ((vec.at(12) % 2) == 0) && ((vec.at(13) % 2) == 0) && ((vec.at(14) % 2) == 0) && ((vec.at(15) % 2) == 0) && ((vec.at(16) % 2) == 0) && ((vec.at(17) % 2) == 0) && ((vec.at(18) % 2) == 0) && ((vec.at(19) % 2) == 0) && ((vec.at(20) % 2) == 0) && ((vec.at(21) % 2) == 0) && ((vec.at(22) % 2) == 0) && ((vec.at(23) % 2) == 0) && ((vec.at(24) % 2) == 0) && ((vec.at(25) % 2) == 0) ){
      cout << "Yes" << endl;
 }
  else {
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9000000000000000000;
const double PI = acos(-1);

int a[100100];
int dp[100100];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	fill(dp, dp + n, INF);
	for (int i = 0; i < n; i++) {
		*lower_bound(dp, dp + n, a[i]) = a[i];
	}
	cout << lower_bound(dp, dp + n, INF) - dp << endl;
}

Measured memory_bytes: 3852
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

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

int x , y ;

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

	cin >> x >> y ;

	if (x % y == 0) return cout << "-1\n" , 0 ;
	cout << x << '\n' ;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

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

    vector<int> a(5);
    REP(i, 5) cin >> a[i];

    int ans = 0;
    int b   = 0;
    int c   = 0;
    REP(i, 5) {
        if (a[i] % 10 != 0) {
            int aa = (10 - (a[i] % 10));
            if (b < aa) {
                c = i;
                b = 10 - a[i] % 10;
            }
        }
    }
    REP(i, 5) {
        if (i != c) {
            ans += a[i];
            while (ans % 10 != 0) {
                ans++;
            }
        }
    }

    ans += a[c];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <ctype.h>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
// #include <pair> 
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
// long long binpow(long long a,long long b)
// {
//     if (b == 1) return a;
//     long long res = binpow(a, b/2)%MOD;
//     if (b % 2) return (res*((res*a)%MOD))%MOD;
//     else return (res * res)%MOD;
// }
 
// long long int fact(long long int a)
// {
//     if(a==0||a==1)
//         return 1;
//     long long int ans = 1;
//     for(int i=a;i>=1;i--)
//         ans = (ans * i);
//     return ans;
// }
 
// long long int ivmod(long long int a)
// {
//     return binpow(a,MOD-2);
// }
 
// long long int ncr(long long int a,long long int b)
// {
//     long long int pans=1;
//     for(int i =a;i>max(b,a-b);i--)
//         pans=pans*i;
//     long long int div = fact(min(b,a-b));
//     // cout<<ans<<"            "<<div<<endl;
//     pans = pans/div;
//     return pans;
// }


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif   
    long long int n,a,b;
    cin>>n>>a>>b;
    long long int minn = (n-1)*a + b;
    long long int mx = (n-1)*b +a;
    //cout<<mx-minn+1<<endl;
    if(mx-minn+1<0)
        cout<<0<<endl;
    else
        cout<<mx-minn+1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int q,h,s,d;
long long n,ans;
int main(){
	scanf("%d%d%d%d",&q,&h,&s,&d);
	scanf("%lld",&n);
	if (q*2<h) h=q*2;
	if (h*2<s) s=h*2;
	if (s*2<d) d=s*2;
	n*=4;
	ans+=(n/8)*d; n%=8;
	ans+=(n/4)*s; n%=4;
	ans+=(n/2)*h; n%=2;
	ans+=n*q;
	printf("%lld\n",ans);
} 

Measured memory_bytes: 128
using System;

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            string Ans = "Three";
            int N = int.Parse(Console.ReadLine());
            string[] put = Console.ReadLine().Split(' ');
            var Color = new string[N+1];
            for (int i = 1; i <= N; i++)
            {
                if (put[i-1] == "Y")
                {
                    Ans = "Four";
                }
            }
            Console.WriteLine(Ans);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>

struct Position
{
    double x;
    double y;
};

double distance(Position p1, Position p2)
{
    double dx = p1.x - p2.x;
    double dy = p1.y - p2.y;
    return std::sqrt(dx * dx + dy * dy);
}

double radius(Position center, Position pos[50], int n)
{
    double maxDist = 0.0;
    for (int i = 0; i < n; ++i)
    {
        double dist = distance(center, pos[i]);
        if (dist > maxDist)
        {
            maxDist = dist;
        }
    }
    return maxDist;
}

double appropriateY(double x, Position pos[50], int n)
{
    double ly = 0.0, ry = 1000.0;
    while (ry - ly > 0.0000000001)
    {
        Position p1, p2;
        p1.x = x;
        p2.x = x;
        p1.y = (ly * 2.0 + ry) / 3.0;
        p2.y = (ly + ry * 2.0) / 3.0;
        if (radius(p1, pos, n) > radius(p2, pos, n))
        {
            ly = p1.y;
        }
        else
        {
            ry = p2.y;
        }
    }
    return (ly + ry) / 2.0;
}

int main()
{
    int n;
    Position pos[50];
    std::cin >> n;
    for (int i = 0; i < n; ++i)
    {
        std::cin >> pos[i].x >> pos[i].y;
    }

    double lx = 0.0, rx = 1000.0;
    Position p1, p2;
    while (rx - lx > 0.0000000001)
    {
        p1.x = (lx * 2.0 + rx) / 3.0;
        p2.x = (lx + rx * 2.0) / 3.0;
        p1.y = appropriateY(p1.x, pos, n);
        p2.y = appropriateY(p2.x, pos, n);
        if (radius(p1, pos, n) > radius(p2, pos, n))
        {
            lx = p1.x;
        }
        else
        {
            rx = p2.x;
        }
    }
    Position center;
    center.x = (p1.x + p2.x) / 2.0;
    center.y = (p1.y + p2.y) / 2.0;

    std::cout << std::setprecision(19) << radius(center, pos, n) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int dp[160][160][160];
int d2[310][310][310];
string s;
int cal(int x,int y,int z){
	if(d2[x][y][z]>=0) return d2[x][y][z];
	if(x==y) return d2[x][y][z]=1;
	if(x>y) return d2[x][y][z]=0;
	int ret=0;
	if(s[x]==s[y]) ret=max(ret,cal(x+1,y-1,z)+2);
	if(z>0) ret=max(ret,cal(x+1,y-1,z-1)+2);
	ret=max(ret,cal(x+1,y,z));ret=max(ret,cal(x,y-1,z));
	return d2[x][y][z]=ret;
}
int main()
{
	int K,n,out;
	cin>>s;n=s.size();cin>>K;
	memset(dp,0,sizeof(dp));
	rep(i,n/2+1) rep(j,n/2+1) rep(k,min(K,155)+1){
		//cout<<i<<' '<<j<<' '<<k<<' '<<dp[i][j][k]<<endl;
		if(i<n/2) dp[i+1][j][k]=max(dp[i+1][j][k],dp[i][j][k]);
		if(j<n/2) dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
		if(i<n/2 && j<n/2){
			if(s[i]==s[n-1-j]) dp[i+1][j+1][k]=max(dp[i+1][j+1][k],dp[i][j][k]+1);
			else dp[i+1][j+1][k+1]=max(dp[i+1][j+1][k+1],dp[i][j][k]+1);
		}
	}
	
	memset(d2,-1,sizeof(d2));
	//cal(0,n-1);
	
	//cout<<dp[6][9][3]<<' '<<cal(6,9)<<endl;
	rep(i,n/2+1) rep(j,n/2+1) rep(k,min(K,155)+1){
		out=max(out,dp[i][j][k]*2+cal(i,n-j-1,K-k));
	}
	cout<<out<<endl;
}


Measured memory_bytes: 132608
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
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> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b=mod-2,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



int n;

signed main() {
    while (cin >> n) {
        if (n==0) return 0;
        int res = 0;
        reps(l,1,n+1) {
            int s = l;
            reps(r,l+1,n+1) {
                s += r;
                if (s==n) {
                    res++;
                    break;
                }
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int t, n, m, k, a, b, c, d;

int32_t main(){
INIT
cin>>a>>b>>c>>d;
cout<<max(max(a*c, b*d), max(a*d, b*c) );



return 0;
}





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

ll ans = 0;

void ck(int x){
    ll three=0;
    ll five =0;
    ll seven=0;
    ll tmp = x;
    //cout << x << endl;
    while(true){
        tmp = x%10;
        if(tmp==3) three++;
        if(tmp==5) five++;
        if(tmp==7) seven++;
        x /= 10;
        if(x==0) break;
    }
    //cout << "3:" << three << " 5:" << five << " 7:" << seven << endl;
    if(three>0 && five>0 && seven>0) ans++;
}

void dfs(ll x, ll n){
    if(x <= n){
        ck(x);
        dfs(10*x+3, n);
        dfs(10*x+5, n);
        dfs(10*x+7, n);
    }
}


int main(){
    ll n;

    cin >> n;
    dfs(0, n);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#define M_NUM 1010
using namespace std;

int main() {
	int num, sum;
	scanf("%d%d", &num,&sum);

	int a,b;
	bool f = false;

	for (a = 0;a <= num;a++) {
		for (b = 0;b <= (num-a) ;b++) {
			if (9 * a + 4 * b == (sum / 1000) - num) {
				printf("%d %d %d\n", a, b, num - a - b);
				f = true;
				break;
			}
		}
		if (f)
			break;
	}

	if (!f)
		printf("-1 -1 -1\n");

	return 0;

}



Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import Data.List

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

main :: IO ()
main = do
  getLine
  xs <- readIntsLine
  let len = length xs
  let sxs = sort xs
  let ixs = map fst . sortOn snd $ zip [1..] $ map fst . sortOn snd $ zip [1..] xs
  let [a, b] = take 2 $ drop (len `div` 2 - 1) sxs
  let mark = len `div` 2
  mapM_ print [if x > mark then a else b | x <- ixs]


Measured memory_bytes: 98940
#include <stdio.h>

#define MAX 100000

int type(int,int);

typedef struct{
  int le,ri,pa;
}data;

data Da[MAX];

int De[MAX];

int main(){
  int n,id,k,buf,bufi,chk=0,le,ri;
  int i,j;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++) Da[i].pa=Da[i].le=Da[i].ri=-1;
  
  for(i=0;i<n;i++){
    scanf("%d%d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&bufi);
      if(j==0) Da[id].le=bufi;
      else Da[le].ri=bufi;
      le=bufi;
      Da[bufi].pa=id;
    }
  }
  for(i=0;i<n;i++){
    if(Da[i].pa==-1) ri=i;
  }

  type(ri,0);
  
  for(i=0;i<n;i++){
    chk=0;
    printf("node %d: ",i);
    printf("parent = %d, ",Da[i].pa);
    printf("depth = %d, ",De[i]);
    if(Da[i].pa==-1) printf("root, ");
    else if(Da[i].le==-1) printf("leaf, ");
    else printf("internal node, ");
    printf("[");
    for(j=0,buf=Da[i].le;buf!=-1;j++,buf=Da[buf].ri){
      if(j) printf(", ");
      printf("%d",buf);
    }
    printf("]\n");
  }
  
  return 0;
}

int type(int a,int b){
  De[a]=b;
  if(Da[a].ri!=-1) type(Da[a].ri,b);
  if(Da[a].le!=-1) type(Da[a].le,b+1);
} 



Measured memory_bytes: 6380
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;
long long MOD=mod;
#define SIZE 1000010
long long fac[SIZE],finv[SIZE],inv[SIZE];
int X,Y;


void make() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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


int main(){

cin>>X>>Y;

if(abs(X-Y)>min(X,Y)|| (X+Y)%3!=0){
    cout<<"0"<<endl;
    return 0;
}

long long cnt=(X+Y)/3;
long long d=abs(X-Y);
long long k;
if(cnt%2==0){
k=cnt/2+d/2;
}
else{
k=cnt/2+(d/2)+1;   
}


make();

cout<<C(cnt,k)<<endl;


 return 0;
}
/*
3 3

2

2 2

0

999999 999999

151840682

*/

Measured memory_bytes: 23680
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n,k,x,y;
  cin>>n>>k>>x>>y;
  int ans = 0;
  if(n - k > 0) {
    ans += y * (n - k) + k * x;
  } else {
    ans += n * x;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
# edges[src][dst] = cost
def warshall(n, edges)
    dist = Array.new(n+1){Array.new(n+1, Float::INFINITY)}
    edges.length.times do |src|
        edges[src].each do |dst, cost|
            dist[src][dst] = cost
        end
    end
    (n+1).times do |k|
        (n+1).times do |i|
            (n+1).times do |j|
                d2 = dist[i][k] + dist[k][j]
                dist[i][j] = d2 if dist[i][j] > d2
            end
        end
    end
    return dist
end



N, M = gets.split.map(&:to_i)
edges = Array.new(N){Hash.new}
M.times do |i|
    a, b, c = gets.split.map(&:to_i)
    edges[a-1][b-1] = c
    edges[b-1][a-1] = c
end

dist = warshall(N, edges)
ans = 0
N.times do |i|
    ((i+1)...N).each do |j|
        next unless edges[i][j]
        ans += 1 if dist[i][j] < edges[i][j]
    end
end

puts ans

Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
#define rep(i,n) for(int i = 0;i<n;i++)

int main(){
	ll n;
	cin >> n;
	vector<char> name;
	n = n-1;
	if( n== 0){
		cout << 'a' << endl;
		return 0;
	}
	while(n != -1 ){
		name.push_back('a'+ (n%26) );
		// name.push_back('a'-1+(n%26));
		n /= 26;
		n -= 1;
	}
	
	for(int i = name.size()-1; i>=0; i--) cout << name[i];
	cout << endl;

	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main()
{

    int N, M;
    cin >> N >> M;

    int Days = N;

    for (int i = 0; i < M; i++) {
        int A;
        cin >> A;

        Days -= A;

        if (Days < 0) {
            cout << -1 <<  endl;
            return 0;
        }
        
    }

    cout << Days <<  endl;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
using namespace std;

int s[35][35];

signed main(){
  
  while(1){
    
    int w, h, t, p;
    cin>>w>>h>>t>>p;
    
    if( !w && !h && !t && !p ) break;
    
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++) s[i][j] = 1;
    }
    
    while(t--){
      
      int d, c;
      cin>>d>>c;
      
      int t[35][35] = {};
                  
      if( d == 1 ){
	
	for(int i=0;i<h;i++){
	  
	  for(int j=0;j<c;j++){
	    
	    t[i][j] = s[i][c-j-1];
	    
	  }
	  
	}
	
	for(int i=0;i<h;i++){
	  
	  for(int j=c;j<w;j++){
	    
	    t[i][j-c] += s[i][j];
	    
	  }
	  
	}
	
	w = max( c, w - c );
	
	for(int i=0;i<h;i++){
	  for(int j=0;j<w;j++) s[i][j] = t[i][j];
	}
	
      }
      else{
	
	for(int i=0;i<c;i++){
	  
	  for(int j=0;j<w;j++){
	    
	    t[i][j] = s[c-i-1][j];
	    
	  }
	  
	}
	
	for(int i=c;i<h;i++){
	  
	  for(int j=0;j<w;j++){
	    
	    t[i-c][j] += s[i][j];
	    
	  }
	  
	}
	
	h = max( c, h - c );
	
	for(int i=0;i<h;i++){
	  for(int j=0;j<w;j++) s[i][j] = t[i][j];
	}
	
      }      
      
    }
    
    while(p--){
      
      int x, y;
      cin>>x>>y;
      
      cout<<s[y][x]<<endl;
      
    }
    
  }
  
  return 0;
}



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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

int main(){
    int N,M;cin>>N>>M;
    vec_int X(M);
    rep(i,M)cin>>X.at(i);

    if(M<=N){
        cout<<0<<endl;
        return 0;
    }
    //N<Mの場合に限定
    //明らかに最初にN個はM個のうちのどこかに置くことになる
    //残りのN-M個になるけれど、移動距離が最短になるN-M個を動かすように制度設計をすればよい。

    //Xをソートする
    sort(X.begin(),X.end());
    //M-1個の距離のベクトルを求める

    vec_int D(M-1);
    rep(i,M-1){
        D.at(i)=X.at(i+1)-X.at(i);
    }

    //Dをソートする
    sort(D.begin(),D.end());

    //Dの最初のN-M個が求める答え

    int tot = 0;
    rep(i,M-N){
        tot+=D.at(i);
    }

    cout<<tot<<endl;








    return 0;
}

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

using namespace std;

int main( void )
{
	int map[1001];
	int w; long long count;
	count = 0;
	while(cin >> w, w) {
		++w;
		for(int i=0; i < w; ++i) map[i] = 0;
		int n, value, weight;
		cin >> n;
		scanf("%d,%d", &value, &weight);
		map[weight] = value;
		for(int i=1; i < n; ++i) {
			scanf("%d,%d", &value, &weight);
			for(int j=w-1; j > 0; --j) {
				if(map[j]) {
					int ww = j + weight;
					if(w > ww) {
						map[ww] = max(map[ww], map[j] + value);
					}
				}
			}
			map[weight] = max(map[weight], value);
		}
		int Max = 0, idx;
		for(int i=1; i < w; ++i) {
			if(Max < map[i]) {
				Max = map[i];
				idx = i;
			}
		}
		cout << "Case " << ++count << ':' << endl;
		cout << Max << endl;
		cout << idx << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

// edit

int conv(int h, int m){
    return h * 60 + m;
}

void solve() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    
    int tapi = conv(h1, m1);
    int tapu = conv(h2, m2);
    
    int ans = max(0, tapu - tapi -  k);
    cout << ans << endl;
    
    
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll M;
    cin >> M;
    ll n = 0, s = 0;
    rep(i, M) {
        ll d, c;
        cin >> d >> c;
        n += c;
        s += d * c;
    }
    ll ans = n - 1 + (s - 1) / 9;
    cout << ans << endl;
}

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

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, a, b;
  cin >> n >> a >> b;
  long long cur = a + b;
  long long res = 0, t = n / cur;
  res += t * a;
  n -= cur * t;
  if (n >= a) res += a;
  else res += n;
  cout << res << '\n';
  return 0;
}


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

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

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

  vl K = {7, 5, 3, 0};

  ll ans = 0;

  REP(i, POW(4, 9)) {
    vector<bool> ok = {false, false, false, false};
    ll score = 0;
    ll k = i;
    bool zerodame = false;
    bool zeroout = false;
    REP(j, 9) {
      ok[k % 4] = true;
      if ((k % 4) != 3)
        zerodame = true;
      if ((k % 4) == 3 && zerodame) {
        zeroout = true;
      }
      score += K[k % 4] * POW(10, 8 - j);
      k /= 4;
    }
    if (ok[0] && ok[1] && ok[2] && !zeroout && score <= N) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

int main(){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  int dx = tx - sx;
  int dy = ty - sy;

  for (int i = 0; i < dy; i++) {
    cout << "U";
  }
  for (int i = 0; i < dx; i++) {
    cout << "R";
  }
  for (int i = 0; i < dy; i++) {
    cout << "D";
  }
  for (int i = 0; i < dx; i++) {
    cout << "L";
  }
  cout << "L";
  for (int i = 0; i <= dy; i++) {
    cout << "U";
  }
  for (int i = 0; i <= dx; i++) {
    cout << "R";
  }
  cout << "D" << "R";
  for (int i = 0; i <= dy; i++) {
    cout << "D";
  }
  for (int i = 0; i <= dx; i++) {
    cout << "L";
  }
  cout << "U" << endl;
}


Measured memory_bytes: 256
import scala.collection.mutable.ArrayBuffer

object Main extends App {
	val sc = new java.util.Scanner(System.in)
	val pw = new java.io.PrintWriter(System.out)
	
	val a, b = sc.nextInt
	
	pw.println( if (a < b) a.toString * b else b.toString * a )
	pw.flush()
}

Measured memory_bytes: 25780
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	resolve(parseProblem())
}

func parseProblem() string {
	return scanString(sc)
}

const (
	Pre = 0 + iota
	Removing
	Post
)

func resolve(str string) {
	const target = "keyence"
	if strings.HasSuffix(str, target) {
		fmt.Println("YES")
		return
	}
	if str[0:len(target)] == target {
		fmt.Println("YES")
		return
	}
	i := 0
	for ; i < len(str); i++ {
		if str[i] != target[i] {
			break
		}
	}
	if strings.HasSuffix(str, target[i:len(target)]) {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
	return
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


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

template<class T>
class FenwickTree {
 public:
  std::vector<T> data;
  FenwickTree<T>(unsigned size) : data(size + 1u, 0) {}
  T sum(unsigned index) {
    ++index;
    T ret = 0;
    while (index) {
      ret += data[index];
      index &= index - 1u;
    }
    return ret;
  }
  void add(unsigned index, T x) {
    ++index;
    while (index <= data.size()) {
      data[index] += x;
      index += index & (~index + 1u);
    }
  }
};

int main() {
  unsigned N, M;
  std::cin >> N >> M;
  std::vector<std::pair<unsigned, unsigned>> lr(N);
  for (unsigned i = 0; i < N; ++i) {
    std::cin >> lr[i].first >> lr[i].second;
  }
  std::sort(lr.begin(), lr.end(),
            [](std::pair<unsigned, unsigned> i,
               std::pair<unsigned, unsigned> j) -> bool {
              return (i.second - i.first) < (j.second - j.first);
            });
  auto p = lr.begin();
  long long inc = N;
  FenwickTree<long long> fenwickTree(M + 2);
  for (unsigned i = 1; i <= M; ++i) {
    while (p < lr.end() && (p->second - p->first + 1) < i) {
      --inc;
      fenwickTree.add(p->first, 1);
      fenwickTree.add(p->second + 1, -1);
      ++p;
    }
    auto ans = inc;
    for (unsigned j = 0; j <= M; j += i) {
      ans += fenwickTree.sum(j);
    }
    std::cout << ans << std::endl;
  }
  return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  for(int i=0; i<M; i++){
    int a;
    cin >> a;
    N -= a;
  }

  cout << (N>=0 ? N : -1) << endl;
}


Measured memory_bytes: 3576
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
f = True
for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            dx = [0]
            dy = [0]
            if i != 0:
                dx.append(-1)
            if i != h - 1:
                dx.append(1)
            if j != 0:
                dy.append(-1)
            if j != w - 1:
                dy.append(1)
            ff = False
            for x in dx:
                for y in dy:
                    if abs(x) == abs(y):
                        continue
                    ff |= (s[i + x][j + y] == "#")
            f &= ff

print("Yes" if f else "No")


Measured memory_bytes: 9212
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <map>
using namespace std;

int main()
{
	int64_t X, Y;
	cin >> X >> Y;

	int64_t res = 1;
	while (true) {
		X *= 2;
		if (X > Y)
			break;
		res++;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, q;

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

  cin >> q;
  while (q--) {
    cin >> n;
    ll k[n + 10] = {}, l[n + 10] = {}, r[n + 10] = {}, info_pos = 0;
    vector<P> info;
    pq que1, que2;
    ans = 0;
    rep(i, n) cin >> k[i] >> l[i] >> r[i], k[i]--;
    // l[i] >= r[i]
    rep(i, n) {
      if (l[i] < r[i]) continue;
      ans += r[i];
      info.p_b({k[i], i});
    }
    sort(all(info));
    reverse(all(info));
    rrrep(i, n - 1, 0) {
      rrep(j, info_pos, Size(info)) {
        if (info[j].fi < i) {
          info_pos = j;
          break;
        } else
          que1.push(l[info[j].se] - r[info[j].se]), info_pos = j + 1;
      }
      if (Size(que1) != 0) {
        ans += que1.top();
        que1.pop();
      }
    }
    info.clear();
    info_pos = 0;

    // l[i] < r[i]
    rep(i, n) {
      if (l[i] >= r[i]) continue;
      ans += l[i];
      info.p_b({k[i], i});
    }
    sort(all(info));
    rep(i, n) {
      rrep(j, info_pos, Size(info)) {
        if (info[j].fi >= i) {
          info_pos = j;
          break;
        } else
          que2.push(r[info[j].se] - l[info[j].se]), info_pos = j + 1;
      }
      if (Size(que2) != 0) {
        ans += que2.top();
        que2.pop();
      }
    }
    Cout(ans);
  }
  return 0;
}

Measured memory_bytes: 9952
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
h,w = readInts()
n = I()
a = readInts()
i = 0
for j in range(h):
    row = []
    for _ in range(w):
        row += [i+1]
        a[i] -= 1
        if a[i] == 0:
            i += 1
    if j % 2 == 1:
        row = reversed(row)
    print(*row)


Measured memory_bytes: 5788
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<set>
#include<queue>
#include<stack>
#include<map>
using namespace std;
typedef long long LL;
const int N = 1e5+5;
int n;
LL a[N],b[N],ret,sum;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%lld%lld",&a[i],&b[i]);
    for(int i=n;i>=1;--i){
       a[i]+=sum;
       a[i]%=b[i];
       if(a[i])sum+=b[i]-a[i],ret+=b[i]-a[i];
    }
    printf("%lld\n",ret);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {
    int n, M = 0, sum = 0, l;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> l;
        sum += l;
        M = max(M, l);
    }

    if (sum > 2 * M)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 888