akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
long long n,d,a,tot,rpos;
pair<long long,long long> arr[200001];
long long ft[300001];
void upd(int p, long long v) {
    while (p < 300001) {
        ft[p] += v;
        p += p&-p;
    }
}
long long qry(int p) {
    long long sum = 0;
    while (p>0) { // while p > 0
        sum += ft[p];
        p -= p&-p;
    }
    return sum;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>d>>a;
    d*=2;
    for (int i=1;i<=n;i++){
        cin>>arr[i].first>>arr[i].second;
    }
    sort(arr+1,arr+n+1);
    for (int i=1;i<=n;i++){
        upd(i,arr[i].second);
        upd(i+1,-arr[i].second);
    }
    for (int i=1;i<=n;i++){
        long long h=qry(i);
        if (h<=0) continue;
        while (rpos<n && arr[rpos+1].first<=arr[i].first+d){
            rpos++;
        }
        long long cur=(h+a-1)/a;
        upd(i,-cur*a);
        upd(rpos+1,cur*a);
        tot+=cur;
    }
    cout<<tot;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
using vc = vector<char>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
  int n;
  cin >> n;
  if(n % 2 == 0){
    cout << n*(n-2)/2 << endl;
    for(int i=1;i<=n;i++){
      for(int j=i+1;j<=n;j++){
        if(i + j == n+1) continue;
        cout << i << " " << j << endl;
      }
    }
  }else{
    cout << (n-1)*(n-1)/2 << endl;
    for(int i=1;i<=n;i++){
      for(int j=i+1;j<=n;j++){
        if(i + j == n) continue;
        cout << i << " " << j << endl;
      }
    }
  }
}

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

	int n;
	int a[200002];

	int p[1000002];
	int c[1000002];

int main(){

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

	for(int i=0;i<=1000000;i++){
		p[i] = c[i] = 0;
	}
	sort(a,a+n);
	//for(int i=0;i<n;i++){
	//	cout<<a[i]<<" ";
	//}

	int ans = 0;
	for(int i=0;i<n;i++){
		c[a[i]]++;
		if(1 < c[a[i]])continue;
		for(int j=a[i]*2;j<=1000000;j+=a[i]){
			p[j] = 1;
		}
	}

	for(int i=0;i<n;i++){
		if(p[a[i]]==0 && c[a[i]] < 2)ans++;
	}

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


Measured memory_bytes: 12192
#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>;
int main() {
    int n; cin >> n;
    vector<char> s(n);
    rep(i, n) cin >> s[i];
    map<char,int> mp;
    rep(i, n) mp[s[i]]++;
    if(mp.size() == 3) cout << "Three";
    else cout << "Four";
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
  int i;
  int n;
  int m;
  int a;
  scanf("%d%d",&n, &m);
  for(i = 0; i < m; i++){
    scanf("%d", &a);
    n -= a;
  }
  if (n < 0)
    printf("-1\n");
  else
    printf("%d\n",n);
}

Measured memory_bytes: 1708
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int a = ni();
        int b = ni();
        int c = ni();

        out.print(a);
        out.print(" ");
        out.print(b);
        out.print(" ");
        out.print(3 * c - a - b);
        out.println();

        out.print(4 * c - 2 * a - b);
        out.print(" ");
        out.print(c);
        out.print(" ");
        out.print(2 * a + b - 2 * c);
        out.println();

        out.print(a + b - c);
        out.print(" ");
        out.print(2 * c - b);
        out.print(" ");
        out.print(2 * c - a);
        out.println();
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 8404
import numpy as np
def q48(n, m, c, b, a):
    correct = 0
    
    for s in a:
        if np.dot(s, b) + c > 0:
            correct += 1
    return correct
        

N, M, C = [int(i) for i in input().split()]
B= [int(i) for i in input().split()]
A = []
for i in range(N):
    A.append([int(i) for i in input().split()])

print(q48(N, M, C, B, A))

Measured memory_bytes: 12452
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    if(n%10==2 ||n%10==4 ||n%10==5 ||n%10==7 ||n%10==9)
    cout<<"hon"<<endl;
    if(n%10==0 ||n%10==1 ||n%10==6 ||n%10==8)
    cout<<"pon"<<endl;
     if(n%10==3)
    cout<<"bon"<<endl;
    return 0;
}

Measured memory_bytes: 3576
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#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;

int main() {
  int a, b;
  cin >> a >> b;

  int d = abs(a + b) / 2;
  if(abs(a + b) % 2 == 1) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << d << endl;
  }

  return 0;
}

Measured memory_bytes: 256
X = input()
n = len(X)
cnt = 0
S_check = 0

for i in range(n):
    if X[i] == 'S':
        S_check += 1

    if X[i] == 'T':
        if S_check > 0:
            S_check -= 1
        else:
            cnt += 1

print(cnt + S_check)

Measured memory_bytes: 9260
import java.util.Scanner;

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

        while (true) {
            int H = scan.nextInt(), W = scan.nextInt();
            if (H == 0 && W == 0) break;

            for (int i = 1; i <= H; i++) {
                for (int j = 1; j <= W; j++) {
                    if ((i + j) % 2 == 0) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }

    }

}

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

