akhauriyash/Code-Regression huggingface dataset:
NMC = list(map(int,input().split()))
N=NMC[0]
M=NMC[1]
C=NMC[2]
B=list(map(int,input().split()))
A = [list(map(int,input().split())) for l in range(N)]
cnt=0

for i in range(N):
    summary=0
    for j in range(M):
        summary=A[i][j]*B[j]+summary
    summary=summary+C
    if summary>0:
        cnt=cnt+1

print(cnt)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long

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

int main () {
    int n, m, a, b;
    cin >> n >> m;
    dsu d(n);
    rep(i, m) {
        cin >> a >> b;
        a--;
        b--;
        d.merge(a,b);
    }
    int cnt = d.groups().size();
    int ans = cnt - 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9028
#include <cmath>
#include <cstdio>

using namespace std;

double deg2rad(int degree) {
  return degree / 360.0 * 2 * M_PI;
}

int main() {
  double x = 0, y = 0;
  int length, degree;
  int direction = 90;

  while (true) {
    scanf("%d,%d", &length, &degree);
    if (length == 0 && degree == 0) { break; }

    double rad = deg2rad(direction);
    x -= length * cos(rad);
    y += length * sin(rad);

    direction += degree;
  }

  printf("%d\n%d\n", static_cast<int>(x), static_cast<int>(y));

  return 0;
}

Measured memory_bytes: 1032
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll>a(n);
    ll cnt=0,cp=0;
    rep(i,n)cin>>a[i];
    rep(i,n)for(int j=i;j<n;++j)if(a[i]>a[j])++cnt;//A1つ当たりの転倒数
    rep(i,n)rep(j,n)if(a[i]>a[j])++cp;//Aの中で何番目の大きさか
    ll b=k*(k-1)/2;
    b%=mod;
    b*=cp;
    b%=mod;
    b%=mod;
    ll ans=b+cnt*k;
    ans%=mod;
    cout<<ans<<endl;
    return 0;
}

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

char str[SIZE];

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  int a = 0, b = 0, ba = 0;
  for (int i = 0; i < n; i++) {
    cin >> str;
    int L = strlen(str);
	for (int j = 0; j + 1 < L; j++) {
	  if (str[j] == 'A' && str[j + 1] == 'B') cnt++;
	}
	if (str[0] == 'B') b++;
	if (str[L - 1] == 'A') a++;
	if (str[0] == 'B' && str[L - 1] == 'A') ba++;
  }
  cnt += min(a,b);
  if (a == ba && b == ba && b > 0) cnt--;
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <bitset>
using namespace std;

const int N = 2050;
typedef bitset<N * N> bs;

int main() {
    int n;
    scanf("%d", &n);
    bs cur;
    cur[0] = 1;
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        cur |= cur << a;
    }
    vector<int> X;
    for (int i = 1; i < N * N; i++) {
        if (cur[i]) X.push_back(i);
    }
    printf("%d\n", X[((int)X.size() - 1) / 2]);
}


Measured memory_bytes: 11628
package main

import (
	"fmt"
)

func main() {

	var N int
	fmt.Scanf("%d", &N)

	var count int = 0
	for i := 1; i <= N; i++ {
		if i%2 != 0 {
			count++
		}
	}

	fmt.Println(float64(count) / float64(N))
}


Measured memory_bytes: 1832
n = int(input())
a = list(map(int, input().split()))
count = 1
k = 10 ** 18
if 0 in a :
  count=0
else :
  for item in a:
    count = count * item
    if count > k:
      break

if count > k:
  print('-1')
else:
  print(count)


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, m, c[100000];

