akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
////////////////////////////////////////////////
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
const ll MOD = 1000000007;  // 1e9+7
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n;
  cin >> n;
  vecll a(n, 0), b(n, 0);
  ll suma = 0;
  ll sumb = 0;
  REPe(e, a) {
    cin >> e;
    suma += e;
  }
  REPe(e, b) {
    cin >> e;
    sumb += e;
  }
  // cout << suma << " " << sumb << endl;
  ll num = sumb - suma;
  if (num < 0) {
    cout << "No" << endl;
    return 0;
  }
  ll na, nb;
  na = nb = 0;
  REP(i, n) {
    if (a[i] >= b[i]) {
      nb += a[i] - b[i];
      b[i] = a[i];
    } else {
      ll tmp = (a[i] + b[i]) % 2;
      na += (b[i] + tmp - a[i]) / 2;
      nb += tmp;
      a[i] = b[i] + tmp;
      b[i] += tmp;
    }
  }
  // cout << na << " " << nb << endl;
  // REP(i, n) cout << a[i] << " ";
  // cout << endl;
  // REP(i, n) cout << b[i] << " ";
  // cout << endl;
  if (num >= na && 2 * (num - na) == (num - nb)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
//////////////////////////////////////////////


Measured memory_bytes: 384
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE     ;
#define dumpV(v);
#define STOP     ;
#endif
#define mp make_pair

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}


int main(){
    int n, m;
    cin >> n >> m;
    vector<int> sum(n+2);
    rep(i, m) {
        int l, r;
        cin >> l >> r;
        sum[l]++;
        sum[r+1]--;
    }
    REP(i, 1, sum.size()) sum[i] += sum[i-1];
    int ans = 0;
    rep(i, sum.size()) if(sum[i] == m) ++ ans;
    cout << ans << endl;
    // dumpV(sum);
    return 0;
}

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

#define ll long long
const ll mod = 1e9+7;

ll qpow(ll a,ll x,ll p)
{
	ll t = a;
	a = 1;
	while (x)
	{
		if (x & 1) a = a * t % p;
		t = t * t % p;
		x = x >> 1;
	}
	return a;
}

ll C(int n,int a)
{
    ll c1 = 1,c2 = 1;
    for (int i = 1;i<=a;i++)
    {
        c1 = (c1 * (n - i + 1)) % mod;
        c2 = c2 * i % mod;
    }
    return c1 * qpow(c2,mod-2,mod) % mod;
}

int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    ll ans = (qpow(2,n,mod) - 1 + mod) % mod;
    ans = (ans - C(n,a) + mod) % mod;
    ans = (ans - C(n,b) + mod) % mod;
    cout<<ans;
    return 0;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

const int MOD=1e9+7;
vector<int> adj[100000];
int D[2][100000];

void solve(int c)
{
	D[0][c]=D[1][c]=1;
	for(auto n: adj[c]) {
		if(D[0][n]==-1) {
			solve(n);
			D[0][c]=(1LL*D[0][c]*(D[0][n]+D[1][n]))%MOD;
			D[1][c]=(1LL*D[1][c]*D[0][n])%MOD;
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int N;
	cin>>N;
	for(int i=1;i<N;i++) {
		int x, y;
		cin>>x>>y;
		adj[--x].push_back(--y);
		adj[y].push_back(x);
	}
	memset(D,-1,sizeof(D));
	solve(0);
	cout<<(D[0][0]+D[1][0])%MOD<<'\n';
	return 0;
}

Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
int main(){
	
int A;
int B;
scanf("%d%d",&A,&B);
if(A>=1&&A<=13&&B>=1&&B<=13){
if(A==1)
A=15;
if(B==1)
B=15;
if(A>B)
cout<<"Alice";
else if(A<B)
cout<<"Bob";
else
cout<<"Draw";
	
	
	
}
	
	
	
	
	
	
	
}


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

using namespace std;

namespace {
    int T, D;
    int ta, tb;
    int da, db;
    void input() {
        cin >> T >> D;
        cin >> ta >> tb;
        cin >> da >> db;
    }

    void solve() {
        double ans = min(abs(T - ta), abs(T - tb));
        for (int i = 0; i * da <= D; i++) {
            for (int j = 0; i * da + j * db <= D; j++) {
                if (i == 0 && j == 0) continue;
                double t = double(i * da * ta + j * db * tb) / (i * da + j * db);
                ans = min(ans, abs(T - t));
            }
        }
        printf("%.12f\n", ans);
    }
}

int main() {
    input(); solve();
    return 0;
}

Measured memory_bytes: 1192
N,W=map(int,input().split())
v=[]
w=[]

for i in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)

dp=[[0 for i in range(W+1)] for j in range(N+1)]

for i in range(N):
    for sum_w in range(W+1):
        #i+1番目の品物を選んだ場合
        if (sum_w-w[i])>=0:
            m=0

            m=dp[i][sum_w - w[i]]+v[i]

            dp[i+1][sum_w]=max(dp[i+1][sum_w],m)
        #i+1番目の品物を選ばなかった場合
        dp[i+1][sum_w]=max(dp[i][sum_w],dp[i+1][sum_w])

print(dp[-1][-1])


Measured memory_bytes: 173704
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
  set<int >s;
  for(int i=0,a;i<n;i++){
  	cin>>a;
    if(s.find(a)==s.end())s.insert(a);
    else s.erase(a);
  }
  cout<<s.size();
}