void trace(int A[], int N);
	void insertionSort(int A[], int N);

int main() {
	int N; //????´???°
	int A[100]; //??°?????????

	//??\???
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	//?¨????
	trace(A, N);
	insertionSort(A, N);

	return 0;
}

//?????????????´???????????????????
void trace(int A[], int N) {
	for (int i = 0; i < N; i++) {
		if (i > 0) { cout << " "; }
		cout << A[i];
	}
	cout << endl;
}

//?????\????????????????????????????????????
void insertionSort(int A[], int N) {
	int j, v;
	for (int i = 1; i < N; i++) {
		v = A[i];
		j = i - 1; //(move)
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trace(A, N);
	}
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int N, M, K, H, W, L, R, X;
//string S, T;
int ans;
void chk(int H, int W){
  rep2(i,1,H){
    int a = i*W;
      
    int w = W/2;
    int b = (H-i)*w;
    int c = H*W - a - b;
    int mx = max(a, max(b, c));
    int mn = min(a, min(b, c));
    ans = min(ans, mx-mn);

    int d = (H-i)/2;
    b = d*W;
    c = H*W - a - b;
    mx = max(a, max(b, c));
    mn = min(a, min(b, c));
    ans = min(ans, mx-mn); 
  }
  return;
}

signed main(){
  cin >> H >> W; 
  if(H%3 == 0 || W%3 == 0){
    cout << 0 << endl;
    return 0;
  }
  
  ans = 1e18;
  chk(H,W);
  swap(H,W);
  chk(H,W);
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3580
a = [input().split() for l in range(3)]
n = int(input())
b = [input() for i in range(n)]
c = [a[0][0],a[1][1],a[2][2]]
d = [a[0][2],a[1][1],a[2][0]]
tate1 = len(set(a[0]) & set(b))
tate2 = len(set(a[1]) & set(b))
tate3 = len(set(a[2]) & set(b))
yoko1 = len(set([x[0] for x in a]) & set(b))
yoko2 = len(set([x[1] for x in a]) & set(b))
yoko3 = len(set([x[2] for x in a]) & set(b))
naname1 = len(set(c) & set(b))
naname2 = len(set(d) & set(b))
bingo = [tate1,tate2,tate3,yoko1,yoko2,yoko3,naname1,naname2]
if 3 in bingo:
  print("Yes")
else:
  print("No")

  

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

#define int long long
#define lc (i << 1)
#define rc (lc | 1)
#define mid ((l + r) >> 1)

const int INF = 1e10;
const int N = 2e5 + 10;
int tree[4 * N], lazy[4 * N];

void prop(int i, int l, int r) {
    if (lazy[i] != 0 and l != r) {
        tree[lc] = tree[i];
        tree[rc] = tree[i] + mid + 1 - l;
        lazy[lc] = lazy[i];
        lazy[rc] = lazy[i]; 
    }
    lazy[i] = 0;
}

void update(int i, int l, int r, int s, int e, int v) {
    prop(i, l, r);
    if (l > e or r < s) {
        return;
    } else if (l >= s and r <= e) {
        tree[i] = v + l - s;
        lazy[i] = 1;
        prop(i, l, r);
    } else {
        update(lc, l, mid, s, e, v);
        update(rc, mid + 1, r, s, e, v);
        tree[i] = min(tree[lc], tree[rc]);
    }
}

int get(int i, int l, int r, int p) {
    prop(i, l, r);
    if (l == r) {
        return tree[i];
    } else if (p <= mid) {
        return get(lc, l, mid, p);
    }
    return get(rc, mid + 1, r, p);
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int H, W;
    cin >> H >> W;
    vector<int> A(H), B(H);
    for (int i = 0; i < H; i++) {
        cin >> A[i] >> B[i];
    }
    for (int i = 0; i < H; i++) {
        int st = INF;
        if (A[i] > 1) {
            st = get(1, 1, W, A[i] - 1) + 1;
        }
        update(1, 1, W, A[i], B[i], st);
        int ans = tree[1];
        if (ans >= INF) {
            cout << -1 << endl;
        } else {
            cout << ans + i + 1 << endl;
        }
    }
    return 0;
}



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

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    ans += min(x, k - x);
  }
  cout << ans * 2 << endl;
}


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


int main()
{
	int n,a=0;
	cin >>n;
	if (n < 105)a = 0;
	else if (n < 135)a = 1;
	else if (n < 165)a = 2;
	else if (n < 189)a = 3;
	else if (n < 195)a = 4;
	else a = 5;
	cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<vector>
#include<string>
using namespace std;
using ll = long long;

int main() {
    ll K;
    // char string = 'ACL';
    cin >> K;
    for (int i = 0; i < K; i++) {
        cout << "ACL";
    }
}

Measured memory_bytes: 3124
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a<b){
        cout << "a < b" <<endl;
    }else if(a>b){
        cout << "a > b" <<endl;
    }else{
        cout << "a == b" <<endl;
        
    }
}


