akhauriyash/Code-Regression huggingface dataset:
#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, X, T;
    cin >> N >> X >> T;

    int ans = 0;
    while (N > 0)
    {
        N -= X;
        ans += T;
    }

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

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }

        
  int main(){
    lint h,w;
    cin>>h>>w;
    lint a=(h+1)/2;
    lint b=(w+1)/2;
    if(h==1||w==1)cout<<1;
   else if(h%2==0&&w%2==0)cout<<h*w/2;
    else if(h%2==0&&w%2==1)cout<<(lint)(h*w/2);
    else if(h%2==1&&w%2==0)cout<<(lint)(h*w/2);
    else cout<<(lint)(a*b+(a-1)*(b-1));
  }

  
     
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n;
  cin >> n;
  vi a(n+2);
  for (int i = 1; i <= n; ++i)  cin >> a[i];
  int sum = 0;
  for (int i = 0; i <= n; ++i)  {
    sum += abs(a[i]-a[i+1]);
  }
  vi ans;
  for (int i = 1; i <= n; ++i) {
    ans.pb(sum - abs(a[i-1]-a[i]) - abs(a[i]-a[i+1]) + abs(a[i-1]-a[i+1]));
  }
  rep(i,ans.size()) printf("%d\n", ans[i]);
  return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

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

  string t;
  rep(i, s.length()) {
    if(s[i]!='x') t+= s[i];
  }

  string u(t);
  reverse(u.begin(), u.end());

  if(u!=t) {
    cout << -1 << endl;
    return 0;
  }

  int res = 0;
  int m = 0, n = s.length()-1;
  while( n - m >= 1 ) {
    //printf("s[%d]:%c vs s[%d]:%c\n", m, s[m], n, s[n]);                                
    if(s[m] != s[n]) {
      if(s[n] == 'x') n--;
      if(s[m] == 'x') m++;
      res++;
    }
    else { n--; m++; }
  }

  cout << res << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

// dir := true x以下, xより大きい 
//        false xより大きい, x以下
ll count(vector<ll> &A, ll x, int i, int s, int t, bool dir) {
    if (t <= s) return 0;
    if (dir) {
        if (A[i] * A[s] > x) return 0;
        if (A[i] * A[t-1] <= x) return t-s;
        int l = s; // x以下
        int r = t-1; // xより大きい
        while (r-l > 1) {
            int mid = (l+r) / 2;
            if (A[i] * A[mid] <= x) l = mid;
            else r = mid;
        }
        return l+1-s;
    } else {
        if (A[i] * A[t-1] > x) return 0;
        if (A[i] * A[s] <= x) return t-s;
        int l = s; // xより大きい
        int r = t-1; // x以下
        while (r-l > 1) {
            int mid = (l+r) / 2;
            if (A[i] * A[mid] <= x) r = mid;
            else l = mid;
        }
        return t-r;
    }
}

// 積がx以下のペアがいくつあるか
ll count(vector<ll> A, ll x) {
    ll res = 0;
    int pos_0 = lower_bound(A.begin(), A.end(), 0) - A.begin(); // 0以上の位置
    for (int i=0; i<(int)A.size()-1; ++i) {
        if (A[i] < 0) {
            if (A[i+1] < 0) {
                res += count(A, x, i, i+1, pos_0, false);
                res += count(A, x, i, pos_0, (int)A.size(), false);
            } else {
                res += count(A, x, i, i+1, (int)A.size(), false);
            }
        } else {
            if (A[i+1] < 0) {
                res += count(A, x, i, i+1, pos_0, true);
                res += count(A, x, i, pos_0, (int)A.size(), true);
            } else {
                res += count(A, x, i, i+1, (int)A.size(), true);
            }
        }
    }
    return res;
}

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for (int i=0; i<N; ++i) cin >> A[i];
    sort(A.begin(), A.end());

    ll l, r;
    l = -1e18-1; // K未満
    r = 1e18+1; // K以上
    while (r-l > 1) {
        ll mid = (l+r)/2;
        if (K <= count(A, mid)) r = mid;
        else l = mid;
    }
    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3428
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {

        Scanner scan=new Scanner(System.in);

        int a=scan.nextInt();
        int b=scan.nextInt();
        int c=scan.nextInt();
        if(a+b==c || b+c==a || c+a==b)
            System.out.println("Yes");
        else
            System.out.println("No");

    }
}


Measured memory_bytes: 9684
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;