Measured memory_bytes: 8152
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
using namespace std;

int main() {
	char grid[110][110];
	int h, w;
	cin >> h >> w;
	int count = 0;
	int endline[110];
	for (int i = 0; i < 110; i++) {
		endline[i] = 1;
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == '.') {
				count++;
			}
		}
		if (count == w) {
			for (int j = 0; j < w; j++) {
				grid[i][j] = '0';
			}
			endline[i] =0;
		}
		count = 0;
	}
	for (int j = 0; j < w; j++) {
		for (int i = 0; i < h; i++) {
			if (grid[i][j] == '.' || grid[i][j] == '0') {
				count++;
			}
		}
		if (count == h) {
			for (int i = 0; i < h; i++) {
				grid[i][j] = '0';
			}
		}
		count = 0;
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (grid[i][j] != '0') {
				cout << grid[i][j];
			}
		}
		if (endline[i] == 1) {
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())

x = [0 for p in range(N)]
for i in range(N):
    x[i] = input().split()

sum = 0
for j in range(N):
    if x[j][1] == "JPY":
        sum += float(x[j][0])
    else:
        sum += float(x[j][0]) * 380000

print(sum)



Measured memory_bytes: 2940
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int size = Integer.parseInt(scan.nextLine());
        int[][] hap = new int[size][3];

        for (int i = 0 ; i < size ; i++) {
            String[] s = scan.nextLine().split(" ");
            hap[i][0] = Integer.parseInt(s[0]);
            hap[i][1] = Integer.parseInt(s[1]);
            hap[i][2] = Integer.parseInt(s[2]);
        }

        scan.close();

        for (int i = 1 ; i < size ; i++) {
            hap[i][0] = Math.max(hap[i-1][1],hap[i-1][2]) + hap[i][0];
            hap[i][1] = Math.max(hap[i-1][0],hap[i-1][2]) + hap[i][1];
            hap[i][2] = Math.max(hap[i-1][0],hap[i-1][1]) + hap[i][2];
        }

        System.out.print(Math.max(hap[size-1][0],Math.max(hap[size-1][1], hap[size-1][2])));
    }
}

Measured memory_bytes: 126688
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <climits>
#include <list>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

enum class Color {
                  Gray,
                  Blown,
                  Green,
                  Aqua,
                  Blue,
                  Yellow,
                  Orange,
                  Red,
                  Purple,
};

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

  int N; cin>>N;
  set<Color> dict;
  int free_color = 0;
  for(int i=0; i<N; i++) {
    int a; cin>>a;
    Color color;
    if(a <= 399) {
      color = Color::Gray;
    } else if(a <= 799) {
      color = Color::Blown;
    } else if(a <= 1199) {
      color = Color::Green;
    } else if(a <= 1599) {
      color = Color::Aqua;
    } else if(a <= 1999) {
      color = Color::Blue;
    } else if(a <= 2399) {
      color = Color::Yellow;
    } else if(a <= 2799) {
      color = Color::Orange;
    } else if(a <= 3199) {
      color = Color::Red;
    } else {
      color = Color::Purple;
      free_color++;
    }
    dict.insert(color);
  }

  int imin=0, imax=0;
  for(auto p: dict) {
    if(p != Color::Purple) {
      imin++;
      imax++;
    } else {
      if(imin <= 0) {
        imin++;
      }
      imax += free_color;
    }
  }

  cout << imin << " " << imax << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

char hw[100][100];
int dx[3]={-1,0,1};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  rep(i,100)rep(j,100)hw[i][j]='.';
  int h,w;cin>>h>>w;
  rep(i,h)rep(j,w)cin>>hw[i+1][j+1];
  repi(i,1,h+1)repi(j,1,w+1)
  {
    int cnt=0;
    rep(k,3)rep(l,3)
    {
      if(k==1&&l==1)continue;
      if(hw[i+dx[k]][j+dx[l]]=='#')cnt++;
    }
    if(hw[i][j]=='.')hw[i][j]=cnt+'0';
  }
  rep(i,h)
  {
    rep(j,w)cout<<hw[i+1][j+1];
    cout<<endl;
  }

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   string s, t;
   cin >> s >> t;
   cout << t << s << endl;
   return 0;
}

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

using namespace std;