int main() {
	cin >> n >> m;
	inc(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		c[a]++;
		c[b]++;
	}
	
	bool flag = true;
	inc(i, n) {
		if(c[i] % 2 == 1) { flag = false; break; }
	}
	cout << (flag ? "YES" : "NO") << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define M1 1000000007
#define M2 998244353

#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define bfl(i,a,b) for(ll i=b-1;i>=a;i--)
#define f(i,n)     for(int i=0;i<n;i++)
#define bf(i,n)    for(int i=n-1;i>=0;i--)
#define f1(i,n)    for(int i=1;i<=n;i++)
#define bf1(i,n)   for(int i=n;i>=1;i--)

#define all(v) v.begin(),v.end()
#define pll pair<long,long>
#define pii pair<int,int>



#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define bn "\n"

//------------------------------------------------------------------------ 
// #define V(a) vector<a>
// #define vt() vector< tuple < int ,int ,int > > ;
// #define vector< int ,int > pv;
// vector< pair <int,int> > vect;


//------------------------------------------------------------------------

ll modI(ll a,ll m);
ll gcd(ll a,ll b);
ll powM(ll x,ll y,ll m);
ll swap(ll a,ll b);

void swap(ll& a,ll& b)
{
    ll tp=a;
    a=b;
    b=tp;
}

ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powM(ll x,ll y,ll m)
{
    ll ans=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            ans*=x;
            ans%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return ans;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

//---------------------------------------------------------------------------

// variable = Expression1 ? Expression2 : Expression3
// max = (n1 > n2) ? n1 : n2; 
// (n>m) ? cout<<"True"<<endl:cout<<"false"<<endl ;

// ---------------------------------------------------------------------------	

// int n;cin>>n;int a[n];for(int i=0;i<n;i++)cin>>a[i];    
// for(int i=0;i<n;i++)cout<<a[i];
// int a,b;cin>>a>>b;   

//----------------------------------------------------------------------------

// vector< tuple < int ,int ,int > > tv;
// vector< int ,int > pv;


//----------------------------------------------------------------------------


int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int tt=1;
   // cin>>tt;
	while(tt--)
	{
	   int a[3],k;
	   
	   f(i,3)cin>>a[i];cin>>k;
	   int c1=0;
	   while(a[0]>=a[1])
	   {
	       a[1]=a[1]*2;
	       c1++;
	   }
	   while(a[1]>=a[2])
	   {
	       a[2]=a[2]*2;
	       c1++;
	   }
	  if(c1<=k)
	  {
	      cout<<"Yes"<<bn;
	  }
	  else
	  cout<<"No"<<bn;
	    
	}
	
	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
int main(){
	int n,sum=0;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		
	}
	
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			sum+=a[i]*a[j];
		}
	}
	printf("%d",sum);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    final int h = sc.nextInt();
    final int w = sc.nextInt();
    final int a = sc.nextInt();
    final int b = sc.nextInt();
    sc.close();
    StringBuilder sb = new StringBuilder();
    for(int i=0;i<h;i++) {
    	for(int j=0;j<w;j++) {
    		if((i<b)^(j<a)) {
    			sb.append("1");
    		}else {
    			sb.append("0");
    		}
    	}
    	sb.append("\n");
    }
    System.out.println(sb.toString());
  }
}