const int maxn = 2e5+100;

vector<int> f[maxn];
int id1,dth,id2;
void dfs(int u,int fa,int deep)
{
	if(deep>dth) {
		dth = deep; id1=u;
	}
	for(int i=0;i<f[u].size();i++)
	{
		int v=f[u][i];
		if(v==fa) continue;
		dfs(v,u,deep+1);
	}
}
int n,x,y;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	if(n==1){
		cout<<"First"<<endl;
		return 0;
	}
	for(int i=1;i<n;i++)
	{
		cin>>x>>y;
		f[x].push_back(y);
		f[y].push_back(x);
	}
	dfs(1,-1,1);dth=0;
	dfs(id1,-1,1);
	if(dth%3==2) cout<<"Second"<<endl;
	else cout<<"First"<<endl;
	return 0;
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
//typedef
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<string> VS;
//repetition
#define FOR(i,a,b) for(int i=int(a); i<int(b); ++i)
#define FORD(i,a,b) for(int i=int(a); i<int(b); --i)
#define REP(i,N) for(int i=0; i<int(N); ++i)
#define REPD(i,N) for(int i=0; i<int(N); --i)
//container util
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//constant
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //配列の最大のrenge
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
    ll a,b,c,d;cin>>a>>b>>c>>d;
    vector<ll> g;
    g.PB(a*c);
    g.PB(a*d);
    g.PB(b*c);
    g.PB(b*d);
    cout<<*max_element(ALL(g));
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int NumStr(string str)
{
	int n = str.size();
	int sum = 0;
	for(int i=0; i<n; i++){
		if(str[i] == 'A')sum += pow(4.,i) * 1;
		else if(str[i] == 'C')sum += pow(4.,i) * 2;
		else if(str[i] == 'G')sum += pow(4.,i) * 3;
		else if(str[i] == 'T')sum += pow(4.,i) * 4;
	}
	return sum;
}

void InsertFlag(vector<bool> &flag, string str)
{
	int num_str = NumStr(str);
	flag[num_str] = true;
}
void FindFlag(vector<bool> &flag, string str)
{
	int num_str = NumStr(str);
	if(flag[num_str] == true)cout << "yes" << endl;
	else if(flag[num_str] == false)cout << "no" << endl;
}

int main()
{
	int n;
	cin >> n;
	vector<bool> flag;
	flag.resize(16777216);
	
	for(int i=0; i<n; i++){
		string command, str;
		cin >> command >> str;
		if(command == "insert")InsertFlag(flag, str);
		else if(command == "find")FindFlag(flag, str);
	}
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int sum_digits(int x) {
    string x_str = to_string(x);
    int res = 0;
    for (int i = 0; i < x_str.size(); i++) {
        res += ctoi(x_str.at(i));
        }
    return res;
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    int cnt = 0;
    for (int n = 1; n < N + 1; n++) {
        int s = sum_digits(n);
        //cout << s;
        if (A <= s && s <= B) cnt += n;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)
    val char = sc.next()
    val vowel = Set("a", "i", "u", "e", "o")
    if (vowel contains char) {
      println("vowel")
    } else {
      println("consonant")
    }
  }
}

Measured memory_bytes: 22452
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))

result = [[None] * W for _ in range(H)]
d = 1
x, y = 0, 0
for i in range(N):
    t = a[i]
    while t > 0:
        result[y][x] = i + 1
        x += d
        if x == -1 or x == W:
            x -= d
            d = -d
            y += 1
        t -= 1

for i in range(H):
    print(*result[i])


Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i,N) cin >> A[i];
	sort(all(A));
	ll sum = 0;
	set<int> s;
	rep(i,N) {
		if(A[i] > sum*2) {
			s.clear();
		}
		s.insert(i);
		sum += A[i];
	}
	cout << s.size() << endl;
	return 0;
}


Measured memory_bytes: 5376
a,b,k = gets.chomp.split(" ").map(&:to_i)
n = a+k-1
m = b-k+1
if n >= m
  (a..b).each do |i|
    puts i
  end
else
  (a..n).each do |i|
    puts i
  end
  (m..b).each do |i|
    puts i
  end
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
char s[300005];
int num[1000],td[1000];
int main(){
	int n;scanf("%d",&n);
	scanf("%s",s+1);int ans=n;
	for (int i=1;i<=n;i++) num[s[i]]++;
	for (int i=1;i<=n;i++){
		int now=td['W'];
		td[s[i]]++;
		now+=num['E']-td['E'];
		ans=min(ans,now);
	}
	printf("%d",ans);
}