int main()
{
  int input_num, num_list[100], cost, min_cost = -1, min_num, max_num;

  cin >> input_num;
  for (int i = 0; i < input_num; i++)
  {
    cin >> num_list[i];
  }

  min_num = max_num = num_list[0];
  for (int i = 0; i < input_num; i++)
  {
    if (min_num > num_list[i]) min_num = num_list[i];
    if (max_num < num_list[i]) max_num = num_list[i];
  }
  for (int j = min_num; j <= max_num; j++)
  {
    cost = 0;
    for (int k = 0; k < input_num; k++)
    {
      cost += (num_list[k] - j) * (num_list[k] - j);
    }
    if (cost < min_cost || min_cost == -1) min_cost = cost;
  }

  cout << min_cost;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll k,t;cin>>k>>t;
    vector<ll> a(t);
    rep(i,t) cin>>a[i];

    sort(a.begin(),a.end(),greater<ll>());
    ll sum=0;
    rep(i,t){
        if(i!=0) sum+=a[i];
    }

    cout<<max(0ll,a[0]-sum-1)<<endl;
    return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
int a[3][3];
int n;
int b[10];
bool appear[3][3];
int main(){
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin>>a[i][j];
        }
        
    }
    cin>>n;

    for (int i = 0; i < n; i++)
    {
        cin>>b[i];
    }

    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            appear[i][j]=false;
            for (int k = 0; k < n; k++)
            {
                if(b[k]==a[i][j]) appear[i][j] = true;
            }
            
        }
        
    }
    
    bool bingo = false;
    for (int i = 0; i < 3; i++)
    {
        if(appear[i][0]&&appear[i][1]&&appear[i][2]) bingo = true;
        if(appear[0][i]&&appear[1][i]&&appear[2][i]) bingo = true;
    }
    if(appear[0][0]&&appear[1][1]&&appear[2][2]) bingo = true;
    if(appear[0][2]&&appear[1][1]&&appear[2][0]) bingo = true;

    if(bingo) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <queue>
#include <cstring>
#define mp make_pair
#define pb push_back
#define p push

#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long int

#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld%lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);

#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define SIZE 1000000007
#define MAXN 100005

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph ;



int main(){
    IOS
ll n,d;
    cin >> n>>d;

    ll t = (n) /(2*d +1 );
    if(n % (2*d + 1) != 0)t++;
    cout << t;
    return 0;
}



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

