akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int n,m;
unordered_map<int,int> mp;

bool solve(){
	for(auto x:mp){
		if(x.second%2!=0)return 0;
	}
	return 1;
}
int main(void)
{
	cin>>n>>m;
	for (int i = 0; i < m; i++) {
		int a,b;
		cin>>a>>b;
		mp[a]++;
		mp[b]++;
	}
	if(solve())cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 3876
#include <iostream>

using namespace std;

int main()
{
	int A, B, C, D;
	int first, second;

	cin >> A;
	cin >> B;
	cin >> C;
	cin >> D;

	first = A*B;
	second = C*D;

	if (first > second) {
		cout << first << endl;
	}
	else if (first <second) {
		cout << second << endl;
	}
	else if(first==second){
		cout << first << endl;
	}

}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var chars = Console.ReadLine();
            var result = new char[chars.Length];

            var count = 0;
            foreach (var c in chars)
            {
                if (char.IsUpper(c))
                {
                    result[count] = char.ToLower(c);
                }
                else if (char.IsLower(c))
                {
                    result[count] = char.ToUpper(c);
                }
                else
                {
                    result[count] = c;
                }
                count++;
            }

            Console.WriteLine(new string(result));

        }
    }
}



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

int main(){
  int h, w; cin >> h >> w;
  int n; cin >> n;
  int ans [h][w] = {};
  int x = 0;
  int y = 0;
  rep(i, n) {
    int num; cin >> num;
    while(num--){
      ans[y][x] = i + 1;
      if(y % 2 == 0) {
        if(x == w-1) y++;
        else x++;
      } else {
        if(x == 0) y++;
        else x--;
      }
    }
  }
  for(int i = 0; i<h; i++){
    for(int j = 0; j < w; ++j){
      (j == 0) ? cout << ans[i][j] : cout << " " << ans[i][j];
    }
    cout << endl;
  }
  return 0; 
}

Measured memory_bytes: 3652
Q=int(input())
lr=[list(map(int,input().split())) for i in range(Q)]
def is_prime(N):
    is_prime=[True]*(N+1)
    is_prime[0:2]=False,False
    for i in range(int(N**0.5)+1):
        if is_prime[i]==False:
            continue
        for j in range(i*2,N+1,i):
            is_prime[j]=False
    return is_prime