Measured memory_bytes: 3104
H, N = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

max_ab = max(AB)
dp = [10**10]*(H+max_ab[0])
dp[0] = 0

for i in range(1, H + max_ab[0]):
    dp[i] = min(dp[i - a] + b for a, b in AB)

print(min(dp[H:]))

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

int main() {
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		if(i%3==0||i%10==3){
			cout<<" "<<i;
		}
		else{
			int x=i;
			while(x){
				x/=10;
				if(x%10==3){
					cout<<" "<<i;
					break;
				}
			}
		}
	}
	cout<<"\n";
}


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

const int MAXV = 200;
const int MAXM = 6;
const int INF = 1<<28;
int M, N, K, D, V;
int cal[MAXM];
int G[MAXV][MAXV];

void wf() {
  for(int k = M; k < V; ++k) {
    for(int i = 0; i < V; ++i) {
      for(int j = 0; j < V; ++j) {
	G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
}

int main() {
  while(cin >> M >> N >> K >> D && (M|N|K|D)) {
    for(int i = 0; i < M; ++i) cin >> cal[i];
    fill(G[0], G[MAXV], INF);
    for(int i = 0; i < MAXV; ++i) G[i][i] = 0;
    V = M + 2 + N;
    int src = M;
    int dst = M+1;
    while(D--) {
      int v[2];
      for(int i = 0; i < 2; ++i) {
	int &a = v[i];
	char c;
	cin >> c;
	if(c == 'C') {
	  cin >> a;
	  --a;
	} else if(c == 'L') {
	  cin >> a;
	  --a;
	  a += M+2;
	} else if(c == 'H') {
	  a = src;
	} else if(c == 'D') {
	  a = dst;
	}
      }
      int d;
      cin >> d;
      G[v[0]][v[1]] = min(G[v[0]][v[1]], d);
      G[v[1]][v[0]] = min(G[v[1]][v[0]], d);
    }

    wf();
    vector<int> id;
    for(int i = 0; i < M; ++i) id.push_back(i);
    id.push_back(dst);

    int res = INF;
    do {
      int p = M;
      int c = 0;
      for(int i = 0; i < id.size(); ++i) {
	int np = id[i];
	if(G[p][np] == INF) {
	  c = INF;
	  break;
	}
	c += G[p][np]*K;
	if(np == dst) break;
	c -= cal[np];
	p = np;
      }
      res = min(res, c);
    } while(next_permutation(id.begin(), id.end()));
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1368
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int H = int.Parse(str[0]);
		int W = int.Parse(str[1]);
		int M = int.Parse(str[2]);
		int[]H1 = new int[H];
		int[]W1 = new int[W];
		int[,]A = new int[M,2];
		for(var i=0;i<M;i++){
			string[] str2 = Console.ReadLine().Split();
			int h1 = int.Parse(str2[0])-1;
			int w1 = int.Parse(str2[1])-1;
			H1[h1]++;
			W1[w1]++;
			A[i,0] = h1;
			A[i,1] = w1;
		}
		int max = 0;
		for(var i=0;i<M;i++){
			max = Math.Max(max,H1[A[i,0]]+W1[A[i,1]]-1);
		}
      	int max1 = 0;
		for(var i=0;i<H;i++){
          	max1 = Math.Max(H1[i],max1);
        }
		int[]HM = new int[H];
		int HMct = 0;
      	for(var i=0;i<H;i++){
          	if(H1[i]==max1){
              	HM[i] = 1;
              	HMct++;
            }
        }
      	int max2 = 0;
		for(var i=0;i<W;i++){
          	max2 = Math.Max(W1[i],max2);
        }
		int[]WM = new int[W];
		int WMct = 0;
      	for(var i=0;i<W;i++){
          	if(W1[i]==max2){
              	WM[i] = 1;
              	WMct++;
            }
        }
      	int cta = 0;
      	for(var i=0;i<M;i++){
          	int h1 = A[i,0];
          	int w1 = A[i,1];
          	if(HM[h1]==1 && WM[w1]==1){
              	cta++;
            }
        }
      	if((long)HMct*WMct==cta){
          	Console.WriteLine(max1+max2-1);
        } else {
          	Console.WriteLine(max1+max2);
        }
		//Console.Error.WriteLine(max1+" "+max2);
		//Console.WriteLine(max);
	}
}

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N, M;
    cin >> N >> M;
    auto x = make_v<ll>(3,N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> x[0][i] >> x[1][i] >> x[2][i];
    }
    ll ans = 0;
    int sign[3];
    for (int bit = 0; bit < (1 << 3); bit++)
    {
        vll vals;
        for (size_t i = 0; i < 3; i++)
        {
            if (bit & (1 << i))
            {
                sign[i] = 1;
            }
            else
            {
                sign[i] = -1;
            }
        }
        for (size_t i = 0; i < N; i++)
        {
            ll val = 0;
            for (size_t j = 0; j < 3; j++)
            {
                val += sign[j]*x[j][i];
            }
            vals.push_back(val);
        }
        ll sum = 0;
        sort(all(vals),greater<ll>());
        for (size_t i = 0; i < M; i++)
        {
            sum += vals[i];
        }
        chmax(ans,sum);

    }
    cout<<ans;
    return 0;
}

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

using namespace std;

int n, t[105], m, p[105], x[105], s;
int main()
{
    int i;
   cin >> n;
    for(i=1; i<=n; i++) {
        cin >> t[i];
    }
    cin >> m;
    for(i=1; i<=m; i++) {
        cin >> p[i] >> x[i];
    }
    for(i=1; i<=n; i++) {
        s += t[i];
    }
    for(i=1; i<=m; i++) {
        cout << s - t[p[i]] + x[i] << endl;
    }
    return 0;
}


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

int main(){
    int n,m,a;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> a;
        n-=a;
        if(n<0) break;
    }
    int res=(n<0)?-1:n;
    cout << res << endl;
}

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

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && a == c){
        cout << 1 << endl;
    }
    else if(a == b || b == c || a == c){
        cout << 2 << endl;
    }
    else{
        cout << 3 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

main(){
  int n;
  int N[100][3];
  int i,j;
  int allday = 0;
  int ans[100];
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d%d%d",&N[i][0],&N[i][1],&N[i][2]);
  }
  
  for(i=1;i<1000;i++){
    if(i%3 == 0){
      allday += 10*20;
    }
    else allday += 5*19 + 5*20;
  }
  allday += 1;
  
  for(i=0;i<n;i++){
    ans[i] = 0;
    for(j=1;j<N[i][0];j++){
    if(j%3 == 0){
      ans[i] += 10*20;
    }
    else ans[i] += 5*19 + 5*20;

    }
    for(j=1;j<N[i][1];j++){
      if(N[i][0]%3 == 0){
	ans[i] += 20;
      }
      else{
	if(j%2 == 0){
	  ans[i] += 19;
	}
	else ans[i] += 20;
      }
    }
    ans[i] += N[i][2];
    printf("%d\n",allday - ans[i]);
  }
  return 0;
}
 