Measured memory_bytes: 32240
#include<iostream>
using namespace std;
int main()
{
    int n,k,ans=1;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        if(ans>k)
        ans+=k;
        else 
        ans*=2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;
 
typedef long long ll;
typedef pair < int , int > ii;
 
int a,b,temp,ans;
 
int main()
{
    cin >> a >> b;
    for (int i = 0; i < b; ++i)
    {
        cin >> temp;
        ans += temp;
    }
    if(ans >= a)
        cout << "Yes";
    else
        cout << "No";

    return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
    int N;
    cin >> N;
    int V[N], C[N];
    for(int i = 0; i < N; ++i) cin >> V[i];
    for(int i = 0; i < N; ++i) cin >> C[i];
    int D[N];
    for(int i = 0; i < N; ++i) D[i] = V[i] - C[i];
    int ans = 0;
    for(int i = 0; i < N; ++i){
        if(D[i] > 0) ans += D[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;  

  return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>
#define L 100005

typedef struct pp{
  char name[100];
  int t;
}A;

A deq();
void enq(A x);
A Q[L];
int t,h, n;

int min(int a,int b){ return a<b ? a : b;}

int main(){

  int elaps=0, c;
  int i, q;
  A u;

  scanf("%d %d", &n, &q);

  for(i=1;i<=n;i++){
    
    scanf("%s",Q[i].name);

    scanf("%d",&Q[i].t);

  }
  
  h=1; t=n+1;

  while(h !=t){

    u=deq();
    c=min(q, u.t);
    u.t -=c;
    elaps+=c;
    if(u.t>0) enq(u);
    else{
      printf("%s %d\n",u.name, elaps);
    }
  }

  return 0;
}



A deq(){
  A x =Q[h];
  h = (h+1)%L;
  return x;
}

void enq(A x){
  Q[t]=x;
  t=(t+1)%L;
}



Measured memory_bytes: 11884
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using ll = long long;
using namespace std;

int main() {
	int W, A, B;
	cin >> W >> A >> B;
	if (A + W <= B) {
		cout << B - (A + W)<< endl;
	}
	else if (B + W <= A) {
		cout << A - B - W << endl;
	}
	else {
		cout << 0 << endl;
	}
}

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

int main() {
    long long x;
    cin >> x;
    long long goldBig = 0;
    long long goldSmall = 0;
    
    while (x >= 500){
        goldBig ++;
        x = x - 500;
    }
    
    while (x >= 5){
        goldSmall++;
        x = x - 5;
    }
    
    long long happy;
    happy = (goldBig * 1000) + (goldSmall * 5);
    
    cout << happy << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(){
    string s;
    cin >> s;
    int a_index=0;
    int z_index=0;
    for (int i=0;i<s.size();++i){
        if (s[i] == 'A') {
            a_index = i;
            break;
        }
    }
    for (int i=0;i<s.size();++i){
        if (s[i] == 'Z') z_index = i;
    }
    cout << z_index - a_index + 1 << endl;
}

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

int main() {
  int N;
  int A[100005];
  int i, j;
  pair<int, int> p[100005];
  cin >> N;
  for (i = 0; i < N; i++) {
    cin >> A[i];
    p[i] = make_pair(A[i], i+1);
  }
  sort(p, p+N);
  for (i = 0; i < N; i++)
    cout << p[i].second << endl;
}

Measured memory_bytes: 2048
// author : Kartikey Tewari
// date: 2020-02-09   20:28:12
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl '\n'
using namespace std;

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

    string a,b,c;
    int count_a,count_b;
    cin >> a >> b >> count_a >> count_b >> c;
    if (c==a)
    {
        cout << count_a-1 << " " << count_b << endl;
    }
    else
    {
        cout << count_a << " " << count_b-1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string s[100];
  for (int i = 0; i < N; i++) cin >> s[i];
  
  int M;
  cin >> M;
  string t[100];
  for (int i = 0; i < M; i++) cin >> t[i];
  
  int reward = 0;
  for (int i = 0; i < N; i++)
  {
    int tmp = 0;
    string word = s[i];
  	for (int j = 0; j < N; j++)
    {
    	if (word == s[j]) tmp++;
    }
    for (int j = 0; j < M; j++)
    {
    	if (word == t[j]) tmp--;
    }
    reward = max(reward, tmp);
  }
  
  cout << reward << endl;
}

Measured memory_bytes: 256
n,m = gets.chomp.split(" ").map{|item| item.to_i}
a = Array.new(n).map{ Array.new(m,0) }
b = Array.new(m,0)
n.times do |i|
    a[i] = gets.chomp.split(" ").map{|item| item.to_i}
end

m.times do |i|
    b[i] = gets.chomp.to_i
end

c = Array.new(n,0)

n.times do |i|
    m.times do |j|
        c[i]+=a[i][j]*b[j]
    end
    print(c[i],"\n")
end

Measured memory_bytes: 8968
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    cout << N / 3 << endl;

    return 0;
}


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

int n, k;
int S[200005];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> S[i];
        S[i] += S[i - 1] - 1;
        S[i] %= k;
    }
    map<int, int> cnt;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i - k >= 0) cnt[S[i - k]]--;
        cnt[S[i - 1]]++;
        ans += cnt[S[i]];
    }
    cout << ans;
}

Measured memory_bytes: 10368
n = int(input())
 
num = {}
for i in range(n):
    a = input()
    if a in num:
        num[a] += 1
    else:
        num[a] = 1
 
t = 0
for i in num.keys():
    if num[i] % 2:
        t += 1
 
print(t)