int main(){
	while(true){
		int floor = 1;
		double vc;
		cin >> vc;
		if(cin.eof()) break;
		for(floor;vc*vc>19.6*(5*(double)floor-5);floor++) ;
		cout << floor << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;

string s;
int d,n,z;
ll dp[10001][101][2];
ll sol;

int main() {
    cin >> s >> d;
    n=s.size();
    dp[0][0][0]=1;
    for (int i=1;i<=n;i++) {
        for (int j=0;j<d;j++) {
            for (int k=0;k<10;k++) {
                for (int b=0;b<2;b++) {
                    if (k>(s[i-1]-'0') && b==0) {continue;}
                    int b2=b;
                    if (k<(s[i-1]-'0')) {b2=1;}
                    dp[i][(j+k)%d][b2]+=dp[i-1][j][b];
                    dp[i][(j+k)%d][b2]%=MOD;
                }
            }
        }
    }
    sol=(dp[n][0][0]+dp[n][0][1])%MOD;
    sol--;
    if (sol==-1) {sol=MOD-1;}
    cout << sol << endl;
}



Measured memory_bytes: 19380
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {

    const tmp = readln.split.to!(long[]);
    const N = tmp[0], K = tmp[1];

    const a = N/K;
    const b = (K&1) ? 0 : (N+K/2)/K;

    writeln(a^^3 + b^^3);
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

b=[]
for i in range(n):
    tmp=[i+1,a[i]]
    b.append(tmp)

b=sorted(b,key=lambda x:x[1])


ans=[]
for j in b:
    ans.append(j[0])

print(*ans)

Measured memory_bytes: 26976
#include<iostream>
using ll = long long;
using namespace std;

ll xor_0_to_n(ll n)
{
    ll a = n % 4;
    if(a == 0) return n;
    else if(a == 1) return 1;
    else if(a == 2) return n + 1;
    else return 0; 
}

int main()
{
    ll a, b;
    cin >> a >> b;
    cout << (xor_0_to_n(a - 1) ^ xor_0_to_n(b)) << endl;
    return 0;
}

Measured memory_bytes: 3552
n, k, q = gets.chomp.split.map(&:to_i)
a = []
q.times do
  a << gets.to_i
end

score = []
n.times do
  score << k
end

q.times do |i|
  score[a[i]-1] += 1
end

n.times do |i|
  tmp = score[i]-q
  if tmp > 0
    print "Yes\n"
  else
    print "No\n"
  end
end

Measured memory_bytes: 4148
#include<stdio.h>
#include<stdlib.h>
typedef long long ll;

int main() {
	ll w, h, n, x, y, a;
	scanf("%lld%lld%lld", &w, &h, &n);
	ll w1 = 0, w2 = w, h1 = 0, h2 = h;
	for (int i = 0; i < n; i++) {
		scanf("%lld%lld%lld", &x, &y, &a);
		switch (a) {
		case 1:
			if (x > w1) w1 = x;
			break;
		case 2:
			if (x < w2) w2 = x;
			break;
		case 3:
			if (y > h1) h1 = y;
			break;
		case 4:
			if (y < h2) h2 = y;
			break;
		}
	}
	if (w2 < w1 || h2 < h1) printf("0\n");
	else printf("%lld", (w2 - w1) * (h2 - h1));

	return 0;
}

Measured memory_bytes: 2152
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = ~~arg[0].split(" ")[0];
    const Y = ~~arg[0].split(" ")[1];
    
    for(let i=0; i<=N; i++) {
        for(let j=0; j<=N; j++) {
            let k = N - i - j;
            
            if(k < 0) continue;
            
            let price = (10000 * i) + (5000 * j) + (1000 * k);
            let bills = ~~i + ~~j + ~~k;
            
            if(Y === price && N === bills) {
                console.log(`${i} ${j} ${k}`);
                return;
            }
        }
    }
    
    console.log("-1 -1 -1");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
import math
from scipy.misc import comb

def com(s, t):
    mod = 10**9+7
    t = min(s-t, t)
    S = 1
    T = 1
    for i in range(t):
        S = ((s-i)*S)%mod
        T = ((i+1)*T)%mod
    return (S*pow(T, mod-2, mod))%mod

def main():
    n, k = map(int, input().split())
    mod = 10**9+7
    for i in range(1, k+1):
        print(comb(n-k+1, i, exact=True)*comb(k-1, i-1, exact=True)%mod)

if __name__=='__main__':
    main()

Measured memory_bytes: 25576
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	string s;
	int q, temp;
	cin >> s >> q;
	bool rev = false;
	for (int i = 0; i < q; i++){
		cin >> temp;
		if (temp == 1){
			if (rev == false) rev = true;
			else rev = false;
		}
		if (temp == 2){
			string p;
			cin >> temp >> p;
			if (temp == 1){
				if (rev == false){
					s.insert(0, p);
				}else{
					s+=p;
				}
			}else{
				if (rev == false){
					s+=p;
				}else{
					s.insert(0, p);
				}
			}
		}
	}
	if (rev == true) reverse(s.begin(), s.end());
	cout << s << endl;
	return 0;
}


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

int main() {
	int n;cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	long long ans=0;
	long long tans=0;
	if(n%2==0){
		for(int i=0;i<n/2-1;i++){
			ans-=a[i]*2;
		}
		ans-=a[n/2-1];
		ans+=a[n/2];
		for(int i=n/2+1;i<n;i++){
			ans+=a[i]*2;
		}
		cout<<ans<<endl;
		return 0;
	}
	for(int i=0;i<n/2-1;i++){
		ans-=a[i]*2;
	}
	ans-=a[n/2-1];
	ans-=a[n/2];
	for(int i=n/2+1;i<n;i++){
		ans+=a[i]*2;
	}
	tans=ans;
	ans=0;
	for(int i=0;i<n/2;i++){
		ans-=a[i]*2;
	}
	ans+=a[n/2+1];
	ans+=a[n/2];
	for(int i=n/2+2;i<n;i++){
		ans+=a[i]*2;
	}
	if(ans<tans)ans=tans;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n,k,ans=0;
    scanf("%lld%lld",&n,&k) ;
    if(k==0)
        ans=n*n;
    else
    {
        for(int b=k+1;b<=n;b++)
        {
            ans+=(n/b)*(b-k);
            if(n%b>=k)
                ans+=n%b-k+1;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m, s = LI()
G = [[] for _ in range(n)]
for _ in range(m):
    u, v, a, b = LI()
    G[u - 1] += [(v - 1, a, b)]
    G[v - 1] += [(u - 1, a, b)]

change = LIR(n)

def dijkstra(s):
    hq = [(0, 0, s)]
    dist = [[INF] * 2451 for _ in range(n)]
    dist[0][s] = 0
    while hq:
        t, u, coin = heappop(hq)
        if t > dist[u][coin]:
            continue
        dist[u][coin] = t
        if t + change[u][1] < dist[u][min(2450, coin + change[u][0])]:
            dist[u][min(2450, coin + change[u][0])] = t + change[u][1]
            heappush(hq, (t + change[u][1], u, min(2450, coin + change[u][0])))
        for v, c, d in G[u]:
            if coin - c >= 0 and t + d < dist[v][coin - c]:
                dist[v][coin - c] = t + d
                heappush(hq, (t + d, v, coin - c))
    return dist

D = dijkstra(min(2450, s))
for t in range(1, n):
    print(min(D[t]))

Measured memory_bytes: 102184
N = int(input())

keta = len(str(N))

count = 0
for k in range(1, keta+1, 2):
  if k != keta:
    count += (10**(k) - 10**(k-1))
  elif k == keta:
    count += (N - 10**(k-1) + 1)
    
print(count)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
//#define pw (ll)pow 
#define MAX 1000005
#define MOD (ll)1e9+7
using namespace std;

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

Measured memory_bytes: 3912
#include <stdio.h>
#include <stdlib.h>
 
#define newTree() ((PTREE)calloc(1, sizeof(TREE)))
 
int code[128] = { 0 };
 
typedef struct _tree {
    int flag;
    struct _tree *list[4];
} TREE, *PTREE;

void insert(PTREE root, char *str) {
    int i;
    if (*str == '\0') {
        root->flag = 1;
        return;
    }
    i = code[(int)*str];
    if (root->list[i] == NULL) {
        root->list[i] = newTree();
    }
    insert(root->list[i], str + 1);
}
 
int find(PTREE root, char *str) {
    int i;
    if (*str == '\0') {
        return root->flag;
    }
    i = code[(int)*str];
    if (root->list[i] == NULL) {
        return 0;
    }
    return find(root->list[i], str + 1);
}
 
int main(void) {
    int i, n;
    char cmd[20], str[20];
    PTREE root = newTree();
    code['A'] = 0;
    code['C'] = 1;
    code['G'] = 2;
    code['T'] = 3;
     
    scanf("%d", &n);
     
    for (i = 0; i < n; ++i) {
        scanf("%s %s", cmd, str);
        if (cmd[0] == 'i') {
            insert(root, str);
        } else if (find(root, str)) {
            printf("yes\n");
        } else {
            printf("no\n");
        }
    }
     
    return 0;
}

Measured memory_bytes: 16900
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define ll long long

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

	vector<pair<ll, ll>> arr(n);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i].first >> arr[i].second;
	}

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

	ll ans = 0;

	for (int i = 0; i < n; i++)
	{
		if (m >= arr[i].second)
		{
			ans += (arr[i].first * arr[i].second);
			m -= arr[i].second;
		}
		else 
		{
			ans += (m * arr[i].first);
			break;
		}

	}
	cout << ans << endl;

}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a*b >= c*d) {
		cout << a*b << endl;
	}
	else {
		cout << c*d << endl;
	}
}

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

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

    ll total = 0;
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        total += a;
    }

    ll ans = n - total;
    if (ans >= 0)
        cout << ans << endl;
    else
        cout << -1 << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
 