Measured memory_bytes: 596
import heapq


def main():
    N, K = map(int, input().split())
    V = list(map(int, input().split()))
    if N <= K:
        V.sort()
        total = sum(V)
        ans = max(total, 0)
        for i in range(min(K-N, N)):
            total -= V[i]
            ans = max(ans, total)
        print(ans)
    else:
        left = [0] * (K+1)
        right = [0] * (K+1)
        for i in range(K, 0, -1):
            lv = V[:i]
            rv = V[-i:]
            left[i] = sum(lv)
            right[i] = sum(rv)
            lheap = list(lv)
            rheap = list(rv)
            heapq.heapify(lheap)
            heapq.heapify(rheap)
            lmsum = 0
            rmsum = 0
            for j in range(1, i):
                if i+j > K:
                    continue
                lmsum += heapq.heappop(lheap)
                left[i+j] = max(left[i+j], left[i] - lmsum)
                rmsum += heapq.heappop(rheap)
                right[i+j] = max(right[i+j], right[i] - rmsum)
        for i in range(1, K+1):
            left[i] = max(left[i], left[i-1])
            right[i] = max(right[i], right[i-1])
        ans = 0
        for i in range(K+1):
            ans = max(max(left[i], 0) + max(right[K-i], 0), ans)
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 39408
#include <iostream>
#include <cstring>
#include <cctype>
using namespace std;

int main() {
    char check[9];
    char sen[100];
    cin >> check;
    int num = 0;
    while(cin >> sen){
        for(int i = 0; i < strlen(sen) ; i++){
            if(isupper(sen[i]))
                sen[i] = tolower(sen[i]);
            if(check[i] != sen[i] ||strlen(sen) != strlen(check))
            	break;
            if(i == strlen(sen) - 1)
            	num++;
        }
    }
    cout << num << endl;
	return 0;
}

Measured memory_bytes: 3012
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e5 + 5;
const int inf = 1000000000;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338; // double PI = 4*atan(1);



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	//ifstream cin (".in");
	//ofstream cout (".out");
    ll a,b;
    cin >> a >> b;
    a%=b;
    cout << min(a,b-a) << '\n';
}





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

using namespace std;


