akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

#define int long long
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define MAX_N (1<<17)

struct SegTree {
  P seg[MAX_N*2-1];
  SegTree() {
    for (int i=0; i<MAX_N*2-1; i++) seg[i] = P(0, 0);
  }

  void update(int i, P x) {
    i += MAX_N-1;
    if (seg[i] >= x) return;
    seg[i] = x;
    while (i > 0) {
      i = (i-1) / 2;
      seg[i] = max(seg[i*2+1], seg[i*2+2]);
    }
  }
  P query(int a, int b, int k=0, int l=0, int r=MAX_N) {
    if (r <= a || b <= l) return P(0, 0);
    if (a <= l && r <= b) return seg[k];
    return max(
      query(a, b, k*2+1, l, (l+r)/2),
      query(a, b, k*2+2, (l+r)/2, r)
    );
  }
};

int N;
int A[100000];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> A[i], A[i]++;
  SegTree seg;
  rep(i, N) {
    P p = seg.query(0, A[i]);
    seg.update(A[i], P(p._1+1, p._2+A[i]-1));
  }
  cout<< seg.query(0, MAX_N)._2 << "\n";
  return 0;
}



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

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }


int main(){
    ll N ,M;
    cin >> N >> M;
    vector<ll> A(M,0);
    vector<ll> D(M - 1,0);
    for(int i = 0; i < M; i++) cin >> A[i];
    sort(A.begin() , A.end());
    for(int i = 0; i < M - 1; i++){
        D[i] = abs(A[i + 1] - A[i]);
    }
    sort(D.begin() ,D.end(),greater<ll>());
    ll ans = 0;
    for(int i = 0 + (N - 1); i < M - 1; i++){
        ans += D[i];
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 1792
from collections import deque

n = int(input())
l = list(map(int, input().split()))
ans = deque()
ans2 = 0
now = [0]*n

for i in range(n):
  i = n-i
  zoom = 2
  cnt = 0
  while i*zoom <= n:
    cnt += now[i*zoom-1]
    zoom += 1
  if (l[i-1] + cnt) % 2 == 1:
    now[i-1] = 1
    ans.appendleft(i)
    ans2 += 1
    
print(ans2)
print(*ans)

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

int gcd(int a, int b) {
;
	if(max(a, b) % min(a, b)==0){
		return min(a, b);
	}
	else {
		return gcd(min(a, b), max(a, b) % min(a, b));
	}
}

int main() {
	int N;
	cin >> N;
	vector<int> vec(N);
	for (int i = 0; i < N; i++) {
		cin >> vec.at(i);
	}
	if (N == 2) {
		cout << max(vec.at(0), vec.at(1)) << endl;
	}
	else {
		int maxi = 1;
		vector<int> gcd_memorized_from_first(N - 1);
		int gcd_memorized_from_end = vec.at(N - 1);
		int G = vec.at(0);
		for (int i = 0; i < N - 1; i++) {
			G = gcd(G, vec.at(i));
			gcd_memorized_from_first.at(i) = G;
		}
        maxi = max(maxi, G);
		for (int i = 0; i < N - 2; i++) {
			gcd_memorized_from_end = gcd(vec.at(N - i - 1), gcd_memorized_from_end);
			G = gcd(gcd_memorized_from_first.at(N - i - 3), gcd_memorized_from_end);
			maxi = max(maxi, G);
		}
        G = gcd(vec.at(1), gcd_memorized_from_end);
        maxi = max(maxi, G);
		cout << maxi << endl;
	}
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

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

    int ans = 0;
    if (400 <= X and X <= 599) {
        ans = 8;
    } else if (600 <= X and X <= 799) {
        ans = 7;
    } else if (800 <= X and X <= 999) {
        ans = 6;
    } else if (1000 <= X and X <= 1199) {
        ans = 5;
    } else if (1200 <= X and X <= 1399) {
        ans = 4;
    } else if (1400 <= X and X <= 1599) {
        ans = 3;
    } else if (1600 <= X and X <= 1799) {
        ans = 2;
    } else if (1800 <= X and X <= 1999) {
        ans = 1;
    }

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


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <cassert>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

struct DynamicModInt {
    using M = DynamicModInt;

  private:
    static uint MD;
    static ull iMD;
    uint v = 0;

  public:
    static void set_mod(uint _MD) {
        assert(2 <= _MD);
        MD = _MD;
        iMD = ull(-1) / _MD + 1;
    }
    DynamicModInt() {}
    DynamicModInt(ll _v) { set_v(uint(_v % MD + MD)); }
    uint val() const { return v; }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }

    M operator*(const M& r) const {
        ull c = ull(v) * r.v;
        ull d = (__uint128_t(c) * iMD) >> 64;
        return M().set_v(uint(c - d * MD + MD));
    }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const {
        pair<uint, ll> p = {MD, 0}, q = {v, 1};
        while (q.first) {
            uint t = p.first / q.first;
            p.first -= t * q.first;
            p.second -= t * q.second;
            swap(p, q);
        }
        return M(p.second);
    }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
uint DynamicModInt::MD;
ull DynamicModInt::iMD;

using Mint = DynamicModInt;

int main() {
    int n, mod;
    cin >> n >> mod;
    Mint::set_mod(mod);
    const int OFF = 3 * n + 10;
    VV<Mint> dp(3 * n + 1);
    dp[0] = V<Mint>(2 * OFF + 1);
    dp[1] = V<Mint>(2 * OFF + 1);
    dp[2] = V<Mint>(2 * OFF + 1);
    dp[3] = V<Mint>(2 * OFF + 1);
    dp[0][OFF] = 1;
    for (int i = 0; i < 3 * n; i++) {
        Mint invi = (i == 0 ? 1 : Mint(i).inv());
        for (int j = 0; j <= 2 * OFF; j++) {
            if (!dp[i][j]) continue;
            Mint idp = dp[i][j] * invi;
            if (i + 1 <= 3 * n) dp[i + 1][j + 1] += idp;
            if (i + 2 <= 3 * n) dp[i + 2][j - 1] += idp;
            if (i + 3 <= 3 * n) dp[i + 3][j] += idp;
        }
        if (i + 4 <= 3 * n) {
            swap(dp[i + 4], dp[i]);
            for (auto& x: dp[i + 4]) x = Mint(0);
        }
    }
    Mint sum = 0;
    Mint fact = 1;
    for (int i = 1; i < 3 * n; i++) fact *= Mint(i);
    for (int j = OFF; j <= 2 * OFF; j++) sum += fact * dp[3 * n][j];
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 640
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

A = sorted(A)

if N%2==0:
    l = A[:N//2]
    u = A[N//2:]
    ans = sum(u)*2-u[0] - (sum(l)*2-l[-1])
else:
    m = A[N//2]
    l = A[:N//2]
    u = A[N//2+1:]
    ans = max(sum(u)*2 - sum(l)*2 - m + l[-1], sum(u)*2 - sum(l)*2 + m - u[0])

print(ans)

Measured memory_bytes: 8284
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    while(1){
        int N,M;
        int fie[100][100];
        int data[4][50][50];
        int zany=10,zanx=10;
        cin>>N>>M;
        if(N==0&&M==0)break;
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                cin>>fie[i][j];
            }
        }
        for(int i=0;i<M;i++){
            for(int j=0;j<M;j++){
                cin>>data[0][i][j];
                data[1][j][M-i-1]=data[0][i][j];
                data[2][M-i-1][M-j-1]=data[0][i][j];
                data[3][M-j-1][i]=data[0][i][j];
            }
        }
        for(int i=0;i+M<=N;i++){
            for(int j=0;j+M<=N;j++){
                for(int k=0;k<4;k++){
                    int flg=1;
                    for(int l=0;l<M;l++){
                        for(int m=0;m<M;m++){
                            if(data[k][l][m]!=-1&&data[k][l][m]!=fie[i+l][j+m])flg=0;
                        }
                    }
                    if(flg){
                        for(int l=0;l<M;l++){
                            for(int m=0;m<M;m++){
                                if(data[k][l][m]!=-1&&(i+l<zany||(i+l==zany&&j+m<zanx)))zany=i+l,zanx=j+m;
                            }
                        }
                    }
                }
            }
        }
        if(zany==10)puts("NA");
        else cout<<zanx+1<<' '<<zany+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 1236
from math import sqrt
from math import floor
n,m = map(int,input().split())
d = m // n
ans = 1
for i in range(1,floor(sqrt(m))+1):
    if m % i == 0:
        x = m // i
        if i <= d:
            ans = max(ans,i)
        if x <= d:
            ans = max(ans,x)
print(ans)

Measured memory_bytes: 9184
#include<stdio.h>
#include<math.h>

void panduan(int shifa)
{

}

int main()
{
   int n;
   int temp;
   scanf("%d",&n);
   int c[502],s[502],f[502];
   int ans[502],i;
   for(i=1;i<n;i++)
   {
       scanf("%d %d %d",&c[i],&s[i],&f[i]);
   }
   for(int j=1;j<n;j++)
   {
       ans[j-1]=s[j];
     for(i=j;i<n;i++)
     {
       temp=ans[i-1]%f[i];
      if(temp==0)
        ans[i]=ans[i-1]+c[i];
      else
      {
          ans[i]=ans[i-1]+c[i]+f[i]-temp;
      }
       if(i<n-1)
      {
          if(ans[i]<s[i+1])
        ans[i]=s[i+1];
      }
     }
     printf("%d\n",ans[i-1]);
   }
   ans[n]=0;
   printf("0");
return 0;
 }


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

using namespace std;

int main(){
    int n;
    long long sum = 0; // long long にしないとエラーが出る
    int max = -10000000;
    int min = 10000000;
    cin >> n;
    int A[n-1];
    int i = 0;
    while(i<n){
        cin >> A[i];
        sum += A[i];
        max = std::max(A[i], max);
        min = std::min(A[i], min);
        ++i;
    }
    cout << min << " " << max << " " << sum << endl;

    return 0;
}


Measured memory_bytes: 3140
import java.util.*;
import java.text.*;
import java.math.*;

public class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		ArrayList<Integer> list = new ArrayList<Integer>();
		while(in.hasNext()){
			int weight = in.nextInt();
			int cu = 1;
			for(int i=0; i<10; i++){
				if(weight%2==1) list.add(cu);
				weight = weight/2;
				cu = cu*2;
			}
			for(int i=0; i<list.size()-1; i++){
				System.out.print(list.get(i)+" ");
			}
			System.out.println(list.get(list.size()-1));
			list.clear();
		}
	}
}

Measured memory_bytes: 12000
import { readFileSync } from 'fs'

function main(input: string) {
  const buttons = input.trim().split(' ').map(Number)

  const [first, second] = [...buttons, ...buttons.map(v => v - 1)].sort((a, b) => b - a)

  console.log(first + second)
}

main(readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 7500
#include <iostream>
#include <numeric>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {

	int N, X, Y;
	cin >> N >> X >> Y;
	int mmmax = 0;

	vector<int> vec(N);
	rep(i, N) {
		vec.at(i) = 0;
	}
	for (int i = 1; i < N ; i++) {
		for (int j = i + 1; j < N + 1; j++) {
			vec.at(min(j - i, abs(X - i) + abs(Y - j) + 1))++;
		}
	}
	for (int i = 1; i < N; i++) {
		cout << vec.at(i) << endl;
	}
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Test | diff Test.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Test.cpp && ./a.out

/*
 
 4/26/2020
 
 13:23-
 
 */

const int MAX_N=1e6+1;
II is[MAX_N];
int N,M;

int viz[MAX_N];
map<int,vector<II>> imos;
void solve() {
  int res=0;
  SETI cur;
  FORR(kvp,imos) {
    vector<II> xs=kvp.second;
    sort(ALL(xs));
    FORR(p,xs) {
      if(p.first==0) {
        if(!viz[p.second]) {
          ++res;
          FORR(i,cur) viz[i]=1;
          cur.clear();
        }
      } else {
        cur.emplace(p.second);
      }
    }
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>M;
  REP(i,M) {
    int l,r; cin>>l>>r;
    imos[l].emplace_back(1,i);
    imos[r].emplace_back(0,i);
  }
  solve();
  
  return 0;
}


Measured memory_bytes: 15868
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 200000;
int p;
int n;
int s[MAX_N];

int main() {
    fastio();

    cin >> n >> p;
    string temp;
    cin >> temp;
    transform(all(temp), s, [](char c) { return c - '0'; });

    map<int, int> cnt;
    cnt[0] = 1;

    ll cur = 0;
    ll ten = 1;
    ll ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (p == 2 || p == 5) {
            if (s[i] % p == 0) {
                cnt[0]++;
            }
            ans += (cnt[0] - 1);
        } else {
            cur = (cur + ten * s[i] % p) % p;
            ans += cnt[cur % p];
            cnt[cur % p]++;
        }

        ten = ten * 10 % p;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1684
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(a*b,c)<<NL;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stdlib.h>
using namespace std;
vector<int> balls;
bool dfs(int i,int left,int right,int len)
{
	if(i==len&&(balls[i-1]>left||balls[i-1]>right))return 1;
	if(balls[i-1]<left&&balls[i-1]<right)return 0;
	if(balls[i-1]>left){
		return dfs(i+1,balls[i-1],right,len);
	}
	if(balls[i-1]>right){
		return dfs(i+1,left,balls[i-1],len);
	}
	
}
int main()
{
	int T;
	cin>>T;
	while(T--){
		int x;
		int j=10;
		while(j--){
			cin>>x;
			balls.push_back(x);
		}
		if(dfs(1,-1,-1,10)){
			cout<<"YES"<<endl;
		}else cout<<"NO"<<endl;
		balls.clear();
	}
} 

Measured memory_bytes: 1204
#include <iostream>

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b > c + d) {
        cout << "Left" << endl;
    } else if (a + b == c + d) {
        cout << "Balanced" << endl;
    } else {
        cout << "Right" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
//https://beta.atcoder.jp/contests/abc087/tasks/arc090_a
#include <iostream>
using namespace std;

int main(){
    int N;
    cin >> N;
    int A[2][N];
    for ( int i = 0; i < 2; i++ ){
        for ( int j = 0; j < N; j++ ){
            cin >> A[i][j];
        }
    }   

    int ans = 0;
    int tmp = 0;

    for ( int i = 0; i < N; i++ ){
        for (int j = 0; j <= i; j++ ){
            tmp += A[0][j];
        }
        for (int j = i; j < N; j++ ){
            tmp += A[1][j];
        }
        if ( ans < tmp) ans = tmp;
        tmp = 0;
    }
    
    cout << ans << endl;

    return 0;
}


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

int main()
{
int n,k;
cin >> n >> k;
vector <string> v(n);
string s;
for (int i = 0; i < n; i++){
    cin >> s;
    v.push_back(s);
}
sort(v.begin(),v.end());

for (int i= 0; i<v.size(); i++){
    cout << v[i];
}


return 0;
}


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

int main() {
  int N, ans;
  
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  ans = 1;
  
  for (int i = 0; i < N -1; i++) {
    if (a.at(i) < a.at(i+1)) {
      ans ++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<string.h>
#include<stdio.h>
char str[64];
int main(){
	scanf("%s",str);
	int n=strlen(str);
	int ans=0;
	if(str[0]=='x')ans++;
	if(str[n-1]=='x')ans++;
	if(ans==2)printf("x\n");else printf("o\n");
}

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

int main() {
  int A,B,C;
  cin >> A >> B >>C;
  
  if (A == B || B == C || C == A){
    if (A == B && B == C){
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
char s[55], t[55];
int dd;

int main() {
	scanf("%s %s", s, t);
	int ls = strlen(s), lt = strlen(t);
	int pos = Inf;
	for(int i = 0; i < ls; i++) {
		int cnt = 0;
		dd = 0;
		for(int j = i; j <= i + lt - 1; j++) {
			if(s[j] == '?' || s[j] == t[dd]) cnt++;
			dd++;
		}
		if(cnt == lt) pos = i;
	}
	if(pos == Inf) puts("UNRESTORABLE");
	else {
		dd = 0;
		for(int i = pos; i <= pos + lt - 1; i++) s[i] = t[dd++];
		for(int i = 0; i < ls; i++) if(s[i] == '?') s[i] = 'a';
		printf("%s\n", s);
	}
}

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

int gcd (int a, int b) {
    if (b>a){
        int tmp = a;
        a = b;
        b = tmp;
    }
    
    if (b==0) return a;
    
    //cout << a << " " << b << endl;
    return gcd (b, a%b);
}

int main(void){
    int x, y; cin >> x >> y;

    cout << gcd (x, y) << endl;

    return 0;
}



Measured memory_bytes: 3080
#include <stdio.h>

int answer(char ch[])
{
	int sum = 0;
	int i;
	
	for(i=0;;i++){
		if(ch[i] == 0){
			break;
		}
		sum += ((int)ch[i]-48);
	}
	
	return sum;
}
int main()
{
	char ch[1001];
	
	while(1){
	
		scanf("%s",ch);
		
		if(answer(ch) == 0){
			break;
		}
	
		printf("%d\n",answer(ch));

	}
	return 0;
}

Measured memory_bytes: 536
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}

macro_rules! trace {
    ($x:expr) => { dbg!($x); };
    ($($xs:expr),*) => { dbg!(($($xs),*)); }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let s: String = sc.cin();
    put!(s.chars().map(|_| 'x').collect::<String>());
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


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

int main()
{
    int n;
    string str1,str2,str;
    cin>>n;

    cin>>str1>>str2;

    str=str1;
    for(int i=0;i<n;i++)
    {
        if(str.substr(i,n-i)==str2.substr(0,n-i))
        {
            str+=str2.substr(n-i,i);
            cout<<str.size();
            return 0;
        }
    }
    str+=str2;
    cout<<str.size();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i = a; i<n; i++)
#define per(i,a,n) for (int i = n-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define all(now) (now).begin(),(now).end()
#define fi first
#define se second
#define SZ(now) ((int)(now).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod = 1000000007;
inline int read(int &n){char c=getchar();int x=0,f=1;while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+(c-'0');c=getchar();}return n = x*f;}
ll powmod(ll a,ll b) {ll res = 1; a%=mod; assert(b>=0); for(;b; b>>=1){if(b&1)res = res*a%mod; a = a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int N = 1e5+7;
int T,n,m;
int f[N];
int main()
{
    //ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int x = 0;
    ll ans = 0,res=1;
    cin >> n;
    rep(i, 1, n + 1) f[i] = (f[i - 1] + powmod(i, mod - 2)) % mod;
    rep(i, 1, n + 1)
    {
        scanf("%d", &x);
        ans = (ans + x*(f[i] + f[n - i + 1] - 1 + mod) % mod) % mod;
        res = res * i % mod;
    }
    printf("%lld\n", ans*res%mod);

    return 0;
}

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

int main()
{
    int n,m;
    cin >> n>>m;
    map<int ,string>st;
    int befi;
    string befs;
    int state[100010][2]={};//quese,(ac,wa)
    int tag;
        for(int i=0;i<m;i++){
        cin >>befi>>befs;
        if(befs=="AC"){
            tag=0;
        }else{
            tag=1;
        }
        if(state[befi][0]==0){
            state[befi][tag]++;
        }
    } 
    int ACs=0;
    int WAs=0;
    for(int i=0;i<=n;i++){
        if(state[i][0]==1){
            ACs+=state[i][0];
            WAs+=state[i][1];
            //cout << state[i][0] << " " << state[i][1];
        }
    }
    cout << ACs<<" "<<WAs;
}


Measured memory_bytes: 1152
import itertools
# import math

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
N, M = map(int, input().split())
# P = list(map(int, input().split()))
# Q = list(map(int, input().split()))
# S = input()

aced = {}
waed = [0] * (N + 1)

cnt_ac = 0
for i in range(M):
    p_i, S_i = input().split()
    if S_i == 'WA':
        if not p_i in aced:
            waed[int(p_i)] += 1
    else:
        if not p_i in aced:
            cnt_ac += 1
            aced[p_i] = 1

cnt_pena = 0
for k in aced:
    cnt_pena += waed[int(k)]

print(cnt_ac, cnt_pena)
# print(aced)

Measured memory_bytes: 22632
def main_function():
    from sys import stdin
    from sys import stdout
    input = stdin.readline
    print = stdout.write

    n = int(input())
    a = list(map(int, input().split()))
    ans = [0] * n
    for who_boss in a:
        ans[who_boss - 1] += 1
    for i in range(len(ans)):
        print(f'{ans[i]}\n')


if __name__ == '__main__':
    main_function()

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

int main(){
  int n,m;
  cin >> n >> m;
  cout << n*(n-1)/2 + m*(m-1)/2 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double x[] = new double[4];
        double y[] = new double[4];
      for(;n>0;n--){
            for(int i=0; i<4; i++){
                x[i] = sc.nextDouble();
                y[i] = sc.nextDouble();
            }
            double ans=Math.abs((x[1]-x[0])*(y[3]-y[2])-(y[1]-y[0])*(x[3]-x[2]));
            System.out.println(ans<=1e-10 ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 23212
#include <bits/stdc++.h>
using namespace std;
int n,t,ans,a[100005];

int main(){
	//freopen("1.txt","r",stdin);
	scanf("%d",&n);
	for (int i=1; i<=n; i++) scanf("%d",&a[i]);
	for (int i=1; i<=n; i++)
		if (a[i]==i){
			for (i++,t=1; a[i]==i; i++) t++;
			ans+=(t+1)/2;
		}
	printf("%d",ans);
}


Measured memory_bytes: 640
import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long a = scan.nextInt();
		long b = scan.nextInt();
		int d = (int) (a/b);
		int r = (int) (a%b);
		double f = (double)a/b;
		DecimalFormat df2 = new DecimalFormat("0.00000000");


		System.out.println(d+" "+r+" "+df2.format(f));

	}

}

Measured memory_bytes: 26504
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19

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

    int n;
    int k;
    cin >> n >> k;
    vector<int> h(n);
    VCIN(h);

    vector<int> ans(n, 0);
    ans[1] = abs(h[1] - h[0]);
    for(int i=2; i<n; i++){
        int mmin = numeric_limits<int>::max();
        for(int j=1; j<=k; j++){
            if(i-j < 0) break;
            int tmp = ans[i-j] + abs(h[i]-h[i-j]);
            if(tmp < mmin) mmin = tmp;
        }
        ans[i] = mmin;
    }

    COUT(ans.back());

    return 0;
}

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

int main()
{
	int X, N;
	cin >> X >> N;
	set<int> st;
	for( int i = 0; i < N; i++ ) {
		int p;
		cin >> p;
		st.insert( p );
	}

	int mi = INT32_MAX / 2;
	int ans;
	for( int x = -100; x < 201; x++ ) {
		if( st.count( x ) ) continue;
		if( abs( X - x ) < mi ) {
			mi = abs( X - x );
			ans = x;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#define N 200005
#define F first
#define S second
#define PI pair<int, int>
using namespace std;

int n, ans, s[N], d[N], L = -2e9, M = 998244353;
stack<PI > st;
PI a[N];
int main()
{
	int i;
	PI t;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf ("%d %d", &a[i].F, &a[i].S);
	}
	sort(a, a + n);
	d[n] = 1;
	st.push(PI(-L, n));
	for (i = n - 1; i >= 0; i--) {
		while (!st.empty()) {
			t = st.top();
			if (a[i].F + a[i].S <= t.F) break;
			st.pop();
		}

//		t = upper_bound(a, a + n, make_pair(a[i].F + a[i].S, L)) - a;
		d[i] = (d[t.S] + d[i + 1]) % M;
		st.push(PI(a[i].F, i));
	}
	cout << d[0];
    return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int H,W,T,n,m,ans;
int qpow(int a,int b){
	int ans=1;
	while(b){
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}
	return ans;
}
int main(){
	H=read(),W=read(),T=read();
	n=H/__gcd(H,T),m=W/__gcd(W,T);
	ans=(qpow(2,n)+qpow(2,m)-1)%mod;
	ans=(ans+qpow(2,__gcd(n,m))-2)%mod;
	ans=qpow((ans+mod)%mod,1LL*(H/n)*(W/m)%(mod-1))%mod;
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 3756
n=int(input())
listA=(input().split())
list1=[0 for i in range(n)]
list2=[]
numOfBox=0
#考えるべきボールの数の合計
for i in range(n,0,-1):#n,n-1,...1って感じです
    #print(i)
    count=1
    s=0
    while i*count<=n:
        s+=list1[i*count-1]
        count+=1
    #print(s)
    if s%2!=int(listA[i-1]):
        list1[i-1]+=1
        numOfBox+=1
        list2.append(i)
#print(list1)
print(numOfBox)
for i in range(len(list2)):
    print(list2[i],end=" ")



Measured memory_bytes: 12144
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, D = il()
    ret = 0
    for _ in range(N):
        X, Y = il()
        if math.sqrt(X ** 2 + Y ** 2) <= D:
            ret += 1
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9892
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
typedef vector<vector<int>> Graph;

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

    int a, b, c;
    cin >> a >> b >> c;
    int ans = 1e18;
    if (a % 2) {
        ans = min(ans, b * c);
    } else {
        ans = 0;
    }
    if (b % 2) {
        ans = min(ans, c * a);
    } else {
        ans = 0;
    }
    if (c % 2) {
        ans = min(ans, a * b);
    } else {
        ans = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
read a b c
A=`echo -e "$a\n$b\n$c" | sort -n | sed -n 1p`
B=`echo -e "$a\n$b\n$c" | sort -n | sed -n 2p`
C=`echo -e "$a\n$b\n$c" | sort -n | sed -n 3p`
if [ $((C % 2)) -eq 0 ]
then
	echo 0
else
	echo $((A * B))
fi


Measured memory_bytes: 840
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
#define int long long int

void solve() {
  // int x;
  // cout << endl;
}

signed main() {
  int n;
  string str;
  cin >> n >> str;
  vector<int> w(n), e(n);

  int total = 0;
  for (int i = 0; i < n; i++) {
    w[i] = total;
    if (str[i] == 'W') {
      total++;
    }
  }

  total = 0;
  for (int i = n - 1; i >= 0; i--) {
    e[i] = total;
    if (str[i] == 'E') {
      total++;
    }
  }

  int ans = INF;
  for (int i = 0; i < n; i++) {
    ans = min(ans, w[i] + e[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5380
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;
 
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}





void test_case() {

    
    

    ld a, b;
    cin>>a>>b;

    for(ld i=1; i<=1e6; i++) {

        ld x = floor(i * 0.08);
        ld y = floor(i * 0.10);

        if( x== a && y == b) {
            // cout<<i * 0.08<<" "<<i * 0.10<<endl;
            int ans = i;
            cout<<ans<<endl;
            return;
        }

    }

    cout<<-1<<endl;
    return;



    




  

    


}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
 
    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

string f1[100][100],f2[100][100],s1,s2;
int l,L,max_l;

bool check(int x)
{
	for(int i=0;i+x<L;++i)
	{
		for(int j=0;j+x<max_l;++j)
		{
			string k1=f1[i][i+x],k2=f2[j][j+x];
			if(k1==k2) return 1;
		}
	}
	return 0;
}

int main()
{
    int a,b; string s[101];
    cin>>a>>b;
    for(int i=0;i<a;++i) cin>>s[i];
    sort(s,s+a);
    for(int i=0;i<a;++i) cout<<s[i];
    cout<<endl;
    return 0;
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vin ll n; cin>>n; vector<ll>x(n); for(ll i=0; i<n; i++) cin>>x[i]
#define vout for(ll i=0; i<n; i++) cout<<x[i]<<" "
#define T ll t; cin>>t; while(t--)
#define ain ll n; cin>>n; ll a[n]; for(ll i=0; i<n; i++) cin>>a[i]
#define aout for(ll i=0; i<n; i++) cout<<a[i]<<" "
#define matin ll m,n; cin>>m>>n; ll a[m][n]; for(ll i=0;i<m;i++) for(ll j=0;j<n;j++) cin>>a[i][j];
#define matout for(ll i=0;i<m;i++){for(ll j=0;j<n;j++) cout<<a[i][j]<<" "; cout<<"\n";}
#define F first
#define S second
#define I insert
#define sin set<ll>s; ll n; cin>>n; ll tmp; for(ll i=0;i<n;i++){cin>>tmp; s.I(tmp);}
#define sout for(auto it=s.begin();it!=s.end();++it) cout<<*it<<" "
#define AISORT sort(a,a+n)
#define ADSORT sort(a,a+n,greater<ll>())
#define VISORT sort(x.begin(),x.end())
#define VDSORT sort(x.begin(),x.end(),greater<ll>())
#define pb push_back
#define ppb pop_back
#define N cout<<"\n"
const ll maxs = 1e6+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9+7;
ll pow(ll x,ll y) 
{   
    ll res = 1; 
    x = x % mod;
    while (y > 0)
    {
        if (y & 1) 
            res = (res * x) % mod;
        y = y >> 1 ; x = (x * x) % mod;
    } 
    return res;
}
ll inv(ll x)
{ 
      return pow(x , mod - 2);  
}

ll fact[maxs];
ll fib[maxs];
ll ncr[maxs1][maxs1];
void FACT()
{
    fact[0]=1;
    for(ll i=1; i<maxs; i++) 
        fact[i] = (i % mod * fact[i-1] % mod) % mod;
}
void FIB()
{
   fib[0]=0; 
   fib[1]=1; 
   for(ll i=2; i<maxs; i++) 
       fib[i] = (fib[i-1] % mod + fib[i-2] % mod)% mod;
}
void NCR()
{
    ll i,j;
    ncr[1][0] = 1;
    ncr[1][1] = 1;
    for(i=2; i<maxs1; i++)
    {
        for(j=0; j<=i; j++)
        {
            if(j==0)
                ncr[i][j]=1;
            else
                ncr[i][j] = (ncr[i-1][j] + ncr[i-1][j-1] ) % mod;
        }
    }
}
bool soe(ll n) 
{ 
    bool prime[maxs+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=maxs; p++) 
    { 
        if (prime[p] == true) 
        {   
            for (ll i=p*p; i<=maxs; i += p) 
                prime[i] = false; 
        } 
    } 
    if(prime[n])
    return true;
    else
    return false;
}
int main()
{
    
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
    ain;
     ll dp[n];
     dp[n-1]=0;
     dp[n-2]=llabs(a[n-1]-a[n-2]);
     for(int i=n-3;i>=0;i--)
     {
       	dp[i]=min(llabs(a[i+1]-a[i])+dp[i+1],llabs(a[i+2]-a[i])+dp[i+2]);
     }
	cout<<dp[0];
                      
   
}


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

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        int xa = Math.abs(x-a);
        int xb = Math.abs(x-b);
        if (xa<xb)
            System.out.println("A");
        else
            System.out.println("B");
    }
}


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

vector<bool> prime_table(int n) {
	vector<bool> prime(n + 1, true);
	if(n >= 0) prime[0] = false;
	if(n >= 1) prime[1] = false;
	for(int i = 2; i * i <= n; i++) {
		if(!prime[i]) continue;
		for(int j = i + i; j <= n; j += i) {	// j = i * iで良い？
			prime[j] = false;
		}
	}
	return prime;
}

int main() {
	int x;
	cin >> x;
	auto p = prime_table(110000);
	while(!p[x]) {
		x++;
	}
	cout << x << endl;
	return 0;
}

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

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(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 ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

struct edge{
    int to, dist, attack;
};

struct P {
    int from, money, enemy;

    bool operator >(const P& p) const {
        return enemy > p.enemy;
    }
};

const int dx[] = {-1,0,1,0}; const int dy[] = {0,1,0,-1};

int N, M, L;

int main() {
    while (cin >> N >> M >> L, N|M|L) {
        vector<vector<edge>> E(N+1);
        REP(i, M) {
            int from, to, dist, enemy;
            cin >> from >> to >> dist >> enemy;
            E[from].push_back((edge){to, dist, enemy});
            E[to].push_back((edge){from, dist, enemy});
        }

        bool G[N+1][L+1];
        fill_n((bool *)G, (N+1)*(L+1), false);

        priority_queue<P, vector<P>, greater<P>> q;
        // start
        q.push((P){1, L, 0});
        int enemy = 0;
        while (!q.empty()) {
            P p = q.top(); q.pop();

            // goal
            if (p.from == N) {
                enemy = p.enemy;
                break;
            }

            if (G[p.from][p.money]) continue;
            G[p.from][p.money] = true;

            for (edge e : E[p.from]) {
                if (p.money >= e.dist) {
                    q.push((P){e.to, p.money - e.dist, p.enemy});
                }
                q.push((P){e.to, p.money, p.enemy + e.attack});
            }
        }

        cout << enemy << endl;
    }
}

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

/*
void solve(long long N, long long K){
    ll cnt = 0;
    for(ll bit = 0; bit < (1<<N); ++bit){
        vector<ll> S;
        for(ll i = 0; i < N; ++i){
            if(bit & (1<<i)) S.push_back(i);
        }
        if(S.size() == 3){
            ll ab = S[0] + S[1];
            ll bc = S[1] + S[2];
            ll ca = S[2] + S[0];
            if(ab % K == 0 && bc % K == 0 && ca % K == 0) cnt++;
        }
    }
    cout << cnt << endl;
}
*/

void solve(long long N, long long K){
    vector<ll> num(K, 0);
    for(ll i = 1; i <= N; ++i) num[i%K]++;
    ll res = 0;
    for(ll a = 0; a < K; ++a){
        ll b = (K - a) % K;
        ll c = (K - a) % K;
        if((b+c) % K != 0) continue;
        res += num[a] * num[b] * num[c];
    }
    cout << res << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 1792
from sys import stdin

def main():

    input = stdin.readline

    N = int(input())

    count = 0
    flag = False
    for _ in range(N):
        d1,d2 = map(int,input().split())

        if d1 == d2:
            count += 1
        else:
            count = 0
        
        if count >= 3:
            flag = True



    if flag is True:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

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

int main() {
  int k,n; cin >> k >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  a.push_back(a[0]+k);
  int l=0;
  rep(i,n) {
    l = max(l, a[i+1] - a[i]);
  }
  int ans = k- l;
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 1792
N, M = map(int, input().split())
AB = []
for _ in range(M):
    a, b = map(int, input().split())
    AB.append((a, b))
AB.sort(key=lambda x: x[1])
cnt = 1
x = AB[0][1]
for a, b in AB:
    if a <= x - 1 <= b and a <= x <= b:
        continue
    else:
        cnt += 1
        x = b
print(cnt)

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

namespace AtCoderPre
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NM[0];
            var M = NM[1];
            var MOD = 1000000007;

            var broken = new bool[N + 1];

            for (int i = 0; i < M; i++)
            {
                var A = int.Parse(Console.ReadLine());
                broken[A] = true;
            }

            var steps = new long[N + 1];
            steps[0] = 1;
            steps[1] = broken[1] ? 0 : 1;

            for (int i = 2; i < N + 1; i++)
            {
                if (broken[i])
                {
                    steps[i] = 0;
                }
                else
                {
                    steps[i] = (steps[i - 1] + steps[i - 2]) % MOD;
                }
            }

            Console.WriteLine(steps[N]);


        }

    }
}

Measured memory_bytes: 13792
N, X = map(int, input().split())
a = [1]
for i in range(N):
    a.append(2*a[i] + 3)
p = [1]
for i in range(N):
    p.append(2*p[i] + 1)
def f(N, X):
    if N == 0:
        if X == 0:
            return 0
        else:
            return 1
    elif N >= 1:
        if 0 <= X <= 1:
            return 0
        elif 1 < X <= 1 + a[N-1]:
            return f(N-1, X-1)
        elif X == 2 + a[N-1]:
            return p[N-1] + 1
        elif 2 +a[N-1] < X <= 2 + 2*a[N-1]:
            return p[N-1] + 1 + f(N-1, X-2-a[N-1])
        else:
            return 2*p[N-1] + 1
print(f(N,X))

Measured memory_bytes: 3064
N = gets.to_i
S = N.times.map{gets.chomp}
T = gets.chomp

before, after = 0, 0
S.each do |s|
    before += 1 if s.gsub('?', 'a') <= T
    after  += 1 if s.gsub('?', 'z') >= T
end

puts ((N+1-after)..(1+before)).to_a.join(' ')

Measured memory_bytes: 3196