int n,pos;
int a[40];
int b[40];

void solve(int,int);				\


 
int main(){
  
  int i;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%d",&a[i]);
  }
  for(i = 0;i < n;i++){
    scanf("%d",&b[i]);
  }
  pos = 0;

  solve(0,n-1);
  
  printf("\n");

  return 0;
}



void solve(int l,int r){
  
  if(l > r)return;

  if(l == r){

    if(b[l] == a[0]){
      printf("%d",b[l]);
    }
    
    else printf("%d ",b[l]);

    pos++;

    return;
  }
 
  int x = a[pos];
  int i;
  
  pos++;

  for(i = l;i <= r;i++){
    
    if(b[i] == x)break;

  }
  
  solve(l,i-1);
  solve(i+1,r);
   
  if(x == a[0]){
    
    printf("%d",x);

  }
  else printf("%d ",x);
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (a >= b && a >= c) {
		for (int i = 0; i < k; i++) {
			a *= 2;
		}
		cout << a + b + c << endl;
		
	}
	else if (b >= a && b >= c) {
		for (int i = 0; i < k; i++) {
			b *= 2;
		}
		cout << a + b + c << endl;
	}
	else {
		for (int i = 0; i < k; i++) {
			c *= 2;
		}
		cout << a + b + c << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
int a,b;

while(1){scanf("%d %d",&a,&b);
         if(a==0 && b==0){break;}
         else if (a>b){printf("%d %d\n",b,a);}
         else {printf("%d %d\n",a,b);}
}
return 0;
}



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

using namespace std;
typedef long long ll;
const int N = 450;
const int mod = 1e9 + 7;

int n, C;
ll dp[N][N], sum[N][N];
ll A[N], B[N];

int main() {
	scanf("%d%d", &n, &C);
	for(int i = 1;i <= n; ++i) scanf("%lld", &A[i]);
	for(int i = 1;i <= n; ++i) scanf("%lld", &B[i]);
	for(int i = 1;i <= 400; ++i) {
		for(int j = 0;j <= 400; ++j) {
			if(j == 0) sum[i][j] = 1;
			else sum[i][j] = sum[i][j - 1] * i % mod;
		}
	}
	for(int j = 0;j <= 400; ++j) {
		for(int i = 1;i <= 400; ++i) {
			sum[i][j] += sum[i - 1][j];
			sum[i][j] %= mod;
		}
	}
	dp[0][0] = 1;
	for(int i = 1;i <= n; ++i) {
		for(int j = 0;j <= C; ++j) {
			for(int k = 0;k <= j; ++k) {
				dp[i][j] += dp[i - 1][j - k] * ((sum[B[i]][k] - sum[A[i] - 1][k] + mod) % mod);
				dp[i][j] %= mod;
			}
		}
	}
	cout << dp[n][C] << endl;
	return 0;
}

Measured memory_bytes: 6476
from math import atan2, degrees

a, b, x = map(int, input().split())

area1, area2 = x/a, a*b-x/a
if area1 <= area2:
    y = 2*area1/b
    angle = atan2(b, y)
else:
    y = 2*area2/a
    angle = atan2(y, a)

print(degrees(angle))


Measured memory_bytes: 3060
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main()
{
    const long long modNum = 1e9 + 7;
    int n;
    cin >> n;
    vector<long long> data(n);
    rep(i,n){
        long long tmp;
        cin >> tmp;
        data[i] = tmp % modNum;
    }
    /*
    rep(i,n){
        cout << data[i] << endl;
    }
    */
    long long rightSum = 0, tot = 0;
    rightSum = data[n-1];
    for(int i = n-2; i >= 0; i--){
        tot = (tot + data[i] * rightSum % modNum) % modNum;
        rightSum = (rightSum + data[i]) % modNum;
    }
    cout << tot << endl;
}

Measured memory_bytes: 4824
#include<stdio.h>
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b){
		printf("%d\n",c);
	}
	else if(b==c){
		printf("%d\n",a);
	}
	else{
		printf("%d\n",b);
	}
	return 0;
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

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

	void run() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] bit = new int[n];
		int[] len = new int[m];
		for (int i = 0; i < n; i++) {
			bit[i] = sc.nextInt();
		}
		for (int i = 0; i < m; i++) {
			len[i] = sc.nextInt();
		}
		int[] goal1 = new int[n];
		int[] goal2 = new int[n];
		boolean turn = false;
		int index = 0;
		for (int i = 0; i < m; i++) {
			turn = !turn;
			for (int j = 0; j < len[i]; j++) {
				goal1[index] = turn ? 1 : 0;
				goal2[index++] = turn ? 0 : 1;
			}
		}
		// debug(goal1);
		// debug(goal2);

		int[] p1 = new int[n];
		int[] p2 = new int[n];
		for (int i = 0; i < n; i++) {
			p1[i] = bit[i];
			p2[i] = bit[i];
		}
		// debug(p1);
		// debug(p2);
		int cnt1 = 0;
		for (int i = 0; i < n; i++) {
			if (p1[i] != goal1[i]) {
				int s = i;
				int t = -1;
				for (int j = i; j < n; j++) {
					if (p1[i] != p1[j]) {
						t = j;
						break;
					}
				}
				if (t != -1) {
					int tmp = p1[s];
					p1[s] = p1[t];
					p1[t] = tmp;
					cnt1 += t - s;
				}
			}
		}

		boolean able1 = true;
		for (int i = 0; i < n; i++) {
			if (p1[i] != goal1[i]) {
				able1 = false;
			}
		}
		int cnt2 = 0;
		for (int i = 0; i < n; i++) {
			if (p2[i] != goal2[i]) {
				int s = i;
				int t = -1;
				for (int j = i; j < n; j++) {
					if (p2[i] != p2[j]) {
						t = j;
						break;
					}
				}
				if (t != -1) {
					int tmp = p2[s];
					p2[s] = p2[t];
					p2[t] = tmp;
					cnt2 += t - s;
				}
			}
		}
		boolean able2 = true;
		for (int i = 0; i < n; i++) {
			if (p2[i] != goal2[i]) {
				able2 = false;
			}
		}
		int one = 0;
		int zero = 0;
		int one1 = 0;
		int zero1 = 0;
		int one2 = 0;
		int zero2 = 0;
		for (int i = 0; i < n; i++) {
			if (bit[i] == 0) {
				zero++;
			} else {
				one++;
			}
			if (goal1[i] == 0) {
				zero1++;
			} else {
				one1++;
			}
			if (goal2[i] == 0) {
				zero2++;
			} else {
				one2++;
			}
		}
		if (zero != zero1 || one != one1) {
			able1 = false;
		}
		if (zero != zero2 || one != one2) {
			able2 = false;
		}
		if (!able1 && !able2) {
			System.out.println(0);
		} else {
			if (!able1 && able2) {
				System.out.println(cnt2);
			} else if (able1 && !able2) {
				System.out.println(cnt1);
			} else {
				System.out.println(Math.min(cnt1, cnt2));
			}
		}
	}

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

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