int main() {
    vector<int> vt(3);
    cin >> vt[0] >> vt[1] >> vt[2];

    sort(vt.begin(), vt.end());
    if (vt[0] == 5 && vt[1] == 5 & vt[2] == 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
const long long LLINF = 1LL << 62;
const int INF = 1LL << 30;
using namespace std;

int main(void) {
	int X, A;
	cin >> X >> A;

	if (X < A) {
		cout << 0 << endl;
	}
	else {
		cout << 10 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define debug(x) cout<<"### x is: "<<x<<"###"<<endl
#define all(a) a.begin(),a.end()
#define tc int t;scanf("%d",&t);while (t--0)
#define int long long
typedef vector<int> vll;
typedef vector<vll> vvll;
const int N=2e5+5;

const int MOD=1e9+7;

int power(int x, int p) 
{
    int res = 1;
    while (p) 
   {
        if (p % 2) 
	{
            res = (res * x) % MOD;
            --p;
        }
        else {
            x = (x * x) % MOD;
            p /= 2;
        }
    }
    return res;
}
int invmod(int x) {return power(x,MOD-2);}


// void go(int s,int pre,int p)
// {
// 	if(s>n)
// 		return;
// 	dp[s]=min(dp[s],pre+abs(a[p]-a[s]));
// 	for(int i=1;i<=k;i++)
// 	{
// 		go(s+i,dp[s],s);
// 	}
// }
int dp[N][4];
int32_t main()
{
	int n;
	
	cin>>n;
	int a[N],b[N],c[N];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	
	
	dp[1][1]=a[1];
	dp[1][2]=b[1];
	dp[1][3]=c[1];
	for(int i=2;i<=n;i++)
	{
		dp[i][1]=a[i]+max(dp[i-1][2],dp[i-1][3]);
		dp[i][2]=b[i]+max(dp[i-1][1],dp[i-1][3]);
		dp[i][3]=c[i]+max(dp[i-1][1],dp[i-1][2]);


	}
	dp[n][1]=max(dp[n][1],dp[n][2]);
	dp[n][1]=max(dp[n][1],dp[n][3]);
	cout<<dp[n][1]<<endl;


}

	
	


	




	


Measured memory_bytes: 8832
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll s;
    cin >> s;

    set<ll> a;

    ll x = s;
    a.insert(x);

    ll m = 1;

    while (1)
    {
        m++;
        if (x & 1)
        {
            x = 3 * x + 1;
        }
        else
        {
            x /= 2;
        }

        if (a.find(x) != a.end())
        {
            break;
        }
        else
        {
            a.insert(x);
        }
    }

    cout << m << endl;
}


Measured memory_bytes: 256
def main():
    import sys
    N,K=list(map(int,sys.stdin.readline().split()))
    P=list(map(int,sys.stdin.readline().split()))
    C=list(map(int,sys.stdin.readline().split()))

    output=-10**20

    lst=[[0]*(N+1) for _ in range(N)]
    for i in range(N):
        st=set()
        now=i
        count=0
        score=0
        if K==1:
            output=max(output,C[P[i]-1])
            continue

        while True:
            count+=1
            now=P[now]-1

            if now in st:
                count-=1
                break
    
            lst[i][count]=lst[i][count-1]+C[now]
            st.add(now)
            
            if count==K:
                break


        if lst[i][count]>0:
            m=max(lst[i][1:count+1])
            
            if K%count:
                p=max(lst[i][1:K%count+1])
                if p>0:
                    s=lst[i][count]*(K//count)+p
                else:
                    s=lst[i][count]*(K//count-1)+m
            else:
                s=lst[i][count]*(K//count-1)+m
        else:
            s=max(lst[i][1:count+1])
        
        output=max(output,s)

    print(output)

main()

Measured memory_bytes: 311004
#include <bits/stdc++.h>
using namespace std;
 
 
int main(void){
  int N, L;
  cin >> N >> L;
  int min = L;
  int sum = 0;
  for(int i = L; i < L + N; i++){
   sum += i;
   if(abs(i) < abs(min)){
    min = i; 
   }
  }
  sum -= min;
  
  cout << sum;
  
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define L long
#define endl "\n"
#define set0(x) memset(x, 0, sizeof(x))
#define setT(x) memset(x, true, sizeof(x))
#define setF(x) memset(x, false, sizeof(x))
#define For(i, init, n) for (ll int i = init; i < n; i++)
#define ___ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

const double PI = acos(-1), E = exp(1.0), EPS = DBL_EPSILON;
const ll int MOD = (ll int)1e9 + 7, N = (int)1e5;

int main()
{   
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ___
    
    ll int x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll int q = x / d, r = x % d;
    ll int ans;
    if (k <= q)
    {
        ans = x - (k * d);
    }
    else
    {
        ans = r;
        k -= q;
        // cout<< k << endl;
        if (k % 2 == 1)
        {
            ans = min(ans + d, abs(ans - d));
        }
    }
    cout<< ans;
    
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
using namespace std;
int n,x,ans,cnt[100010];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&x),++cnt[x];
	for (int i=1;i<=100000;++i) ans=max(ans,cnt[i-1]+cnt[i]+cnt[i+1]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>

using namespace std;
int main(){
    int x,a,b,c,cnt;
    cnt = 0;
    scanf("%d %d %d %d",&a,&b,&c,&x);
    x = x/50;


    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(x == i*10+j*2+k){
                    cnt++;
                    break;
                }

            }
        }
    }
cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

ll gcd(ll x, ll y) {
  if(x > y)
    return gcd(y, x);
  else if(x == 0)
    return y;
  else
    return gcd(y % x, x);
}
ll lcm(ll x, ll y) {
  ll g = gcd(x, y);
  return g * (x / g) * (y / g);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> T(n); rep(i, n) cin >> T[i];
  ll ans = 1;
  rep(i, n) ans = lcm(ans, T[i]);
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.Sumitrust_2019
{
    class F
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] t12 = ReadInts();
            int t1 = t12[0];
            int t2 = t12[1];
            long[] a12 = ReadLongs();
            long a1 = a12[0];
            long a2 = a12[1];
            long[] b12 = ReadLongs();
            long b1 = b12[0];
            long b2 = b12[1];
            long delta1 = (a1 - b1) * t1;
            long delta2 = delta1 + (a2 - b2) * t2;
            if (delta2 == 0)
            {
                WriteLine("infinity");
            }
            else if ((delta1 < 0 && delta2 > 0)
                || (delta1 > 0 && delta2 < 0))
            {
                long res = 1;
                if (-delta1 % delta2 == 0)
                {
                    res += -delta1 / delta2 * 2 - 1;
                }
                else
                {
                    res += -delta1 / delta2 * 2;
                }
                WriteLine(res);
            }
            else
            {
                WriteLine(0);
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
a = list(map(int, input().split()))
d = 0
e = 0
for i in range(3):
  f = a[i]
  if f == 7:
    d += 1
  elif f == 5:
    e += 1
  else:
    break
if d == 1 and e == 2:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  bool f=true;
  for(int i=0;i<s.size();i++){
    if(i%2==0&&s[i]=='L')f=false;
     else if(i%2!=0&&s[i]=='R')f=false; 
  } 
    if(f)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template<typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(int i=0;i<((int)(v.size()));++i) {
    if (i) os << " ";
    os << v[i];
  }
  return os;
}
struct Elm {
  ll val;
  ll atk;
  int idx;
  int cnt;
};
bool operator<(Elm &e1, Elm &e2) {
  return e1.atk * e2.cnt < e2.atk * e1.cnt;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vi h(n+1), a(n+1), d(n+1), s(n+1);
  for(int i=0;i<(n+1);++i) {
    cin >> h[i] >> a[i] >> d[i] >> s[i];
  }
  vector<Elm> v(n);
  ll now = 0;
  for(int i=0;i<(n);++i) {
    if(a[0] - d[i+1] <= 0) {
      v[i].val = 0;
      v[i].cnt = INF;
      v[i].atk = max(0, a[i+1] - d[0]);
      if(v[i].atk > 0) {
        cout << -1 << endl;
        return 0;
      }
      continue;
    }
    v[i].idx = i+1;
    ll tmp1 = max(0, a[i+1] - d[0]);
    ll tmp2 = (h[i+1]-1) / (a[0] - d[i+1]) + 1;
    if(tmp1 > LLONG_MAX / tmp2) {
      cout << -1 << endl;
      return 0;
    }
    v[i].val = tmp1 * (tmp2 - (s[0] > s[i+1]));
    v[i].cnt = tmp2;
    v[i].atk = tmp1;
    now += v[i].atk;
  }
  sort(v.rbegin(), v.rend());
  ll su = 0;
  for(int i=0;i<(n);++i) {
    su += v[i].val;
    if(su >= h[0]) {
      cout << -1 << endl;
      return 0;
    }
    now -= v[i].atk;
    if(now > LLONG_MAX / v[i].cnt) {
      cout << -1 << endl;
      return 0;
    }
    if(now * v[i].cnt >= h[0]) {
      cout << -1 << endl;
      return 0;
    }
    su += now * v[i].cnt;
    if(su >= h[0]) {
      cout << -1 << endl;
      return 0;
    }
  }
  if(su >= h[0]) {
    cout << -1 << endl;
  } else {
    cout << su << endl;
  }
}



Measured memory_bytes: 4284
import itertools

a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                cnt += 1

print(cnt)

Measured memory_bytes: 3060
num, count = map(int, input().split())
baggages = [int(input()) for _ in range(num)]

def check(capacity):
    index = 0
    for _ in range(count):
        weight = 0
        while weight + baggages[index] <= capacity:
            weight += baggages[index]
            index  += 1

            if index == num:
                return num
    return index


L,R = 0, 100000*10000
while R - L > 1:
    pivot = (L + R) // 2
    v = check(pivot)
    if v >= num:
        R = pivot
    else:
        L = pivot
print(R)


Measured memory_bytes: 9556
<?php
# 数値の入力
fscanf(STDIN, "%d", $data1);
$data2 = trim(fgets(STDIN));
$a = explode(" ", $data2);

$anser = $a[$data1-2];

for($i=0; $i<$data1-1; $i++){
    if($i!=0){
        if($a[$i]>=$a[$i-1]){
            $anser += $a[$i-1];
        }else{
            $anser += $a[$i];
        }
    }else{
        $anser += $a[$i];
    }
}

echo $anser;
?>

Measured memory_bytes: 3576
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String St = sc.nextLine();
		String num = sc.nextLine();
		String U = sc.nextLine();
		
		String[] str1 = St.split(" ");
		String[] str2 = num.split(" ");
		
		String S = str1[0];
		String T = str1[1];
		
		int A = Integer.parseInt(str2[0]);
		int B = Integer.parseInt(str2[1]);
				
		if(U.equals(S)){
			A = A - 1;
		}
		else if(U.equals(T)){
			B = B - 1;
		}
		
		System.out.println(A+" "+B);
	}
}

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

x.append(a)
x.sort()

diff_all = []
for i in range(len(x) - 1):
    diff_all.append(abs(x[i] - x[i+1]))

import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

print(gcd_list(diff_all))


Measured memory_bytes: 83480
N = int(input())
data = [int(input()) for i in range(N)]
c = 0
if data[0] > 0:
    print(-1)
    exit()
for i in range(1,N)[::-1]:
    if data[i] - data[i-1] > 1:
        print(-1)
        exit()
    if data[i] - data[i-1] == 1:
        c += 1
    if data[i] - data[i-1] < 1:
        c += data[i]
print(c)


Measured memory_bytes: 12328
#include <iostream>
#include <cmath>
#include <limits>
#include <set>
#include <vector>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    vector<bool> ok(n, true);
    for(int i=0; i < n; i++){
        cin >> h[i];
    }
    for(int i=0; i < m; i++){
        int a, b;
        cin >> a >> b;
        --a; --b;
        if(h[a] <= h[b]) ok[a] = false;
        if(h[b] <= h[a]) ok[b] = false;
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        if(ok[i]) ans++;
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3800
n = int(input())
S = input()
L = []
ans = 0
for i in range(10):
  for j in range(10):
    for k in range(10):
      cnt = 0
      iflag = 0
      jflag = 0
      while True:
        if cnt >= n:
          break
        if iflag == 0 and S[cnt] == str(i):
          iflag = 1
          cnt += 1
          continue
        if iflag == 1 and jflag == 0 and S[cnt] == str(j):
          jflag= 1
          cnt += 1
          continue
        if jflag == 1 and S[cnt] == str(k):
          ans += 1
          break
        cnt += 1

print(ans)

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

signed main(){
  string S;
  cin>>S;
  rep(i,S.size())if(i%2==0)cout<<S[i];
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
bool prime(int x){
    if(x<=1)return false;
    for(int i=2;i<=sqrt(x);i++){
        if(x%i==0)return false;
    }
    return true;
}
int main(){
    ll n;
    cin>>n;
    for(int i=n;;i++){
        if(prime(i)){
            cout<<i;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  
using namespace std;  
map<string,int> Q;  
const int maxn = 107;  
int n,m,a[maxn],b[maxn];  
int main(int argc, char const *argv[])  
{  
    cin>>n;  
    int now = 0;  
    for(int i=1;i<=n;i++)  
    {  
        string s;  
        cin>>s;  
        if(!Q.count(s))  
            {  
                Q[s]=now;  
                a[now++]=1;  
            }  
        else a[Q[s]]++;  
    }  
    cin>>m;  
    for(int i=1;i<=m;i++)  
    {  
        string s;  
        cin>>s;  
        if(!Q.count(s))  
            {  
                Q[s]=now;  
                b[now++]=1;  
            }  
        else b[Q[s]]++;  
    }  
    int ans = 0;  
    for(int i=0;i<now;i++)  
    {  
        ans = max(ans,max(0,a[i]-b[i]));  
    }  
    cout<<ans<<endl;  
    return 0;  
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vb=vector<bool>;
int n,q,m,k,l,ans;
ll lans;
string s;
map<ll, vll> bits;

int main() {
    // cin.tie(nullptr);
    // ios_base::sync_with_stdio(false);
	// cout<<fixed<<setprecision(20);
    
    cin >> n >> k;
    // 和をx+10^100+yの形で書く
    lans = 0;
    ll ymin = 0,ymax=0;
    rng(i,0,k-1) {ymin+=i;ymax+=n-i;}
    // printf("ymin:%lld ymax:%lld\n",ymin,ymax);
    rng(x,k,n+2){
        ymin+=x-1,ymax+=n-x+1;
        // rng(i,0,x) {ymin+=i;ymax+=n-i;}
        lans += ymax-ymin+1;
        lans %= MOD;
        // printf("x:%d ymin:%lld ymax:%lld ans:%lld\n",x,ymin,ymax,lans);
    }
    cout << lans << endl;
    return 0;
}

Measured memory_bytes: 3636
n = int(input())
ans=[0]*(n+1)
for i in range(1,101):
    for j in range(1,101):
        for k in range(1, 101):
            if i * j + j * k + k * i + i * i + j * j + k * k<=n:
                ans[i * j + j * k + k * i + i * i + j * j + k * k] += 1
                
for i in range(n):
    print(ans[i+1])

Measured memory_bytes: 74576
#! /usr/bin/perl

use strict;
use warnings;

chomp(my $s = <>);
my($a, $b, $k) = split(/\s+/, $s);

my $s1 = $a;
my $e1 = $a + ($k - 1);
my $s2 = $b - ($k - 1);
my $e2 = $b;

if($b < $e1) {
    $e1 = $b;
}
if($s2 <= $e1) {
    $s2 = $e1 + 1;
}
foreach my $i ($s1 .. $e1) {
    print $i, "\n";
}
foreach my $i ($s2 .. $e2) {
    print $i, "\n";
}


Measured memory_bytes: 640
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    List<Integer> x = new ArrayList<Integer>();
    x.add(sc.nextInt());
    int count = 0;
    while(x.get(count) != 0) {
      System.out.println("Case " + (count + 1) + ": " + x.get(count++));
      x.add(sc.nextInt());
    }
  }
}

Measured memory_bytes: 42644
from math import *

n, m = map(int, input().split())
fac_n = factorial(n) % (10 ** 9 + 7)
fac_m = factorial(m) % (10 ** 9 + 7)

ans = fac_n * fac_m % (10 ** 9 + 7)

print(0 if abs(n - m) > 1 else ans if n != m else (ans * 2)  % (10 ** 9 + 7))

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

time = sum(b) - sum(a)
if time < 0:
	print("No")
else:
	pos = 0
	neg = 0
	for i in range(n):
		if a[i] <= b[i]:
			pos += (b[i] - a[i] + 1) // 2
		else:
			neg += a[i] - b[i]
	if pos <= time and neg <= time:
		print("Yes")
	else:
		print("No")

Measured memory_bytes: 4596
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}


void solve(){
    int x;
    read(x);
    if( x >= 30){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
} 

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    solve();

    return 0;
}


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

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]


def op(b,i):
    global ans
    if i == n-1:
        res = (b[i]-a[i])//(b[i-1]+b[0])
        if res < 0: return 0
        b[i] -= (b[i-1]+b[0])*res
    else:
        res = (b[i]-a[i])//(b[i-1]+b[(i+1)])
        if res < 0: return 0
        b[i] -= (b[i-1]+b[(i+1)])*res
    ans += res
    return res

def check(b,c):#c からチェック 操作ができる最初のi
#    print(b,c)
    for i in range(c,c+n):
        if op(b,i%n) > 0: return i
    else:
        return(-1)

def rev(b,i):#iから逆向きに操作
    for j in range(i-1,-n,-1):
#        print(b,j)
        if op(b,j%n) == 0: break

    
c = 0
ans = 0
"""
while True:
    i = check(b,c)
    if i == -1: break
    rev(b,i)
    c += 1
    if c >= n: c -= n
"""

s = set(range(n))

while s:
    i = s.pop()
    if op(b,i) > 0:
        s.add((i-1)%n)
        s.add((i+1)%n)

if a == b:
    print(ans)
else:
    print(-1)












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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define y1 dhwjdshg

using namespace std;

const int N = 1000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    int a[n], b[n];
    rep(i, 0, n)
        cin >> a[i];
    rep(i, 0, n)
        cin >> b[i];
    sort(a, a + n);
    sort(b, b + n);
    int ans = 0;
    rep(p, 0, 29)
    {
        vector<int> A1, A2, B1, B2;
        rep(i, 0, n)
        {
            if ((a[i] >> p) & 1)
                A1.push_back(a[i] & ((1 << p) - 1));
            else
                A2.push_back(a[i] & ((1 << p) - 1));
            if ((b[i] >> p) & 1)
                B1.push_back(b[i] & ((1 << p) - 1));
            else
                B2.push_back(b[i] & ((1 << p) - 1));
        }
        sort(A1.begin(), A1.end());
        sort(A2.begin(), A2.end());
        sort(B1.begin(), B1.end());
        sort(B2.begin(), B2.end());
        ll cnt = 0;
        rep(i, 0, sz(A1))
        {
            int pos = lower_bound(B1.begin(), B1.end(), (1 << p) - A1[i]) - B1.begin();
            cnt += sz(B1) - pos;

            pos = lower_bound(B2.begin(), B2.end(), (1 << p) - A1[i]) - B2.begin();
            cnt += pos;
        }
        rep(i, 0, sz(A2))
        {
            int pos = lower_bound(B1.begin(), B1.end(), (1 << p) - A2[i]) - B1.begin();
            cnt += pos;

            pos = lower_bound(B2.begin(), B2.end(), (1 << p) - A2[i]) - B2.begin();
            cnt += sz(B2) - pos;
        }
        if (cnt % 2 == 1)
            ans |= (1 << p);
    }
    cout << ans << "\n";
    return 0;
}

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

typedef long long ll;

int main()
{
    int n;
    cin>>n;
    ll ans;
    cin>>ans;
    while(--n){
        ll t;
        cin>>t;
        ans=ans/__gcd(ans,t)*t;
    }
    cout<<ans;

}


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

bool kai(string S){
    string SS = S;
    reverse(S.begin(),S.end());
    return S == SS;
}

int main(){
    string S;
    cin >> S;
    int l = S.size();
    int k = (l-1)/2;
    string sub1 = S.substr(0,k) , sub2 = S.substr(k+1,k);
    if(kai(S) && kai(sub1) && kai(sub2)) cout << "Yes" << endl;
    else cout << "No" << endl;
}   

Measured memory_bytes: 256