prime=is_prime(10**5)
like=[0]*(10**5+1)
for i in range(1,10**5+1):
    if i%2==1 and prime[i] and prime[(i+1)//2]:
        like[i]=like[i-1]+1
    else:
        like[i]=like[i-1]
for l,r in lr:
    print(like[r]-like[l-1])

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int a, b, c, ans = 0;
    cin >> a >> b >> c;
    if(a > b){swap(a, b);}
    if(b > c){swap(b, c);}
    if(a > b){swap(a, b);}
    if((a != b && b != c) || (a == b && b == c)){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
def step(n):
  if n == 0:
      return 1
  steps = [0 for i in range(n + 2)]
  steps[1] = 1
  steps[2] = 2
  for i in range(3, n + 1):
    steps[i] = steps[i - 1] + steps[i - 2]
  return steps[n]

n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]

a.append(n)

sum = 1

for i in range(m + 1):

  if i == 0:
    sum *= step(a[i] - 1)
    continue
  
  elif i == m:
    sum *= step(a[m] - a[m-1] -1)
    
  elif a[i] - a[i-1] == 1:
    sum = 0
    break

  else:
    sum *= step(a[i] - a[i-1] -2)
    
if m == 0:
  sum = step(n)

print(sum % 1000000007)

Measured memory_bytes: 474548
n = gets.to_i
dp = Array.new(n+1).map{Array.new(3,0)}
n.times do |i|
    a = gets.split.map(&:to_i)
    3.times do |j|
        3.times do |k|
            next if j == k
            dp[i+1][j] = dp[i][k] if dp[i+1][j] < dp[i][k]
        end
        dp[i+1][j] += a[j]
    end
end
puts dp[n].max

Measured memory_bytes: 10108
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

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



vector<int> rf(vector<int> nums){
	int n = nums.size();
	vector<int> res(n);
	rep(i, n){
		if(i >= n / 2){
			res[2*(i-n/2)+1] = nums[i];
		}else{
			res[2*i] = nums[i];
		}
	}
	return res;
}

vector<int> cu(vector<int> nums, int k){
	int n = nums.size();
	vector<int> res(n);
	rep(i, n){
		if(i < k){
			res[n-k+i] = nums[i];
		}else{
			res[i-k] = nums[i];
		}
	}
	return res;
}

vector<int> nums;

int main(){
	int n, m, k;
	while(cin >> n >> m && (n || m)){
		nums.clear();
		rep(i, 2 * n) nums.push_back(i + 1);
		rep(i, m){
			cin >> k;
			if(k == 0) {
				nums = rf(nums);
			}else{
				nums = cu(nums, k);
			}
		}
		rep(i, 2 * n) cout << nums[i] << endl;;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        int[] m = new int[n];
        int ans = 0;
        for(int i = 0; i < n; ++i) {
            p[i] = sc.nextInt();
            m[i] = (i == 0) ? p[i] : Math.min(p[i], m[i - 1]);
            if(p[i] == m[i]) ++ans;
        }
        System.out.println(ans);
    }
}

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

string r,g,d, out;
unsigned int x,y,z;
char center;
char pushR(){ return g[y++]; }
char pushD(){ return r[x++]; }

int main(){
  while( cin>>r && r!="-" ){
    cin >> g >> d;
    x=0;y=0;z=0;

    out = "";
    center =  pushR();
    while( r.length()-x + g.length()-y > 0 ){
       if( z<d.length() && center==d[z] ){
	center = pushD();
	z++;
      }else{
	out += center;
	center = pushR();
      }
    }
    out += center;

    cout << out << endl;
  }

  return 0;
}

Measured memory_bytes: 1184
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll N,A,B;
    cin >> N >> A >> B;
    ll X[N];
    rep(i,N) cin >> X[i];
    ll out = 0;
    rep(i,N-1){
        out += min((X[i+1]-X[i])*A,B);
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 4344
#include<stdio.h>
#include<string.h>

#define SIGN_LENGTH 9
#define CIPHER_NUM 32
#define CODE_MAX 801
#define NUL 0x00
#define INITIALIZE 0
#define TEXT_LENGTH_MAX 101
#define FIVE 5

typedef struct cipher
{
	char charcter_change_sign[SIGN_LENGTH];
	char sign_change_charcter[SIGN_LENGTH];
	char charcter;
}CIPHER;

int main(void)
{
	
	CIPHER code[CIPHER_NUM] = {
		{"100101","00000",'A'},
		{"10011010","00001",'B'},
		{"0101","00010",'C'},
		{"0001","00011",'D'},
		{"110","00100",'E'},
		{"01001","00101",'F'},
		{"10011011","00110",'G'},
		{"010000","00111",'H'},
		{"0111","01000",'I'},
		{"10011000","01001",'J'},
		{"0110","01010",'K'},
		{"00100","01011",'L'},
		{"10011001","01100",'M'},
		{"10011110","01101",'N'},
		{"00101","01110",'O'},
		{"111","01111",'P'},
		{"10011111","10000",'Q'},
		{"1000","10001",'R'},
		{"00110","10010",'S'},
		{"00111","10011",'T'},
		{"10011100","10100",'U'},
		{"10011101","10101",'V'},
		{"000010","10110",'W'},
		{"10010010","10111",'X'},
		{"10010011","11000",'Y'},
		{"10010000","11001",'Z'},
		{"101","11010",' '},
		{"010001","11011",'.'},
		{"000011","11100",','},
		{"10010001","11101",'-'},
		{"000000","11110",'\''},
		{"000001","11111",'?'}
	};
	
	unsigned short i = INITIALIZE;
	unsigned short j = INITIALIZE;
	unsigned short k = INITIALIZE;
	
	char input_text[TEXT_LENGTH_MAX];
	for(i = 0; i < TEXT_LENGTH_MAX; i++)
	{
		input_text[i] = NUL;
	}
	
	while(gets(input_text) != NULL)
	{
		unsigned short text_length = INITIALIZE;
		unsigned short barcode_length = INITIALIZE;
		unsigned short count = INITIALIZE;
		int c = 0;
		int cc = 0;
		char barcode[CODE_MAX];
		char code_fivecut[CODE_MAX / FIVE][FIVE];/*160:5*/
		
		for(i = 0; i < CODE_MAX - 1; i++)//配列の最後(800番目)には\0が入るためマイナス1してある
		{
			barcode[i] = NUL;
		}
		
		for(i = 0; i < CODE_MAX / FIVE;i++)
		{
			for(j = 0; j < 5; j++)
			{
				code_fivecut[i][j] = '0';
			}
		}
		
		for(i = 0; i < TEXT_LENGTH_MAX; i++)
		{
			text_length++;
			if(input_text[i] == NUL)
			{
				break;
			}
		}
		
		for(i = 0; i < text_length; i++)
		{
			for(j = 0; j < CIPHER_NUM; j++)
			{
				if(input_text[i] == code[j].charcter)
				{
					strcat(barcode, code[j].charcter_change_sign);
				}
			}
		}
		
		for(i = 0; i < CODE_MAX; i++)
		{
			barcode_length++;
			if( barcode[barcode_length] == '\0')
			{
				break;
			}
		}
		
		for(i = 0; i < barcode_length; i++)
		{
			for(j = 0; j < FIVE; j++)
			{
				if(c < barcode_length)
				{
					code_fivecut[i][j] =  barcode[c];
					c++;
				}
			}
		}
		
		for(i = 0;i < CODE_MAX ; i+= FIVE)
		{
			if(barcode_length <= i)
			{
				count = i / FIVE;
				break;
			}
		}
		
		for(i = 0; i < count; i++)
		{
			for(j = 0; j < CIPHER_NUM; j++)
			{
				for(k = 0; k < FIVE; k++)
				{
					if(code_fivecut[i][k] == code[j].sign_change_charcter[k])
					{
						cc++;
					}
				}
				if(cc == 5)
				{
					printf("%c",code[j].charcter);
				}
				cc = 0;
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 524
var n,i,j,k,y:longint;
begin
  read(n,y);
  for i:=0 to n do
  begin
    for j:=0 to n-i do
    if (y-i*10000-j*5000) mod 1000=0 then
    begin
      k:=(y-i*10000-j*5000) div 1000;
      if i+j+k=n then
      begin
        writeln(i,' ',j,' ',k);
        exit;
      end;
    end;
  end;
  writeln('-1 -1 -1');
end.


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

#define ll long long int

#define pi 2*acos(0.0)
#define mod 1000000007

#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}

#define pb push_back
#define Bit_off(val,pos)       (val & (~(1<<pos)))
#define Bit_on(val,pos)        (val | (1<<pos))
#define Bit_toggle(val,pos)    (val ^ (1<<pos))
#define Bit_check(val,pos)     (bool)(val & (1<<pos))
#define odd_even(val)          (bool)(val & 1)
#define koita_1_ase(val)       (__builtin_popcount(val))

//ll Big_Mod(ll v1, ll p, ll md)  { ll res=1; v1=v1%md; while (p > 0){if (p & 1)res = (res * v1) % md; p =p>>1; v1 = (v1 * v1) % md;}return res;}

ll ar[500009],br[500009],cr[500009];
map<ll,ll>mp,mp1;
vector<ll>v;
string s,d;

int main()
{
    ll a,b,c,i=0,j,k,x,y,z,f,g,h;
    cin>>a>>b>>c>>x;
    while(1)
    {
        i++;
        if(i%2==1)
        {
            c=c-b;
            if(c<=0)
            {
                k=1;
                 break;
            }
        }
        else
        {
            a=a-x;
            if(a<=0)
            {
                k=0;
                break;
            }
        }
    }
    if(k==1)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}



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

int main(){
    ll a, v;
    cin >> a >> v;

    ll b, w;
    cin >> b >> w;
    ll t;
    cin >> t;

    int flag = 0;

    if(v <= w){
        flag = 1;
    }else{
        ll k = 0;
        if(a >= b){
            k = a - b;
        }else{
            k = b - a;
        }

        ll o = v - w;

        ll ans = k / o;

        if(k % o != 0){
            ans++;
        }

        if(ans > t){
            flag = 1;
        }
    }

    if(flag == 1){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define emb emplace_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define N  99999
#define f first 
#define em emplace
#define s second
using lint=long long int;

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;

 
#define fori(n) for(int i=0; i<int(n); i++)
 
#define cins(s) string s; cin>>s;
#define cini(i) lint i; cin>>i;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }
#define z 1000000007 
const int INF=1e9+5;
   
void solve(){
 
        cini(n); cini(k);
        vector<int> v(n,INF);
        cinai(b,n);
        v[0]=0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<=i+k;j++){
              if(j<n)
                v[j]=min(v[j],abs(b[i]-b[j])+v[i]);
            }
        }

        cout<<v[n-1]<<endl;
  }

 
 
int main()
{ 
  fast;
  /*#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("hex.txt","w",stdout);
  #endif*/

  solve();
 }

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define LL __int128

using namespace std;

LL read()
{
	LL ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}

void write(LL x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
        write(x/10);
    putchar(x%10+'0');
}

LL n,a,ans=1,sum=1e18;

int main()
{
	n=read();
	for(int i=1;i<=n;++i)
	{
		a=read();
		if(ans!=-1)
			ans=ans*a;
		if(ans>sum)
			ans=-1;
		if(a==0)
			ans=0;
	}
	write(ans);
	return 0;
}


Measured memory_bytes: 2996
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

ll A, B;

ll gcd(ll a, ll b) {
    if (a < b) return gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    cin >> A >> B;
    ll G = gcd(A, B);

    int ans = 1;
    for (ll i = 2; i * i <= G; i++) {
        if (G % i == 0) ans++;
        while (G % i == 0) G /= i;
    }
    if (G != 1) ans++;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int gcd(int N, int M){
  if (M == 0){
    return N;
  } else {
    return gcd(M, N % M);
  }
}
long long lcm(long long N, long long M){
  return N * M / gcd(N, M);
}
int main(){
  int N, M;
  cin >> N >> M;
  string S;
  cin >> S;
  string T;
  cin >> T;
  long long L = lcm(N, M);
  map<int, char> mp;
  for (int i = 0; i < N; i++){
    mp[L / N * i] = S[i];
  }
  bool ok = true;
  for (int i = 0; i < M; i++){
    if (mp.count(L / M * i) && mp[L / M * i] != T[i]){
      ok = false;
    }
  }
  if (ok){
    cout << L << endl;
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 4736
n, limit = gets.chomp.split.map(&:to_i)
sack = Array.new(limit + 1, 0)
n.times{
    v, w = gets.chomp.split.map(&:to_i)
    prev = sack.dup
    1.upto(limit){|j|
        sack[j] = [(j < w) ? 0 : prev[j - w] + v, prev[j]].max
    }
}
p sack.last

Measured memory_bytes: 9240
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_M = 100000, MAX_N = 100000;
int n, m, s, t;
int u[MAX_M], v[MAX_M];
int a[MAX_M], b[MAX_M];

                            
struct edge { int to, cost; 
  edge(int t, int c) {
    to = t; cost = c;
  }
};
const int MAX_V = 100000; 
const ll INF = 1e18;

int V;
vector<edge> G1[MAX_V];
vector<edge> G2[MAX_V];
ll d[MAX_V];

void dijkstra(int s, vector<edge> G[]) {
  fill(d, d+V, INF);

  priority_queue<pii, vector<pii>, greater<pii> > pque;
  d[s] = 0;
  pque.push(pii(0, s));


  while (!pque.empty()) {
    pii p = pque.top(); pque.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < (int)G[v].size(); ++i) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost; 
        pque.push(pii(d[v]+ e.cost, e.to));
      }
    }
  }
}

ll sto[MAX_N], tot[MAX_N];
pll cost[MAX_N];

int main() {
  cin >> n >> m >> s >> t;
  --s; --t;
  rep(i,m) {
    int tu, tv;
    cin >> tu >> tv >> a[i] >> b[i];
    u[i] = tu-1; v[i] = tv-1;
  }
  V = n;

  // stoを求める。
  rep(i,m) {
    G1[u[i]].push_back(edge(v[i], a[i]));
    G1[v[i]].push_back(edge(u[i], a[i]));
  }

  dijkstra(s, G1);

  rep(i,n) sto[i] = d[i];

  // totを求める。
  rep(i,m) {
    G2[u[i]].push_back(edge(v[i], b[i]));
    G2[v[i]].push_back(edge(u[i], b[i]));
  }

  dijkstra(t, G2);

  rep(i,n) tot[i] = d[i];

  rep(i,n) cost[i] = pll(sto[i]+tot[i], i);

  sort(cost, cost+n);

  int idx = 0;
  ll money = 1e15;
  rep(i,n) {
    while (cost[idx].sc < i) ++idx;
    printf("%lld\n", money - cost[idx].fi);

  }

  return 0;
}



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

void dfs(int s, vector<vector<int>> &l, vector<int> &visited)
{
	visited[s]=1;
	for(int i=0; i<l[s].size(); i++)
	{
		int v=l[s][i];
		if(visited[v]==0)
			dfs(v,l,visited);
	}
}

int main()
{
	int n,m;
	cin>>n>>m;
	vector<vector<int>> l(n);
	for(int i=0; i<m; i++)
	{
		int u,v;
		cin>>u>>v;
		l[u-1].push_back(v-1);
		l[v-1].push_back(u-1);
	}

	vector<int> visited(n,0);
	int ans=0;
	for(int i=0; i<n; i++)
	{
		if(visited[i]==0){
			ans++;
			dfs(i,l,visited);
		}
	}
	cout<<ans-1<<endl;
	return 0;	
}


Measured memory_bytes: 9980
#include <bits/stdc++.h>
using namespace std;
 int arr[100];
int main() {
    int a,b;
    cin>>a>>b;
    for (int i=1;i<=1000;i++){
        if (floor(i*0.08)==a and floor(i*0.1)==b ){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back

using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

int s[51][51];
int g[51][51];

int main(){
	int w=read(),h=read(),T=read(),p=read();
	REP(i,p){
		int x=read(),y=read(),t=read();
		g[y][x]++;
	}
	REP(i,h)
		REP(j,w)
			s[i][j]=read();
	int ans=0;
	REP(i,h)REP(j,w)ans+=g[i][j]*s[i][j];
	cout<<ans<<endl;
}

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

using namespace std;

int main()
{
	int N;
	int i;
	int sum = 0;
	vector<int> ans;
	cin >> N;

	for (i = 1; i <= N; i++)
	{
		if (sum > N)
			break;

		sum += i;
	}

	for (int j = 1; j < i; j++)
	{
		if (sum - j != N)
		{
			cout << j << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[2005][2005];
int main() {
	a[0][0]=1;
	for(int i=1;i<2005;i++){
		for(int j=0;j<=i;j++){
			a[i][j]=a[i-1][j-1]+a[i-1][j];
			a[i][j]%=inf;
		}
	}
	ll n,k;
	cin>>n>>k;
	for(int i=1;i<=k;i++){
		cout << a[k-1][i-1]*a[n-k+1][i]%inf<<endl;
	}
}

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

long long int n,step;

int main(){
	while(scanf("%d",&n)*n>0){
		step=0;
		while(n>1){
			step++;
			if(n%2)n=3*n+1; else n=n/2;
		}
		printf("%d\n",step);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  ll x, y;
  cin >> x >> y;

  ll ans = x;

  if(x % y == 0) {
    ans = -1;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rint register int
#define MP make_pair
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii; // 注意必要时改类型
typedef vector<int> vi;
template<typename T>
inline void read(T &x){
    int ch = getchar(); x = 0;
    bool f = false;
    double d = 1;
    for(;ch != '-' && (ch < '0' || ch > '9');ch = getchar());
    if(ch == '-'){f = true; ch = getchar();}
    for(;ch >= '0' && ch <= '9';ch = getchar()) x = x * 10 + ch - '0';
    if(ch == '.') for(ch = getchar();ch >= '0' && ch <= '9';ch = getchar()) x += (ch - '0') * (d *= 0.1);
    if(f) x = -x;
}
template<typename T>
inline bool chkmax(T &a, const T &b){if(a < b) return a = b, 1; return 0;}
template<typename T>
inline bool chkmin(T &a, const T &b){if(a > b) return a = b, 1; return 0;}
double L;
int main(){
    read(L); L /= 3;
    printf("%.10lf", L * L * L);
}

Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;

struct Edge {
  
    string name;     // 辺の行き先
    int point; // 辺の重み
  
    Edge(string n, int p) : name(n), point(p) { }
  
};

using Graph = vector<vector<Edge>>;
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;



using Graph = vector<vector<Edge>>;

char in[120];
pair<pair<string,int>,int> p[110];

int main(){
  
int a;scanf("%d",&a);
for(int i=0;i<a;i++){
int t;scanf("%s%d",in,&t);
string tmp=in;
p[i]=make_pair(make_pair(in,-t),i);
}
std::sort(p,p+a);
for(int i=0;i<a;i++)printf("%d\n",p[i].second+1);

  
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.ParseException;
import java.util.*;


public class Main {

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;
    static StringBuilder sb = new StringBuilder("");

    static int[] inputArray(int n) throws IOException {
        int[] a = new int[n];
        st = new StringTokenizer(br.readLine());
        for(int i = 0 ; i < n ; i++) {
            a[i] = Integer.parseInt(st.nextToken());
        }
        return a;
    }

    public static void main(String[] args) throws IOException {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            StringTokenizer st;
            StringBuilder sb = new StringBuilder("");
            int n = Integer.parseInt(br.readLine());
            int res = 0;
            boolean found = false;
            for(int i = 0 ; i < n ; i++) {
                st = new StringTokenizer(br.readLine());
                if(st.nextToken().equals(st.nextToken())) {
                    res++;
                }
                else {
                    res = 0;
                }
                if(res == 3) {
                    found = true;
                }
            }
            if(found) {
                System.out.println("Yes");
            }
            else {
                System.out.println("No");
            }
        }

    static int gcd(int a , int b) {
        if(a % b == 0) {
            return b;
        }
        return gcd(b , a % b);
    }

    static void longestGcdSeq(int a[] , int n) {
        int coprimes[] = new int[n];
        for(int i = 0 ; i < n ; i++) {
            if(a[i] < a[(i+1)%n]) {
                if(gcd(a[(i+1)%n] , a[i]) != 1) {
                    coprimes[i] = 1;
                }
            }
            else {
                if(gcd(a[i] , a[(i+1)%n]) != 1) {
                    coprimes[i] = 1;
                }
            }
        }
        //System.out.println(Arrays.toString(coprimes));
        int maxLen = 0 , startLen = 0 , endLen = 0;
        int i = 0;
        while(i < n && coprimes[i] == 1) {
            startLen++;
            i++;
        }
        i = n -1;
        while(i >= 0 && coprimes[i] == 1) {
            endLen++;
            i--;
        }
        int start = 0;
        for(i = 0 ; i < n ; i++) {
            if(coprimes[i] == 0) {
                maxLen = Math.max(maxLen , i - start);
                start = i + 1;
            }
        }
        maxLen = Math.max(maxLen , i - start);
        start = i + 1;
        //System.out.println(startLen + " " + maxLen + " " + endLen);
        int contMax = startLen == n ? n : Math.max(startLen + endLen , maxLen) + 1;
        //System.out.println(contMax);
        for(int k = 2 ; k <= n ; k++) {
            System.out.print((contMax-1)/(k-1) + " ");
        }
        System.out.println();
    }

}
/*

if(tree.size == 2) {

}

5 8
5 1 2 4 3
0 1
0 2
0 3
0 4
0 5
1 1000000000
1 1
1 500000000


 */

Measured memory_bytes: 32924
#include <bits/stdc++.h>
#define ll long long int
#define loop for(int i=0;i<n;i++)
using namespace std;
string reverese(string n)
{
	string st="";
	for(int i=n.length()-1;i>=0;i--)
		st+=n[i];
			return st;

}
int main()
{
string k;
cin>>k;
int flag=1;
int n=k.length();
if((k.substr(0,n/2)==reverese(k.substr(0,n/2))) and (k.substr(((n+3)/2)-1,n-1)==reverese(k.substr((((n+3)/2)-1),n-1))))
	if(k==reverese(k))
flag=2;
if(flag==2)
	puts("Yes");
else
	puts("No");


}

Measured memory_bytes: 256
import collections
N = int(input())
S = list(map(int, input()))
ans = 0
first = [0 for _ in range(10)]
lst = [[0 for _ in range(10)] for _ in range(10)]

for i in range(N):
	ima = 100
	if first[S[i]] == 0:
		first[S[i]] = 1
		ima = S[i]
	for j in range(10):
		if ima != j and first[j] == 1 and lst[j][S[i]] == 0:
			lst[j][S[i]] = 1
			ans += len(collections.Counter(S[i + 1:]))
				
				
print(ans)

Measured memory_bytes: 48620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;

const int MAXN = 2e5+5;

ll k, a[MAXN];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> k;
	for (int i = 0; i < k; ++i)
		cin >> a[i];

	ll a1 = 2, a2 = 2;

	for (int i = k-1; i >= 0; --i) {
		a1 = a[i]*((a1+a[i]-1)/a[i]);
		a2 = a[i]*(a2/a[i]);
		if (a1 > a2) {
			cout << "-1\n";
			return 0;
		}

		a2 += a[i]-1;
	}

	cout << a1 << ' ' << a2 << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
long long func(long long x,long long y){
  long long r;
  long long x1 = x,y1 = y;
  if(x <= y){
    r = x;
    x = y;
    y = r;
  }
  r = y;
  while(x % y != 0){
    r = x;
    x = y;
    y = r % x;
  }
  //cout << x1 << " "<< y1 << " " << y << endl;
  return x1 / y * y1;
}

int main(){
  int n;
  cin >> n;
  long long x;
  vector<long long> vec(n,0);
  for(int i=0;i<n;i++){
    cin >> vec[i];
  }
  x = vec[0];
  for(int i=1;i<n;i++){
    x = func(x,vec[i]);
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256
a,b,k=map(int,input().split())

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

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
from collections import defaultdict
from itertools import accumulate


def read():
    N, M = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, M, A

def solve(N, M, A):
    D = defaultdict(int)
    S = [0 for i in range(N+1)]
    for i in range(N):
        s = (S[i] + A[i]) % M
        S[i+1] = s
        D[s] += 1
    ans = 0
    k = 0
    for i in range(N):
        ans += D[k]
        k += A[i]
        k %= M
        D[k] -= 1
    return ans


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))


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

namespace ALDS1_9_A_CompleteBinaryTree
{
	class Program
	{
		static void Main ( string[] args )
		{
			int dataCount = int.Parse (Console.ReadLine ());
			int[] inputNum = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();

			Heap heap = new Heap (inputNum);
			string[] result = new string[dataCount];
			
			for (int lp = 0; lp < dataCount; lp++)
			{
				result[lp] = heap.GetInfomation (lp + 1);
			}

			Console.WriteLine (string.Join ("\r\n", result));
		}
	}

	class Heap
	{
		public Heap ( int[] numArray )
		{
			this.NumArray = new int[numArray.Length + 1];
			numArray.CopyTo (this.NumArray, 1);
		}

		private int[] NumArray { set; get; }
		private const int Error = int.MinValue;

		public string GetInfomation ( int index )
		{
			int key = GetKey (index);
			int parent = GetParentKey (index);
			int left = GetLeftKey (index);
			int right = GetRightKey (index);

			System.Text.StringBuilder output = new System.Text.StringBuilder (100);

			output.Append ("node " + index + ": ");
			output.Append ("key = " + key + ", ");

			if (parent != Error)
			{
				output.Append ("parent key = " + parent + ", ");
			}

			if (left != Error)
			{
				output.Append ("left key = " + left + ", ");
			}

			if (right != Error)
			{
				output.Append ("right key = " + right + ", ");
			}

			return output.ToString ();
		}

		private int GetKey ( int index )
		{
			if (1 <= index && index < NumArray.Length)
				return NumArray[index];
			else
				return Error;
		}
		private int GetParentKey ( int index )
		{
			int i = index / 2;

			if (1 <= i && i < NumArray.Length && index != i)
				return NumArray[i];
			else
				return Error;
		}
		private int GetLeftKey ( int index )
		{
			int i = index * 2;

			if (1 <= i && i < NumArray.Length)
				return NumArray[i];
			else
				return Error;
		}
		private int GetRightKey ( int index )
		{
			int i = index * 2 + 1;

			if (1 <= i && i < NumArray.Length)
				return NumArray[i];
			else
				return Error;
		}
	}
}

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


def main():
    H, W, K = map(int, input().split())
    state = [list(input()) for _ in range(H)]


    q = []
    checked = [[False]*W for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if state[h][w] == "S":
                q.append((h, w))
                checked[h][w] = True

    goal = False
    for _ in range(K):
        qq = []
        for h, w in q:
            if h == 0 or h == H-1 or w == 0 or w == W-1:
                goal = True
                break
            nexts = [(h, w-1), (h, w+1), (h-1, w), (h+1, w)]
            for nh, nw in nexts:
                if state[nh][nw] == "." and not checked[nh][nw]:
                    checked[nh][nw] = True
                    qq.append((nh, nw))
        q = qq
    if goal:
        print(1)
    else:
        ans = 10**14
        for h in range(H):
            for w in range(W):
                if checked[h][w]:
                    d1 = min(h, H-1-h)
                    d2 = min(w, W-1-w)
                    D = min(d1//K + min(d1%K, 1), d2//K + min(d2%K, 1))
                    ans = min(D+1, ans)
        print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 75868
#include <stdio.h>

int main(){
	int a, b, c;
	int tmp;
	scanf("%d %d %d", &a, &b, &c);
	if (a > b) {
	    tmp = a;
	    a = b;
	    b = tmp;
	}
	if (b > c) {
		tmp = b;
		b = c;
		c = tmp;
		if (a > b) {
		    tmp = a;
		    a = b;
		    b = tmp;
		}
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}


Measured memory_bytes: 2076
def gen_pattern(N, pre=""):
  for c in range(0x61, ord(max(pre or "\x60"))+2):
    pat = pre+chr(c)
    if len(pat) == N:
      yield pat
    else:
      yield from gen_pattern(N, pat)

for pattern in gen_pattern(int(input())):
  print(pattern)


Measured memory_bytes: 4412
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)); //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } }
const LL MOD = 1e9 + 7;
const LL INF = 1LL << 60;

bool is_ascending(vector<LL> vec) {
	bool res = true;
	for (LL i = 1; i < vec.size(); i++) {
		if (vec[i] < vec[i - 1]) {
			res = false;
			break;
		}
	}
	return res;
}

int main(void) {
	LL N;
	cin >> N;

	vector<LL> H(N);
	rep(i, N) cin >> H[i];

	for (int i = N - 1; i >= 1; i--) {
		if (H[i] >= H[i - 1]) {
			continue;
		}

		if (H[i] < H[i - 1]) {
			H[i - 1]--;
		}
	}

	if (is_ascending(H)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{

    public static int n;
    public static int[] A = new int[50];

    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        n = Integer.parseInt(br.readLine());
        String[] in = br.readLine().split(" ");
        for(int i = 0; i < n; i++) A[i] = Integer.parseInt(in[i]);
        int q = Integer.parseInt(br.readLine());
        in = br.readLine().split(" ");
        for(int i = 0; i < q; i++){
            //int M = Integer.parseInt(in[i]);                                        
            if(solve(0, Integer.parseInt(in[i]))) sb.append("yes\n");
            else sb.append("no\n");
        }
        System.out.print(sb);
    }

    public static boolean solve(int i, int m){
        if(m == 0) return true;
        if(i >= n) return false;
        boolean res = solve(i + 1, m) || solve(i + 1, m - A[i]);
        return res;
    }

}

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

int main() {
  int n;
  std::cin >> n;
  std::vector<int64_t> a(n);
  for (auto &i : a) {
    std::cin >> i;
  }

  std::vector<int64_t> b(n);
  for (int i = 0; i < n; i++) {
    b[i] = std::abs(a[i]);
  }

  auto get_max = [&](const auto s, const auto e) {
    int r = s;
    int64_t val = b[r];

    for (int i = s; i < e; i++) {
      if (val < b[i]) {
        r = i;
        val = b[i];
      }
    }
    return r;
  };

  int s = 0, e = n;

  while (s != e) {
    const auto i = get_max(s, e);
    if (0 < a[i]) {
      e = i;
    } else if (a[i] < 0) {
      s = i + 1;
    } else {
      s = e = i;
    }
  }

  std::vector<std::pair<int, int>> ans;
  for (int i = s - 1; 0 < i; i--) {
    if (a[i] < a[i - 1]) {
      ans.push_back({i, i - 1});
      a[i - 1] += a[i];
    }
    if (a[i] < a[i - 1]) {
      ans.push_back({i, i - 1});
      a[i - 1] += a[i];
    }
  }

  for (int i = e; i < n - 1; i++) {
    if (a[i + 1] < a[i]) {
      ans.push_back({i, i + 1});
      a[i + 1] += a[i];
    }
    if (a[i + 1] < a[i]) {
      ans.push_back({i, i + 1});
      a[i + 1] += a[i];
    }
  }

  std::cout << ans.size() << std::endl;
  for (const auto &i : ans) {
    std::cout << i.first + 1 << " " << i.second + 1 << std::endl;
  }

  return 0;
}

Measured memory_bytes: 256
def solve():
  from itertools import accumulate
  from sys import stdin
  
  f_i = stdin
  N, K = map(int, f_i.readline().split())
  A = map(int, f_i.readline().split())
  S = accumulate(a - 1 for a in A)
  S = (0, ) + tuple(s % K for s in S)
  
  rec = {}
  ans = 0
  for j, S_j in enumerate(S):
    if j >= K:
      rec[S[j-K]] -= 1
    if S_j in rec:
      ans += rec[S_j]
      rec[S_j] += 1
    else:
      rec[S_j] =1
  
  print(ans)

solve()

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

typedef long long ll;
typedef pair<int, int> P;

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;

int main(){
	ll n, k; cin >> n >> k;
	ll ans = 0;
	ll t = n / k;
	ans += t * t * t;
	if(k % 2 == 0){
		ll s = n / (k / 2) - t;
		ans += s * s * s;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll n,a;
 cin>>n>>a;
 a*=2;
 a++;
 cout<< n/a + ( n%a != 0 ) <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back
#define fi first
#define be begin()
#define en end()
#define se second

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

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; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int a,b;
  cin>>a>>b;
  cout<< max({a + b,a - b,a*b}) << endl;
  return 0;
}



Measured memory_bytes: 256
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons,std.numeric;
const dx = [1,0,-1,0], dy = [0,1,0,-1];
const readMixin = q{
	auto line = readln().split(); 
	if (line.length < args.length) return;
	foreach(i,ref arg; args) arg = line[i].to!(typeof(arg));
};
void read(T...)  (auto ref T args){ mixin(readMixin);}
void readArray(T)(auto ref T args){ mixin(readMixin);}
//------------------------------
const coin = [10,50,100,500];
void main(){	
	int total;
	for(read(total); total ; read(total), write(total ? "\n":"")){
		auto have = new int[4];
		readArray(have);
		int howMany = int.max; 
		auto uses = new int[4];
		foreach (I;cartesianProduct(iota(have[0]+1),iota(have[1]+1),iota(have[2]+1),iota(have[3]+1))){
			auto tmpuses = I.array;
			auto pay = coin.dotProduct(tmpuses);	
			if (pay < total) continue;
			int tmpHowMany = have.sum + howManyCoins(pay - total) - tmpuses.sum;
			if (tmpHowMany < howMany ){
				howMany = tmpHowMany;
				uses = tmpuses;
			}
		}
		foreach(i,u;uses){if(u >0)writeln(coin[i]," ",u);}
	}
}
int howManyCoins(int pay){
	int res;
	foreach_reverse(c;coin){
		while(pay >= c){ 
			pay -= c;res ++;
		}
	} 
	return res;
}

Measured memory_bytes: 3056
import math
n=int(input())
M=int(math.sqrt(n))
N=3

A=[]
def dfs(nums,length):
    if length==N:
        A.append(nums)
        return
    for i in range(1,M+1):
        new_nums=nums+[i]
        dfs(new_nums,length+1)
dfs([],0)

dp=[0 for i in range(n)]
for i,j,k in A:
    ans=i**2+j**2+k**2+i*j+j*k+k*i
    if ans<=n:
        if i==j and j==k:
            dp[ans-1]+=1
        elif i==j or j==k or k==i:
            dp[ans-1]+=1
        else:
            dp[ans-1]+=1
for i in dp:
    print(i)

Measured memory_bytes: 221112
import bisect
n = int(input())
l = list(map(int, input().split()))
sort_l = sorted(l)
count = 0

for a in range(n):
    for b in range(a+1, n):
        c = bisect.bisect_left(sort_l, sort_l[a] + sort_l[b])
        if c > b:
            count += c - b -1
        else:
            pass     
        

print(count)

Measured memory_bytes: 9372
#include <bits/stdc++.h>
const long long mod =1e9+7;
const long long inf =1e18;
using namespace std;
long long n;
long long a[101010];
int main() {
    cin>>n;
    for(int i=0;i<n;i++)
    {
    	cin>>a[i];
	}
    long long x=a[0];
	for(int i=1;i<n;i++)
	{
		x^=a[i];
	}
	if(x==0) 
	  cout<<"Yes"<<endl;
    else 
	  cout<<"No"<<endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
const ll MOD = 1e9+7;
vector<ll> f, invf;

template<class T> T powmod(T x, ll n, ll m)
{
    T r = 1;
    T a = x % m;
    while (n>0)
    {
        if (n & 1)
            r = (r*a)%m;
        a = (a*a)%m;
        n = n >> 1;
    }
    return r;
}

ll comb(int n, int k){
    return f[n] * invf[k] % MOD * invf[n-k] % MOD;
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int x, y;
    cin >> x >> y;

    f.resize(1e6+1);
    invf.resize(1e6+1);
    f[0] = invf[0] = 1;
    FOR1(i, 1e6) {
        f[i] = f[i - 1] * i % MOD;
        invf[i] = powmod(f[i], MOD-2, MOD);
    }

    ll sol = 0;
    for(int i=0; i<=x; i++){
        if((x-i)%2==0){
            int j = (x-i)/2;
            if (i*2 + j*1 == y){
                sol += comb(i+j, i);
            }
        }
    }
    cout << sol << endl;


    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
using Graph = vector<vector<int>>;

int main(){
	char s; cin >> s;
	cout << (char)(s + 1) << endl;
}

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

int main()
{
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int hoge = 0, ans = 0;
    for (int i = 0; i <= a; i++){
        for (int j = 0; j <= b; j++){
            for(int k = 0; k <= c; k++){
                hoge=500*i+100*j+50*k;
                if(hoge==x){
                    ans++;
                }
            }
        }
    }

    cout << ans;
    return 0;
}

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

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

    int n;
    cin >> n;
    pair<int, int> sdt[n];
    rep (i, n) {
        int a;
        cin >> a;
        sdt[i] = make_pair(a, i+1);
    }
    sort(sdt, sdt + n);
    rep (i, n) printf("%d ", sdt[i].second);
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            int[] num = Array.ConvertAll(str, new Converter<string, int>(s => int.Parse(s)));
            int swap = 0;

            for(int i=0;i<n;i++)
            {
                int mini = i;
                for (int j = i + 1; j < n; j++)
                    if (num[j] < num[mini]) mini = j;
                if (i != mini) { int tmp = num[i];num[i] = num[mini];num[mini] = tmp; swap++; } 
            }

            str = Array.ConvertAll(num, new Converter<int, string>(k => k.ToString()));
            Console.WriteLine(string.Join(" ",str));
            Console.WriteLine(swap);
        }
    }
}

Measured memory_bytes: 9056
N, Q = map(int, input().split())
S = list(input())
T = [0]
s = 0
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        s += 1
        T.append(s)
    else:
        T.append(s)
for i in range(Q):
    l, r = map(int, input().split())
    print(abs(T[l-1]-T[r-1]))


Measured memory_bytes: 6872
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    int ans = 0;
    rep(is, 1<<h) rep(js, 1<<w){
        int cnt = 0;
        rep(i, h)rep(j, w){
            if(is>>i & 1) continue;
            if(js>>j & 1) continue;
            if(s[i][j] == '#') cnt++;
        }
        if(cnt == k) ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 3584
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static boolean solve() {
		int n = in.nextInt();
		if (n == 0) return false;

		boolean f = false;
		boolean[] foot = new boolean[2];
		int cnt = 0;
		for (int i=0; i<n; i++) {
			String s = in.next();
			if ("lu".equals(s)) {
				foot[0] = true;
				if (foot[0] && foot[1] && !f) {
					cnt++;
					f = !f;
				}
			} else if ("ru".equals(s)) {
				foot[1] = true;
				if (foot[0] && foot[1] && !f) {
					cnt++;
					f = !f;
				}
			} else if ("ld".equals(s)) {
				foot[0] = false;
				if (!foot[0] && !foot[1] && f) {
					cnt++;
					f = !f;
				}
			} else {
				foot[1] = false;
				if (!foot[0] && !foot[1] && f) {
					cnt++;
					f = !f;
				}
			}
		}

		out.println(cnt);

		return true;
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		while(solve());
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

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

#define rep(i, n)  for (int i = 0; i < (n) ; ++i)
#define mod 1000000007

using namespace std;
using ll=long long;
const ll INF = 100000000;

int main() {
    int x, y;
    int t, c;
    bool res = false;
    cin >> x >> y;
    for (int i = 0; i <= x; ++i) {
        t = x - i;
        c = i;
        if (t * 4 + c * 2 == y) {
            res = true;
            break;
        }
    }
    if (res){
        cout << "Yes";
    }else{
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long maks = -1000000000000000001;
	long long a, b, c, d;
	cin>>a>>b>>c>>d;
	long long ans2 = a*c;
	maks = max(maks,ans2);
	long long ans3 = a*d;
	maks = max(maks,ans3);
	long long ans4 = b*c;
	maks = max(maks,ans4);
	long long ans5 = b*d;
	maks = max(maks,ans5);
	cout<<maks<<endl;
}


Measured memory_bytes: 3536