Measured memory_bytes: 17372
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define fi first
#define se second
#define MP make_pair

int read()
{
    int v = 0, f = 1;
    char c = getchar();
    while (c < 48 || 57 < c) {if (c == '-') f = -1; c = getchar();}
    while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
    return v * f;
}

bitset<410> c[410];

int n, m, a[101000], b[101000], ans, d[410];

int main()
{
    n = read(), m = read();
    for (int i = 1; i <= m; i++)
        a[i] = read(), b[i] = read();
    for (int i = 1; i <= n; i++)
    {
        c[i][i] = 1;
        for (int j = m; j >= 1; j--)
            if (c[i][a[j]] && c[i][b[j]])
            {
                d[i] = 1;
                break;
            } else
                if (c[i][a[j]] && !c[i][b[j]])
                    c[i][b[j]] = 1;
                else
                    if (!c[i][a[j]] && c[i][b[j]])
                        c[i][a[j]] = 1;
    }
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++)
            if (!d[i] && !d[j])
                if ((c[i] & c[j]).count() == 0)
                    ans++;
    printf("%d\n", ans);
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main {
    public static MyScanner scan;
    public static PrintWriter out;
    public static void main(String[] args) {
        scan=new MyScanner();
        out=new PrintWriter(new BufferedOutputStream(System.out));

        int t=1;
//        int t=scan.nextInt();
        while(t-->0) {

            long[] a=new long[4];
            for(int c=0;c<4;c++) a[c]=scan.nextLong();
            out.println(Math.max(a[0]*a[3],Math.max(a[0]*a[2],Math.max(a[1]*a[2],a[1]*a[3]))));

        }
        out.close();
    }



    //scanner
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 25400
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod = 1000000007;
const ll INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> ans(n);
    rep(i,k){
        int d;
        cin >> d;
        rep(j,d){
            int a;
            cin >> a;
            a--;
            ans[a] = 1;
        }
    }
    ll s = 0;
    rep(i,n){
        if(ans[i]==0) s++;
    }
    cout << s << endl;
    
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>

#define INF 10e10
#define REP(i,n) for(int i=0; i<n; i++)
#define REP_R(i,n,m) for(int i=m; i<n; i++)

using namespace std;

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

ll N;
ll m;

int count_digits(ll n) {
  int digits = 0;

  while (n > 0) {
    n /= 10;
    digits++;
  }

  return digits;
}


int main() {
  cin >> N;
  ll n = N;
  int count = 0;
  int ans = 100;

  for (ll i = 1LL; i * i <= N; i++) {

    if (N % i) continue;
    n = N / i;

    count = max(count_digits(i), count_digits(n));

    if (count < ans) {
      ans = count;
    }

  }

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


Measured memory_bytes: 256
//ALL GLORY TO JESUS CHRIST 
#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;

#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=(int)(n-1); i>=0; --i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )

const int MOD = (int)1e9+7;

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
}
//modular inverse
//inv(a,m) - inverse of a mod m
template <class T>
inline T inv(T a, T m){
 return 1<a ? m - inv(m%a, a)*m/a : 1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef LOCAL
    clock_t tStart = clock();
#endif
    int n; cin >> n;
    int d[n];
    forn(i, n) cin >> d[i];
    ll res = 0;
    forn(i, n) {
        forab(j, i+1, n-1) 
            res += d[i] * d[j];
    } 

    cout << res << "\n";
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * (clock() - tStart)/ CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  ABC
//
//  Created by Amarsanaa Davaasuren on 2019/08/31.
//  Copyright © 2019 Amarsanaa Davaasuren. All rights reserved.
//

#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)

using namespace std;
using ll = long long;


int main(){
    string S; cin >> S;
    int ans = 0;
    rep(i,S.size()) if (S[i] == '+') ans++;else ans--;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n,k,i,l,r,zero=-1;
	long min=5000000000,ans;
	scanf("%d%d",&n,&k);
	int x[n];
	for(i=0;i<n;i++){
		scanf("%d",&x[i]);
		if(x[i]>=0 && zero==-1)
			zero=i;
	}
	if(zero==-1){
		printf("%d",(-1)*x[n-k]);
		return 0;
	}
	if(zero<=k && zero+k<=n){
		for(i=0;i<=zero;i++){
			l=x[i];
			r=x[i+k-1];
			if(l>0)
				l=0;
			if(r<0)
				r=0;
			ans=(-2)*l+r;
			if(ans<min)
				min=ans;
			ans=(-1)*l+2*r;
			if(ans<min)
				min=ans;
		}
	}
	else if(zero<=k && zero+k>n){
		for(i=0;i<=n-k;i++){
			l=x[i];
			r=x[i+k-1];
			if(l>0)
				l=0;
			if(r<0)
				r=0;
			ans=(-2)*l+r;
			if(ans<min)
				min=ans;
			ans=(-1)*l+2*r;
			if(ans<min)
				min=ans;
		}
	}
	
	else if(zero>k && zero+k<=n){
		for(i=zero-k;i<=zero;i++){
			l=x[i];
			r=x[i+k-1];
			if(l>0)
				l=0;
			if(r<0)
				r=0;
			ans=(-2)*l+r;
			if(ans<min)
				min=ans;
			ans=(-1)*l+2*r;
			if(ans<min)
				min=ans;
		}
	}
	else if(zero>k && zero+k>n){
		for(i=zero-k;i<=n-k;i++){
			l=x[i];
			r=x[i+k-1];
			if(l>0)
				l=0;
			if(r<0)
				r=0;
			ans=(-2)*l+r;
			if(ans<min)
				min=ans;
			ans=(-1)*l+2*r;
			if(ans<min)
				min=ans;
		}
	}
	printf("%ld",min);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) a.begin(),a.end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define INF 1e9
typedef long long ll;

int N,M;

int dfs(int i, int cnt,
    bitset<500> cur, vector<bitset<500>> &bs){
    if(N == i){
        return cur.count() == 0 ? cnt : 0;
    }
    return max(dfs(i+1,cnt,cur,bs), dfs(i+1,cnt+1,cur^bs[i],bs));
}

int solve2(vector<bitset<500>> &bs){
    using P = pair<int,int>;
    vector<P> cur = {{0,0}};
    rep(i,N){
        vector<P> nxt;
        int bit = bs[i].to_ullong();
        for(P p : cur){
            nxt.push_back(p);
            int mask = p.first;
            int cnt = p.second;
            nxt.push_back({mask^bit, cnt+1});
        }
        sort(all(nxt),greater<P>());
        cur.clear();
        int n = nxt.size();
        cur.push_back(nxt[0]);
        rep(j,n-1){
            if(nxt[j].first != nxt[j+1].first){
                cur.push_back(nxt[j+1]);
            }
        }
    }
    int res = 0;
    for(P p : cur){
        int mask = p.first;
        int cnt = p.second;
        if(mask == 0){
            res = max(res,cnt);
        }
    }
    return res;
}

int main(void){
    while(cin>>N>>M, N|M){
        vector<bitset<500>> bs(N);
        rep(i,N) cin>>bs[i];
        if(N <= 23){
            cout<<dfs(0,0,bitset<500>(""),bs)<<endl;
        }else{
            cout<<solve2(bs)<<endl;
        }
    }
    return 0;
}

// int main(void){
//     bitset<500> bs("1111000101010101010");
//     cout<<bs<<endl;
//     return 0;
// }


Measured memory_bytes: 13128
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
L = LI()

count = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i]+L[j] > L[k] and L[i]+L[k] > L[j] and L[j]+L[k] > L[i]:
                if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                    count += 1

print(count)

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

#define endl '\n'

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

    string s;
    cin >> s;
    bool yes = false;
    int cnt = 1;
    for(int i = 1; i < 4; i++) {
        if(s[i - 1] == s[i]) cnt++;
        else cnt = 1;
        if(cnt >= 3) yes = true;
    }
    cout << (yes ? "Yes" : "No");

    return 0;
}

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