Measured memory_bytes: 512
using System;
using System.Windows;
using System.Collections.Generic;
using System.Linq;

class Program
 {
        static void Main(string[] args)
        {
          //入力を受け取る
          string[] tmp = Console.ReadLine().Split(' '); 
          int N = int.Parse(tmp[0]);
          int K = int.Parse(tmp[1]);
          string S = Console.ReadLine();
          int cnt = 0;
          if(S[0] == 'R' && S[1] == 'R'){
            cnt++;
          }
          if(S[N-1] == 'L' && N > 1 && S[N-2] == 'L'){
            cnt++;
          }       
          for (int i = 1; i < N-1; i++){
            if(S[i] == 'R' && S[i] == S[i+1]){
              cnt++;
            }else if(S[i] == 'L' && S[i] == S[i-1]){
              cnt++;
            }
          }
          if(cnt+K*2 >= N-1){
           System.Console.WriteLine(N-1);
          }else{
            System.Console.WriteLine(cnt+K*2);
          }
        }
 }

Measured memory_bytes: 13140
#include <stdio.h>

int main(){
  int x1, y1, x2, y2;

  scanf( "%d%d%d%d", &x1, &y1, &x2, &y2 );
  int x3, y3, x4, y4;
  x3 = x2 - ( y2 - y1 ); y3 = y2 + ( x2 - x1 );
  x4 = x1 - ( y2 - y1 ); y4 = y1 + ( x2 - x1 );

  printf( "%d %d %d %d\n", x3, y3, x4, y4 );

  return 0;
}

Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            long n = in.nextLong();
            long ans = 2 * (n / 11) + (n % 11 > 6 ? 2 : 1);
            ans -= n % 11 == 0 ? 1 : 0;
            out.println(ans);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

    }
}



Measured memory_bytes: 22228
W, H = map(int, input().split())
P = [(int(input()), 0) for i in range(W)]
Q = [(int(input()), 1) for i in range(H)]

E = sorted(P + Q)
used = [W + 1, H + 1]

ans = 0
for e, f in E:
    ans += e * used[1 - f]
    used[f] -= 1

print(ans)


Measured memory_bytes: 27736
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;