Measured memory_bytes: 17880
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }

    vector<int> b(n);
    vector<int> ans;
    int m = 0;
    for(int i=n; i>=1; --i){
        int cnt = 0;
        for(int j=i; j<=n; j+=i){
            if(b[j-1]){
                cnt++;
            }
        }
        if(a[i-1]%2 == 0){
            if(cnt % 2 != 0){
                b[i-1] = 1;
                ans.push_back(i);
                m++;
            }
        }
        else{
            if(cnt % 2 == 0){
                b[i-1] = 1;
                ans.push_back(i);
                m++;
            }
        }
    }
    cout << m << endl;
    rep(i, m){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>

using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
ll a[11234567];
//std::ios::sync_with_stdio(0); std::cin.tie(0);
int main() {
	ll n, i, t, ans = 0, j;
	cin >> n;
	ll q;
	for (i = 1; i <= n; ++i) {
		for (j = i; j <= n; j+=i) {
			++a[j];
		}
	}
	for (i = 1; i <= n; ++i)ans += i * a[i];
	cout << ans << endl;
}

Measured memory_bytes: 81748
h = int(input())
w = int(input())
n = int(input())
a = b = 100000000
for i in range(h+1):
    if n <= i * w:
        a = i
        break
for i in range(w+1):
    if n <= i * h:
        b = i
        break
print(min(a,b))

Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#include <ctime>
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define eps 1.0e18
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define memset(x,y) memset(x,y,sizeof(x))
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
#define ll long long
using namespace std;
const int maxn = 1e7+5;

ll divisor_num[maxn];
void init(ll n){
    for(int i = 1; i <= n; i++)
    {
        divisor_num[i]++;
       for(int j = i * 2; j <= n; j += i)
            divisor_num[j]++;
    }
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("text1.in","r",stdin);
	//freopen("text1.out","w",stdout);
	ll n;
	cin>>n;
//	clock_t startTime,endTime;
//    startTime = clock();//计时开始
	init(n);
	ll ans=0;
	for(ll i=1;i<=n;i++) {
		ans+=i*divisor_num[i];
	}
	cout<<ans<<endl;
//	endTime = clock();//计时结束
//    cout << "The run time is: " <<(double)(endTime - startTime) / CLOCKS_PER_SEC << "s" << endl;
	return 0;
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  int l = 1, r = 1e5;
  for (int i = 0; i < m; i++)
  {
    int t_l, t_r;
    cin >> t_l >> t_r;
    l = max(l, t_l);
    r = min(r, t_r);
  }
  if (l <= r)
    cout << r - l + 1 << endl;
  else cout << "0" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  vector<int> l(n);
  for(auto&& e:l)
  {
    cin>>e;
  }
  sort(l.begin(), l.end());
  int ans = 0;
  for (int i = 0; i < n; ++i)
  {
    for (int j = i+1; j < n; ++j)
    {
      auto itr = lower_bound(l.begin(), l.end(),l[i]+l[j]);
      int k = itr-l.begin();
      ans += max(k-j-1,0);
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
#### import ####
import sys
import math
from collections import defaultdict

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

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

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

N,A,B,C = II()
l = [I() for _ in range(N)]
inf = float('inf')

def solve(cur,a,b,c):
    if cur==N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf
    ret0 = solve(cur+1,a,b,c)
    ret1 = solve(cur+1,a+l[cur],b,c)+10
    ret2 = solve(cur+1,a,b+l[cur],c)+10
    ret3 = solve(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)

print(solve(0,0,0,0))

Measured memory_bytes: 45020
def divisor(n):
    div=[]
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            div.append(i)
            if i != n / i:
                div.append(n / i)
    return div

n = int(input())
ans = len(divisor(n - 1)) - 1
for i in divisor(n):
    if i == 1:
        continue
    m = n
    while m % i == 0:
        m /= i
    if m % i == 1:
        ans += 1

print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    int H, W;

    cin >> H >> W;

    while (H || W)
    {
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if ((i + j) % 2 == 0)
                {
                    cout << '#';
                }
                else
                {
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W;
    }

    return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int N,M;
	cin>>N>>M;
	int G[10][10];
	rep1(i,N)rep1(j,N)G[i][j]=0;
	rep(i,M){
		int a,b;
		cin>>a>>b;
		G[a][b]=1;
		G[b][a]=1;
	}
	int p[10];
	rep(i,N-1)p[i]=i;
	int ans=0;
	do{
		int path=1;
		path*=G[1][p[0]+2];
		rep1(i,N-2)path*=G[p[i-1]+2][p[i]+2];
		ans+=path;
	}while(next_permutation(p,p+(N-1)));
	cout<<ans;
}

Measured memory_bytes: 256
import math
A, B, H, M = map(int, input().split())

if 30 * H + (30 * M / 60) == 6 * M:
    kakudo = 0
elif 30 * H + (30 * M / 60) > 6 * M:
    kakudo = 30 * H - 6 * M + (30 * M / 60) 
elif 30 * H + (30 * M / 60) < 6 * M:
    kakudo = 6 * M - 30 * H - (30 * M / 60)

ans = A ** 2 + B ** 2 - 2 * A * B * math.cos(math.radians(kakudo))

print(ans ** (1/2))

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

typedef long long LL;
const int maxn = 100010;
const LL mod = 1e9 + 7;
const LL INF = 100000000000000LL;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define FOR(c,a,b) for(int c=a;c<=b;++c)
const double PI = acos(-1.0);

char mp[55][55];

int solve() {
	int h, w;
	cin >> h >> w;
	for(int i = 1;i <= h;i++) {
		cin >> mp[i] + 1;
	}
	int ok = 1;
	for(int i = 1;i <= h && ok;i++) 
		for(int j = 1;j <= w && ok;j++) {
			if(mp[i][j] == '#') {
				if(mp[i][j - 1] == mp[i][j]) ok = 1;
				else if(mp[i][j + 1] == mp[i][j]) ok = 1;
				else if(mp[i - 1][j] == mp[i][j]) ok = 1;
				else if(mp[i + 1][j] == mp[i][j]) ok = 1;
				else ok = 0;
			}
		}
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

int main() {
	LL t = 1e18;
	//cin >> t;
	while(t--) {
		if(!solve())break;
	}
	int mark_EOF;
	if(scanf("%d", &mark_EOF) == EOF) return 0;
    return 0;
}

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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  int n; cin >> n;
  vector<int> c(n-1), s(n-1), f(n-1);
  for(int i=0; i<n-1; ++i) {
    cin >> c.at(i) >> s.at(i) >> f.at(i);
  }

  for(int i=0; i<n; ++i) {
    int ans = 0;
    for(int j=i; j<n-1; ++j) {
      if(ans < s[j]) {
        ans = s[j];
      } else if(ans % f[j] == 0) {
      } else {
        ans += f[j] - ans % f[j];
      }
      ans += c[j];
    }
    cout << ans << '\n';
  }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3644
#!/usr/bin/env ruby

gets

nums = gets.chomp.split.map(&:to_i)

nums.length.times do |i|
  v = nums[i]
  j = i - 1
  while j >= 0 && nums[j] > v
    nums[j + 1] = nums[j]
    j -= 1
  end
  nums[j + 1] = v
  puts nums.join(' ')
end

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

int main() {
  int A = 0, B = 0, n = 0;
  cin >> A >> B;
  
  for (int i = A; i <= B; i++) {
    if (((i / 10000) == i % 10) && (((i / 1000) % 10) == ((i / 10) % 10))) {
      n++;
    }
  }
  cout << n << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int T = sc.nextInt();
		System.out.println(B * (T / A));
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 22356
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];

int main(){
  cin >> n;
  print(n/3);
  return 0;
}

Measured memory_bytes: 256
while True:
    a,op,b = input().split()
    if(op == '+'):
        print(int(a)+int(b))
    elif(op == '-'):
        print(int(a)-int(b))
    elif(op == '*'):
        print((int(a)*int(b)))
    elif(op == '/'):
        print('%d'%(int(a)/int(b)))
    elif(op == '?'):
        break;
            



Measured memory_bytes: 5596
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define sz(a) (int)(a).size() 
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  
#define mt make_tuple 
 
#define int long long 
 
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
 
typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
const int N = 3e3 + 5;
int dp[N][N], a[N];
int n; 

int ans(int i,int j) {
	if(i == j) return dp[i][j] = a[i] ;
	if(dp[i][j] != -1) return dp[i][j] ;
	return dp[i][j] = max(a[i] - ans(i+1,j), a[j] - ans(i,j-1)); 
}

void solve() {
	cin >> n ;
	fl(dp,-1) ;
	rep(i,0,n) cin >> a[i] ;

	cout << ans(0,n-1) ;
}
 
int32_t main() {
 
 
    fast; 
	int t=1;
	// cin>>t;
	rep(i,0,t) {
		solve() ;
	}
 
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 70912
// Daniel Grzegorzewski15
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int N = 2*(int)1e5 + 3;

int n, k, a[N];

bool check(int x) {
  int cnt = 0;
  for (int i = 1; i <= n; ++i)
    cnt += (a[i]+x-1)/x-1;
  return cnt <= k;
}

signed main() {
  init_ios();
  cin >> n >> k;
  for (int i = 1; i <= n; ++i)
    cin >> a[i];
  int x1 = 1, x2 = 1e9+3, x3;
  while (x2-x1 > 1) {
    x3 = (x1+x2)/2;
    if (check(x3))
      x2 = x3;
    else
      x1 = x3;
  }
  if (check(x1))
    cout<<x1<<"\n";
  else
    cout<<x2<<"\n";
}

Measured memory_bytes: 5068
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> p;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
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;
}

string c[100][100];
int main() {
  int h, w, n;
  cin >> h >> w >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<string> v;
  reps(x, n) {
    rep(i, a[x - 1]) {
      v.push_back(to_string(x));
    }
  }

  int index = 0;
  rep(i, h) {
    if(i % 2 == 0) {
      rep(j, w) {
        c[i][j] = v[index++];
      }
    } else {
      rrep(j, w) {
        c[i][j] = v[index++];
      }
    }
  }

  rep(i, h) {
    rep(j, w) {
      if(j > 0) cout << ' ';
      cout << c[i][j];
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 896
# https://atcoder.jp/contests/abc106/tasks/abc106_d

# MAX_N = 505
n, m, q = map(int, input().split())
X = [[0] * (n + 1) for _ in range(n + 1)]
C = [[0] * (n + 1) for _ in range(n + 1)]
count = [0] * (n + 1)
for _ in range(m):
    li, ri = map(int, input().split())
    X[li][ri] += 1
for i in range(1, n + 1):
    for j in range(1, n + 1):
        C[i][j] = C[i][j - 1] + X[i][j]

for _ in range(q):
    p, q = map(int, input().split())
    sum_k = 0
    for j in range(p, q + 1):
        sum_k += C[j][q] - C[j][p - 1]
    print(sum_k)

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

int n, m;
int height[100001];
int biggest[100001]; //the largest peak the height is directly connected to

int main()
{
	cin >> n >> m;
	for (int in1 = 1; in1 <= n; in1++) //start with 1 because it makes input easier
	{
		cin >> height[in1];
	}
	for (int in2 = 0; in2 < m; in2++)
	{
		int a, b;
		cin >> a >> b;
		biggest[a] = max(biggest[a], height[b]); //update largest peak connected
		biggest[b] = max(biggest[b], height[a]);
	}

	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		ans += (biggest[i] < height[i]); //if the biggest connection was smaller than itself, add; else, do nothing
	}

	cout << ans << endl;
}

Measured memory_bytes: 4380
#include <bits/stdc++.h>
#define mem(s,t) memset(s,t,sizeof(s))
#define pb(s) push_back(s)
#define inf 0x3f3f3f3f
#define mn 100010
typedef long long ll;
using namespace std;

int main()
{
    string s;
    int x,y,z,l,i,p;
    cin>>s;
    l=s.length();
    x=y=z=0;
    for (i=0;i<l;i++)
    {
        if (s[i]=='a') x++;
        if (s[i]=='b') y++;
        if (s[i]=='c') z++;
    }
    p=min({x,y,z});
    x-=p;
    y-=p;
    z-=p;
    if (x>1||y>1||z>1) cout<<"NO\n";
    else cout<<"YES\n";
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

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

	string s;
	cin >> s;

	vector<int> arr(n);

	for (int i = 1; i < n; i++)
	{
		if (s[i] == 'C' && s[i - 1] == 'A')
		{
			arr[i] = arr[i - 1] + 1;
		}
		else
		{
			arr[i] += arr[i - 1];
		}
	}

	for (int i = 0; i < q; i++)
	{
		int l, r;
		cin >> l >> r;

		cout << arr[r - 1] - arr[l - 1] << endl;
	}
}


Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int x,a;
    cin>>x>>a;
    if(x<a)cout<<0<<endl;
    else cout<<10<<endl;
}

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

int main()
{
  int M, N;
  cin >> N >> M;
  vector<int> A(N);
  int sum = 0;

  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    sum += A.at(i);
  }

  int cnt = 0;
  double border = sum / (4.0 * M);

  for(int i = 0; i < N; i++){
    if(A.at(i) >= border){
      cnt++;
    }
  }
  if(cnt >= M){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

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


int main(void)
{
    unsigned int room;
    int flag;
    char *table = "01235789";
    int i;
    
    while (1){
        scanf("%u", &room);
        if (room == 0){
            break;
        }
        
        flag = 0;
        for (i = 30; i >= 0; i -= 3){
            if (((room >> i) & 7) != 0){
                flag = 1;
            }
            if (flag == 1){
                printf("%c", table[(room >> i) & 7]);
            }
        }
        printf("\n");
    }
    return (0);
}

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

typedef long long ll;
const int N = 100054;

int n;
std::priority_queue <ll> L;
std::priority_queue <ll, std::vector <ll>, std::greater <ll> > R;
ll OL, OR; // offset

int main() {
	int i, l, r, dis, la = -1; ll x, y, ans = 0;
	scanf("%d%d%d", &n, &l, &r), la = r - l;
	L.emplace(l), R.emplace(l);
	for (i = 1; i < n; ++i, la = dis) {
		scanf("%d%d", &l, &r), dis = r - l, OL -= dis, OR += la;
		x = L.top() + OL, y = R.top() + OR;
		if (x > l) ans += x - l, R.push(x - OR), L.pop(), L.emplace(l - OL), L.emplace(l - OL);
		else if (y < l) ans += l - y, L.push(y - OL), R.pop(), R.emplace(l - OR), R.emplace(l - OR);
		else L.emplace(l - OL), R.emplace(l - OR);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2036
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;

ll dp[51][51];
ll v[50];
int main()
{
	int n,k;
	ll ans=0;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>v[i];
	fill(dp[0],dp[51],0);
	vector<ll> l;
	for(int a=0;a<n+1;a++)
	{
		if(a>0)
			l.push_back(v[a-1]);
		vector<ll> r;
		for(int b=0;b<n+1-a;b++)
		{
			if(b>0)
				r.push_back(v[n-b]);
			vector<ll> lr(l);
			for(int i=0;i<r.size();i++)
				lr.push_back(r[i]);
			sort(lr.begin(),lr.end());
			if(k<a+b)
				continue;

			ll s=0;
			for(int i=0;i<lr.size();i++)
				s+=lr[i];
			//できるだけマイナスを引く
			for(int i=0;i<k-a-b;i++)
			{
				if(i==lr.size())
					break;
				if(lr[i]>0)
					break;
				s-=lr[i];
			}
			//cerr<<a<<" "<<b<<" "<<s<<endl;
			dp[a][b]=s;
		}
	}

	for(int i=0;i<51;i++)
	{
		for(int j=0;j<51;j++)
			ans=max(ans,dp[i][j]);
	}
	cout<<ans<<endl;
	return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll A, B, C;
  cin >> A >> B >> C;
  bool res = false;
  REP1(i, B) {
    if (A * i % B == C) {
      res = true;
    }
  }
  cout << (res ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222





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


  cin >> n;
  ll sum = 0;
  rep(i, n) {
    cin >> tmp;
    ma = max(ma, tmp);
    sum += tmp;
  }
  sum -= ma;
  if (sum > ma) cout << "Yes" << endl;
  else cout << "No" << endl;
  //cout << sum << " " << ma << endl;


  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define du(x) cout<<#x<<'='<<x<<endl
#define du2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define du3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());


int main() {
    int N;
    cin >> N;
    if (N == 1) {
        cout << "Hello World" << endl;
        return 0;
    }
    else if (N == 2) {
        int A, B;
        cin >> A >> B;
        cout << A + B << endl;
    }



}


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

const int N = 3e3 + 10;

double a[N], sum, d[N][N];
int n, kek;

int main ()
{
	cin >>n;
	d[0][0] = 1;
	for (int i = 1; i <= n; i++)
	{
		cin >>a[i];
		d[i][0] = 1;
	}
	d[n][0] = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			d[i][j] = d[i - 1][j - 1] * a[i] + d[i - 1][j] * (1 - a[i]);
		}
	}
	if (n % 2 == 1)
	{
		kek = int(n / 2) + 1 ;
	} else
	{
		kek = int(n / 2);
	}
	for (int i = kek; i <= n; i++)
	{
		sum += d[n][i];
	}
	printf("%.10f", d[n][kek]);
	return 0;
}

Measured memory_bytes: 70784
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    private static void reverse(int[] arr) {
        int N = arr.length;
        int temp;
        for (int i = 0; i < N / 2; i++) {
            temp = arr[i];
            arr[i] = arr[N-i-1];
            arr[N-i-1] = temp;
        }
    }

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] H = new int[N];
        Arrays.setAll(H, i -> sc.nextInt());
        Arrays.sort(H);
        reverse(H);
        // 大きい順に必殺技を適用して, 残ったモンスターのHPの合計 + K
        System.out.println(solve(N, K, H));
    }

    private static long solve(int N, int K, int[] H) {
        long turns = 0L;
        for (int i = K; i < N; i++) {
            turns += H[i];
        }
        return turns;
    }
}


Measured memory_bytes: 65492
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;//采用数学归纳法 
const int N=110;
int n,m,a[N],b[N];
int main(){
  scanf("%d%d",&n,&m);
  int iodd=0;
  for(int i=1;i<=m;i++)
    scanf("%d",&a[i]),iodd+=(a[i]&1);
  if(m==1){
    if(a[1]==1) printf("%d\n1\n%d\n",1,1);
    else printf("%d\n2\n%d %d\n",a[1],a[1]-1,1);
    return 0;
  }
  if(iodd>2) puts("Impossible");
  else{
    for(int i=2;i<=m;i++)
      if(a[i]&1) (a[1]&1)?swap(a[m],a[i]):swap(a[1],a[i]);
    int t=0; if(a[1]>1) b[++t]=a[1]-1;
    for(int i=2;i<m;i++) b[++t]=a[i];
    b[++t]=a[m]+1;
    for(int i=1;i<=m;i++) printf("%d ",a[i]); putchar('\n');
    printf("%d\n",t);
    for(int i=1;i<=t;i++) printf("%d ",b[i]);
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;

constexpr int64_t MOD=1e9+7;
int64_t inv[200010];
int64_t x,y;
void gcd(int64_t a, int64_t b){
    if(a==0){
        x=0,y=1;
    } else if(a==b || b==0){
        x=1,y=0;
    } else if(a<b){
        gcd(a,b%a);
        x-=(b/a)*y;
    }else{
        gcd(a%b,b);
        y-=(a/b)*x;
    }
}

void init_inv(){
    for(int i=1;i<=200000;++i){
        gcd(i,MOD);
        inv[i]=x;
    }
}

int64_t comb(int n, int k){
    int64_t ans=1;
    for(int i=n,j=1;i>=0&&j<=k;++j,--i){
        ans*=(i*inv[j])%MOD;
        ans%=MOD;
    }
    return ans;
}

int main() {
    int n,m,k;
    cin>>n>>m>>k;
    init_inv();
    int64_t c=comb(n*m-2,k-2);
    int64_t cnt=0;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            int64_t x[]={j-1,m-j,i-1,n-i};
            int64_t y[]={n,n,m,m};
            for(int k=0;k<4;++k){
                int64_t d=(x[k]*(x[k]+1))/2;
                d%=MOD;
                cnt+=(d*y[k])%MOD;
                cnt%=MOD;
            }
        }
    }
    cnt*=inv[2];
    cnt%=MOD;
    int64_t ans=(c*cnt)%MOD;
    if(ans<0)ans+=MOD;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    TXY = [[int(i) for i in input().split()] for j in range(N)]
    time = 0
    px = 0
    py = 0
    for t, x, y in TXY:
        move = abs(py-y) + abs(px - x)
        if (t-time) < move or (t - time) % 2 != move % 2:
            return print("No")
        time = t
        px = x
        py = y
    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 21108