namespace ITP1
{
    class ITP1_7_C
    {
        static void Main(string[] args)
        {
            int r, c;
            int[,] spreadSheet;
            int[] readLine;
            int[,] spreadSheetSum;
            string outputLine;

            readLine = Console.ReadLine().Split().Select(int.Parse).ToArray();
            r = readLine[0];
            c = readLine[1];
            spreadSheet = new int[r, c];
            spreadSheetSum = new int[r + 1, c + 1];

            for (int i = 0; i < r; i++)
            {
                readLine = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < c; j++)
                {
                    spreadSheetSum[i, j] = readLine[j];
                    spreadSheetSum[i, c] += readLine[j];
                    spreadSheetSum[r, j] += readLine[j];
                    spreadSheetSum[r, c] += readLine[j];
                }
            }

            for (int i = 0; i < r + 1; i++)
            {
                outputLine = "";
                for (int j = 0; j < c + 1; j++)
                {
                    outputLine += $" {spreadSheetSum[i, j]}";
                }
                Console.WriteLine(outputLine.Trim());
            }
            Console.ReadLine();
        }
    }
}



Measured memory_bytes: 18460
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, x) = (2 * v[0] - 1, v[1]);
    if x == 1 || x == n {
        println!("No");
        return;
    } else {
        println!("Yes");
    }
    let mut answers = vec![0; n];
    answers[n / 2] = x;
    answers[n / 2 - 1] = x - 1;
    answers[n / 2 + 1] = x + 1;

    if n >= 5 {
        if x >= 3 {
            answers[n / 2 + 2] = x - 2;
        } else {
            answers[n / 2 - 2] = 4;
        }
    }

    let mut used = HashSet::new();
    for &ans in answers.iter() {
        used.insert(ans);
    }
    let mut not_used = vec![];
    for i in 1..n + 1 {
        if !used.contains(&i) {
            not_used.push(i);
        }
    }
    let mut pointer = 0;
    for i in 0..n {
        if answers[i] == 0 {
            answers[i] = not_used[pointer];
            pointer += 1;
        }
    }

    for ans in answers {
        println!("{}", ans);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 9724
/*a,bの積の偶奇を判定する*/

        function main(input){
            const args = input.split(' ');
            const a = parseInt(args[0],10);
            const b = parseInt(args[1],10);
            

            if (( a * b ) % 2 === 0 ){
                console.log('Even');
            } else {
                console.log('Odd');
            }  
         }
          
          const input = require('fs').readFileSync('/dev/stdin', 'utf8');
      main(input);

Measured memory_bytes: 20680
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef dsu uf;
typedef fenwick_tree<ll> fw;

const ll mod=1e9+7;
const ll inf=1e18;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()


int op(int a, int b) {return max(a, b);}
 
int e() {return -1;}
 
int x;
bool f(int b) {return b < x;};
 

void solve(){
 int n,q;
  cin >> n >> q;
 vector<int> a(n);
  rep(i,0,n) cin >> a[i];
  
  segtree<int, op, e> st(a);
  while(q--){
   ll t,l,r;
    cin >> t >> l >> r;
    if(t==1) st.set(l-1,r);
    else if(t==2) cout << st.prod(l-1, r) << endl;
    else {
      x = r;
      cout << st.max_right<f>(l - 1) + 1 << endl;
    }
    
  }
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 6084