int main()
{
    long long int n, k, t, i, sum = 0;
    vector <long long int> h;

    cin >> n >> k;
    for (i = 0; i < n; ++i)
    {
        cin >> t;
        h.push_back(t);
    }

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

    if (k > n)
    {
        cout << 0;
    }
    else
    {
        for (i = 0; i < n - k; ++i)
        {
            sum += h[i];
        }
        cout << sum;
    }
        

    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
#define MSG(a) cout << #a << " " << a << "\n";

int main(){
  string S,T; cin >> S >> T;
  int ans;ans = 0;
  if(S[0] == T[0]) ans++; 
  if(S[1] == T[1]) ans++;
  if(S[2] == T[2]) ans++;
  cout << ans <<endl;





}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define QS ios_base::sync_with_stdio(false);
typedef long long ll;
const ll INF = 1e18;
const int MOD = 1e9+7;
using namespace std;

string s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
void shift(int n){
    for(int i = 0; i < 26; ++i){
        int cnt = 0;
        char ch = s[i];
        while(cnt < n){
            if(ch == 'Z'){
                ch = 'A';
            }
            else ++ch;

            cnt++;
        }
        s[i] = ch;
    }
}
int main(){
//freopen("output.txt", "w", stdout);
    QS
    int n;

    string ss;
    cin >> n >> ss;
    shift(n);
    //cout << s;
    for(int i = 0; i < ss.size(); ++i){
        cout << s[ss[i]-'A'];
    }
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

bool cmp(pll a, pll b)
{

    return a.ss  < b.ss;
}

int main()
{

    ll n, k;
    cin >> n >> k;
    vector<ll> vv;
    map<ll,ll> m;
    for(ll i = 0; i < n; i++)
    {

        ll x;
        cin >> x;
        if(m[x]==0) vv.pb(x);
        m[x]++;
    }
    vector<pll> v;
    for(ll i = 0;i<vv.size(); i++)
    {

        ll x = vv[i];
        v.pb(mp(x,m[x]));
    }
    ll z;
    if(vv.size() <= k) z=0;
    else z = vv.size()-k;
    sort(all(v),cmp);
    ll ans = 0;
    for(ll i = 0; i  <z; i++) ans+=v[i].ss;
    cout << ans;
}


Measured memory_bytes: 20464
N = int(input())
A = [int(x) for x in input().split()]
from statistics import mean
from math import floor, ceil
meanA = mean(A)
if meanA < floor(meanA) + 0.5:
    meanA = floor(meanA)
else:
    meanA = ceil(meanA)
ans = 0
for a in A:
    ans += (a-meanA)**2
print(ans)

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 100000002;
int gcd_2(int a, int b){
	if(b == 0) return a;
	return gcd_2(b, a%b);
}

int gcd_3(int a, int b, int c){
	int tmp = gcd_2(a, b);
	return gcd_2(tmp, c);
}

int main(){
	ll ans = 0;
	int k; cin >> k;
	for (int i=1; i<=k; i++){
		for (int j=1; j<=k; j++){
			for (int h=1; h<=k; h++){
				ans += gcd_3(i, j, h);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3592
import sys
def input(): return sys.stdin.readline().strip()


def main():
    n = int(input())
    train = []
    for _ in range(n - 1):
        c, s, f = map(int, input().split())
        train.append((c, s, f))
    
    for i in range(n):
        if i == n - 1:
            print(0)
            continue
        start = i + 1
        time = train[i][0] + train[i][1]
        while start < n - 1:
            if time < train[start][1]:
                time = train[start][0] + train[start][1]
            elif time % train[start][2] == 0:
                time += train[start][0]
            else:
                time += train[start][2] - (time % train[start][2])
                time += train[start][0]
            start += 1
        print(time)


if __name__ == "__main__":
    main()


Measured memory_bytes: 71460
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

using ll = long long;

#define fst first
#define snd second
#define mp make_pair
#define mt make_tuple

/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) (LL((v).size()))

#define FIND(v, k) (v).find(k) != (v).end()
#define VFIND(v, k) find(ALL(v), k) != (v).end()

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.fst << "," << p.snd << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
T sq(T a) {
    return a * a;
}

template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
    int K, N;
    cin >> K >> N;

    if (K % 2 == 0) {
        cout << K / 2 << " ";
        for (int i = 0; i < N - 1; ++i) {
            cout << K << " ";
        }
        cout << endl;
    } else {
        vector<int> ans(N, (K + 1) / 2);
        for (int i = 0; i < N / 2; ++i) {
            if (ans.back() == 1) {
                ans.pop_back();
            } else {
                --ans.back();
                while (ans.size() < N) {
                    ans.push_back(K);
                }
            }
            // cout << ans << endl;
        }

        for (auto v : ans) {
            cout << v << " ";
        }
        cout << endl;
    }
    return 0;
}


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

int main(){
  string S, T;
  cin >> S >> T;
  
  int ans=0;
  for(int i=0; i < S.size(); i++){
    if(S[i] != T[i]) ans += 1;
  }
  
  cout << ans << endl;
  return 0;
}

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


int main() {
  int N,K,C;
  string S,T;
  cin >> N >> K >> C >> S;
  T = S;
  reverse( T.begin(), T.end() );
  vector<int> l(N,-1),r(N,-1);
  int nd = 0, d = 0;
  
  REP(i,N) {
    if ( (S[i] == 'x') || (nd > 0) ) {
//      l[i] = d;
      nd--; continue;
    }
    nd = C;
    l[i] = ++d;
  }
  nd = 0, d = 0;
  REP(i,N) {
    if ( (T[i] == 'x') || (nd > 0) ) {
//      r[i] = d;
      nd--; continue;
    }
    nd = C;
    r[i] = ++d;
  }
  REP(i,N) {
    if ( (l[i] != -1) && (r[N-i-1] != -1) && (l[i] + r[N-i-1] == K+1) ) cout << (i+1) << endl;
  }

//  REP(i,N)  cout << l[i] << " ";
//  cout << endl;
//  REP(i,N)  cout << r[N-i-1] << " ";
//  cout << endl;

}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i=(a);i<(b);++i)
using namespace std;

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

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const ll MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795;

int main()
{
	string inp;
	cin >> inp;
	cout << "2018/01/" << inp[8] << inp[9] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if(b % a == 0) cout << a + b << endl;
    else cout << b - a << endl;
}

Measured memory_bytes: 764
// Author: 23forever
#include <bits/stdc++.h>
#define pii pair<int, int>
#define mp make_pair
#define fi first
#define se second
typedef long long LL;
const int MAXN = 100;
const int MAXM = 100000;
using namespace std;

inline int read() {
  int x = 0, w = 1;
  char c = ' ';

  while (c < '0' || c > '9') {
    c = getchar();
    if (c == '-') w = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }

  return x * w;
}

int n, m, w[MAXN + 5], v[MAXN + 5], dp[MAXM + 5];
int sum;

void init() {
  n = read();
  m = read();
  for (int i = 1; i <= n; ++i) {
    w[i] = read();
    v[i] = read();
    sum += v[i];
  }
}

int main() {
#ifdef forever23
  freopen("test.in", "r", stdin);
  //freopen("test.out", "w", stdout);
#endif
  init();

  memset(dp, 0x3f, sizeof(dp));
  dp[0] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = sum; j >= v[i]; --j) {
      dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
    }
  }

  for (int i = sum; ~i; --i) {
    if (dp[i] <= m) {
      printf("%d\n", i);
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
using namespace std;
class prog {
public:
	int S, T;
	prog(){}
	prog(int s, int t):S(s),T(t){}
	prog(const prog& ano):S(ano.S),T(ano.T){}
};
int main() {
	int n, c;
	scanf("%d %d", &n, &c);

	vector<vector<prog>> chan(c);
	for (int i = 0; i < n; i++) {
		int s, t, cc;
		scanf("%d %d %d", &s, &t, &cc);
		chan[cc - 1].emplace_back(s, t);
	}
	vector<prog> all_chan;
	for (int i = 0; i < c; i++) {
		if (chan[i].empty())
			continue;
		sort(chan[i].begin(), chan[i].end(), [](const prog& a, const prog& b) {
			return a.S < b.S;
		});
		all_chan.emplace_back(chan[i][0]);
		for (int j = 1; j < chan[i].size(); j++) {
			if (all_chan.back().T == chan[i][j].S)
				all_chan.back().T = chan[i][j].T;
			else
				all_chan.emplace_back(chan[i][j]);
		}
	}
	sort(all_chan.begin(), all_chan.end(), [](const prog& a, const prog& b) {
		if (a.S != b.S)
			return a.S < b.S;
		return a.T < b.S;
	});
	int recorder = 1;
	priority_queue<int, vector<int>, greater<int>> record_que;
	record_que.emplace(0);
	for (int i = 0; i < all_chan.size(); i++) {
		if (record_que.top() < all_chan[i].S)
			record_que.pop();
		else
			recorder++;
		record_que.emplace(all_chan[i].T);
	}

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

Measured memory_bytes: 2552
N=int(input())
h=list(map(int,input().split()))

ans=0
while sum(h)>0:
  for i in range(N):
    if i<N-1 and h[i]>0 and h[i+1]==0:
      ans+=1
    else:
      if i==N-1 and h[i]>0:
        ans+=1
    if h[i]>0:
      h[i]-=1
print(ans)      

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        int S;
        cin >> S;

        for (int i = 111; i < 1000; i += 111)
        {
                if (i - S >= 0)
                {
                        cout << i << endl;
                        return 0;
                }
        }

        return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }

int main() {
	SS(int,n,m);
	SV(int,a,m);
	int sum=0;
	rep(i,m)sum+=a[i];
	if(sum>n){
		p(-1);
		return 0;
	}
	p(n-sum);
}

Measured memory_bytes: 3688
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define Rep(i,a,n)for(LL i=(LL)(a);i<(LL)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Repp(i,l,r,k)for(LL i=(l);i<(r);i+=(k))
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007//1000000009,998244353 
int upi(const void* a, const void* b) { return*(int*)a<*(int*)b ? -1 : *(int*)a> * (int*)b ? 1 : 0; }
int downi(const void* a, const void* b) { return*(int*)a<*(int*)b ? 1 : *(int*)a> * (int*)b ? -1 : 0; }
void sortupi(int* a, int n) { qsort(a, n, sizeof(int), upi); } //1,2,3,4,...
void sortdowni(int* a, int n) { qsort(a, n, sizeof(int), downi); }
int upLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? -1 : *(LL*)a> * (LL*)b ? 1 : 0; }
int downLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? 1 : *(LL*)a> * (LL*)b ? -1 : 0; }
void sortupLL(LL* a, int n) { qsort(a, n, sizeof(LL), upLL); }
void sortdownLL(LL* a, int n) { qsort(a, n, sizeof(LL), downLL); }
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
LL gcd(LL p, LL q) { while (q) { LL t = p % q; p = q; q = t; }return p; }
LL modpow(LL a, LL n, int m) { LL x = 1; for (a %= m; n; n /= 2)n & 1 ? x = x * a % m : 0, a = a * a % m; return x; }
#define invmodpow(b,p)modpow(b,p-2,p)// a/b≡a*b^{-1}(mod p)...return b^{-1}(mod p)
typedef struct fac { LL n, exp; }F;
int fact(LL n,F*a){LL x,i,j,c=0;x=n;for(i=2;i*i<=x;i++){for(j=1;x%i==0;j++)x/=i;if(j>1){a[c].n=i;a[c].exp=j-1;c++;}}if(x-1){a[c].n=x;a[c].exp=1;c++;}return (int)c;}
//snippet
#define N 1009

int main(){
  LL a,b; F c[N];
  scanf("%lld%lld",&a,&b);
  printf("%d",fact(gcd(a,b),c)+1);
}


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

int main() {
   int H, N,n;
   int sum = 0;
    cin >> H >> N;

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

            if (H <= sum)
                cout << "Yes" << endl;
            else
                cout << "No" << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
using namespace std;
const long long N = 1e5+507;
long long a[N];
int main ()
{
    unsigned long long  m,x;
    int i,n;
    long double y;
    cin>>n;
    y=1000000000000000000;
    for (i=1; i<=n; ++i)
    {
        cin>>a[i];
        if (!a[i])
        {
            cout<<0;
            return 0;
        }
    }
    m=a[1];
    for (i=2; i<=n; i++)
    {
        x=a[i];
        if (!x)
        {
            cout<<"0\n";
            return 0;
        }
        else if (y/x>=m)
                m=m*x;
        else
        {
            cout<<"-1\n";
            return 0;
        }
    }
    cout<<m<<"\n";
}



Measured memory_bytes: 4368
/*
power code taken from geeks for geeks
*/
// cout << setprecision (2) << fixed << 1.2;

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;


const ll INF = 1e18 + 5;
const ll MAX_N = 1e4 + 5;
const ll MODD = 1e9 + 7;
const ld PI = 3.14159265358979323846;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
ld modd(ld a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}


struct p_str {
    ll a, b;
};



void solve() {
    ll n;
    cin >> n;
    
    ll ans[MAX_N];
    memset(ans, 0, sizeof(ans));

    for(ll i = 1; i <= 100; i++) {
        for(ll j = i; j <= 100; j++) {
            for(ll k = j; k <= 100; k++) {
                set<ll> st;
                st.insert(i);
                st.insert(j);
                st.insert(k);
                ll val = (i * i) + (j * j) + (k * k);
                val += i * j;
                val += i * k;
                val += j * k;
                if(val >= MAX_N) {
                    break;
                }
                ll v = 3 * 2;
                if(st.size() == 1) {
                    v = 1;
                }
                else if(st.size() == 2) {
                    v = 3;
                }
                ans[val] += v;
            }
        }
    }

    for(ll i = 1; i <= n; i++) {
        cout << ans[i] << endl;
    }
}


int main(){

  


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    
    ll t=1;
    
    // cin>>t;


    while(t--){
        
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3692
// Code for B - Go to Jail
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,x,y) for(ll i=x;i<(ll)(y);i++)

#define MOD 1000000007
#define mod(x) ( (x) % MOD + MOD ) % MOD

#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T, typename U> void view(const std::map<T, U>& m){ for(const auto& e : m){ std::cout << e.first << "=>" << e.second << " "; } std::cout << std::endl; }

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

  vector<int> D1(N), D2(N);
  REP(i, N) {
    cin >> D1[i] >> D2[i];
  }

  REP(i, N - 2) {
    bool x = true;
    REP(j, 3) {
      if ( D1[i+j] != D2[i+j] ) {
          x = false;
      }
    }
    if (x) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
<?php
$input = trim(fgets(STDIN));
$array = explode(" ", $input);
$a = $array[0];
$b = $array[1];
if($a > $b){
    echo "a > b";
}elseif ($a == $b) {
    echo "a == b";
}elseif ($a < $b){
    echo "a < b";
}
?>

Measured memory_bytes: 15064
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)
#define _popcnt __builtin_popcount

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

struct BIT{
  // 1-indexed BIT
private:
  int N; vector<int> bit;
public:
  BIT(int size){
    N = size;
    bit.assign(N+1, 0);
  }
  void add(int a, int w){
    for(int x = a; x <= N; x += x & -x)
      bit[x] += w;
  }
  int sum(int a){ // prefix sum
    int res = 0;
    for(int x = a; x > 0; x -= x & -x)
      res += bit[x];
    return res;
  }
};

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

	int N, Q; string S; cin >> N >> S >> Q;
	vector<BIT> BITs(26, BIT(N));
	REP(i, N){
		BITs[S[i]-'a'].add(i+1, 1);
	}
	REP(_, Q){
		int type; cin >> type;
		if(type == 1){
			int idx; char c; cin >> idx >> c;
			if(S[idx-1] == c) continue;

			BITs[S[idx-1]-'a'].add(idx, -1);
			BITs[c-'a'].add(idx, 1);
			S[idx-1] = c;
		} else {
			int l, r; cin >> l >> r;
			int ans = 0;
			REP(i, 26){
				if(BITs[i].sum(r) - BITs[i].sum(l-1) > 0) ans++;
			}
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 106396
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#ifndef LL
#define LL long long
#endif
#ifndef uLL
#define uLL unsigned long long
#endif
#ifndef uL
#define uL unsigned int
#endif
#ifndef iL
#define iL int
#endif
#ifndef iS
#define iS short
#endif
#ifndef uS
#define uS unsigned short
#endif
#ifndef uC
#define uC unsigned char
#endif
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define abs(a) (((a)<0)?(-(a)):(a))
#define sgn(a) (((a)<0)?(1):(0))
#define movs(a,b,l) (memmove((a),(b),sizeof(*(b))*(l)))
#define stosb(a,b,l) (memset((a),(b),sizeof(*(a))*(l)))
int main()
{
	LL a,b,c,i,j,k,n,m;
	scanf("%lld%lld",&n,&m);
	printf("%lld\n",n-m+1);
	return 0;
}

Measured memory_bytes: 128
import sys
N = int(input())

A = tuple(map(int, input().split()))

res = 1
overflow = False

if 0 in A:
  print(0)
  sys.exit()

i = 0
while i < len(A) and res <= 10**18:
  res *= A[i]
  i += 1


if res > 10 ** 18:
  print(-1)
else:
  print(res)

Measured memory_bytes: 21684
#include <iostream>
#include <climits>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	int n, dp[100][100] = {}, c[100][2];
	cin >> n;
	rep(i,n) {
		cin >> c[i][0] >> c[i][1];
	}
	rep(i,100) {
		rep(j,100) {
			if(i==j) continue;
			dp[i][j] = INT_MAX;
		}
	}
	rep2(i,1,n) {
		rep(j,n-i) {
			rep2(k,j,j+i) {
				dp[j][j+i] = min(dp[j][j+i], dp[j][k]+dp[k+1][j+i]+c[j][0]*c[k][1]*c[k+1][0]*c[j+i][1]);
			}
		}
	}
	cout << dp[0][n-1] << endl;
	return 0;
}

Measured memory_bytes: 1204
#include<stdio.h>
#include<math.h>
#define ture 1
#define false -1

int isPrime(int x){
  int i;
  double y,e= x%2,z;
  if(x==2)return ture;

  if(x<2 ||e ==0)return false;
  i=3;
  y=sqrt((double)x);
  while(i<= y){
    z= x%i;
    if(z==0)return false;
    i=i+2;//?\???° 3+2n;
  }return ture;
}

int main(){
  int n,count=0;
  int i,j;
  int p;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&p);
    if(isPrime(p)==ture)count++;
  }

  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
int main(){
  long long int a,b,c,d;
  long long int r,temp,cnt;
  scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
  cnt = b/c - (a-1)/c + b/d -(a-1)/d;
  if(c<d){ temp=c; c=d; d=temp; }
  r =c%d; temp=c*d;
  while(r!=0){
    c=d;
    d=r;
    r=c%d;
  }
  cnt -= b/(temp/d) -(a-1)/(temp/d);
  printf("%lld\n",b-a+1-cnt);
  return 0;
}

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

int main(){
	int a, b, c, f, n, num, i, j,cnt, abc[300], test[1000][4] = {0};
	
	while(true){
		cin>>a>>b>>c;
		if(!a)if(!b)if(!c) break;
		num = a+b+c;
		cin>>n;
		for(i=0;i<num;i++){
			abc[i] = 2;
		}
		for(i=0;i<n;i++){
			cin>>test[i][0]>>test[i][1]>>test[i][2]>>test[i][3];
			test[i][0]--; test[i][1]--; test[i][2]--;
			if(test[i][3]){
				abc[test[i][0]] = abc[test[i][1]] = abc[test[i][2]] = 1;
			}
		}
		for(i=0;i<n;i++){
			cnt=0;
			if(!test[i][3]){
				for(j=0;j<3;j++){
					if(abc[test[i][j]] == 1){
						cnt++;
					}else{
						f=j;
					}
				}
				if(cnt == 2) abc[test[i][f]]=0;
			}
		}
		for(i=0;i<num;i++){
			cout<<abc[i] << endl;
		}
	}
	return 0;
}

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

using namespace std;

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

    int a, b;
    cin >> a >> b;
    cout << max(a - 2 * b, 0) << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n';
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> g(n, vector<pair<int, int>>());
    int u, v, w;
    REP(i, n - 1) {
        cin >> u >> v >> w;
        u--; v--;
        g[u].emplace_back(v, w);
        g[v].emplace_back(u, w);
    }

    vector<int> ans(n, 0);
    function<void(int, int)> dfs = [&](int c, int p) {
        if (p != -1 && sz(g[c]) == 1) return;
        for (auto x : g[c]) {
            if (x.first == p) continue;
            if (x.second % 2 == 0) ans[x.first] = ans[c];
            else ans[x.first] = (ans[c] + 1) % 2;
            dfs(x.first, c);
        }
    };

    dfs(0, -1);
    REP(i, n) cout << ans[i] << endl;
}



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

signed main() {
    int n;
    cin >> n;

    int X = 0;
    vector<tuple<int,int,int>> v;
    for(int i = 0; i < n; i++){
        int a,b;
        cin >> a >> b;

        X -= b;
        int c = a + b;
        v.emplace_back(c,a,b);
    }
    sort(all(v));
    reverse(all(v));

    for(int i = 0; i < n; i+=2){
        X += get<0>(v[i]);
    }
    cout << X << endl;
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;

int n,k;
int main(){
  cin >> n >> k;
  vector<int>v(n);
  int ans = 0;
  for(int i = 0 ; i < n; i++) cin >> v[i];
  int cnt = min(n,k);
  for(int a = 0; a<=cnt; a++){  //左から，a回とる
    for(int b = 0; b<=cnt-a; b++){ //右から，b回とる
      vector<int>get; //拾ったやつまとめ
      for(int i = 0; i<a; i++)get.push_back(v[i]);      //min(n,k)なので，
      for(int i = 0; i<b; i++)get.push_back(v[n-1-i]);  //重複してとることはない．
      sort(all(get));
      int tmp = accumulate(all(get), 0);
      for(int i = 0; i < min(k-a-b, (int)get.size()); i++){
        if(get[i] < 0)tmp -= get[i];
      }
      ans = max(ans, tmp);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// O(N^2+NM) or O(NMlogN)
#include<cstdio>
const int MaxN=5010,MaxM=210;
int N,M,A[MaxN],B[MaxN][MaxM],stk[MaxN],left[MaxN],right[MaxN];
long long S[MaxN][MaxN],x[MaxN];
void cmax(long long&a,long long b){b>a?a=b:1;}
int main(){
	scanf("%d%d",&N,&M);
	for(int i=1;i<N;i++)scanf("%d",A+i),x[i+1]=x[i]+A[i];
	for(int i=1;i<=N;i++)
		for(int j=1;j<=M;j++)scanf("%d",B[i]+j);
	for(int j=1;j<=M;j++){
		int tp=0;
		for(int i=1;i<=N;i++){
			while(tp&&B[stk[tp]][j]<=B[i][j])right[stk[tp--]]=i;
			left[i]=stk[tp];
			stk[++tp]=i;
		}
		while(tp)right[stk[tp--]]=N+1;
		for(int i=1;i<=N;i++){
			S[left[i]+1][right[i]-1]+=B[i][j];
			S[left[i]+1][i-1]-=B[i][j];
			S[i+1][right[i]-1]-=B[i][j];
		}
	}
	long long ans=0;
	for(int i=1;i<=N;i++)
		for(int j=N;j>=i;j--)
			cmax(ans,(S[i][j]+=S[i-1][j]+S[i][j+1]-S[i-1][j+1])-x[j]+x[i]);
	printf("%lld\n",ans);
}

Measured memory_bytes: 200448