akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;
constexpr ll M = 1e9 + 7;
inline ll sum_1(const ll n) { return ((n * (n + 1)) / 2) % M; }
inline ll sum_2(const ll n) { return ((n * (n + 1) * (2 * n + 1)) / 6) % M; }
inline ll sum_3(const ll n) { return (((n * (n + 1)) / 2) % M * ((n * (n + 1)) / 2) % M) % M; }
inline ll sum_1(const ll i, const ll j) { return (sum_1(j) - sum_1(i - 1) + M) % M; }
inline ll sum_2(const ll i, const ll j) { return (sum_2(j) - sum_2(i - 1) + M) % M; }
inline ll sum_3(const ll i, const ll j) { return (sum_3(j) - sum_3(i - 1) + M) % M; }

ll pow_f(ll base, ll exp) {
    ll ans = 1;
    base = base % M;
    while (exp) {
        if (exp&1) {
            ans = (ans * base) % M;
        }
        base = (base * base) % M;
        exp >>= 1;
    }
    return ans;
}


void solve() {
    ll n, k;
    cin >> n >> k;
    /**
     * GCD can lie between 1....K
     * Count no. of sequence having gcd X \in 1...K
     * 
     * gcd X i.e all are divisible by X atleast K/X**N
     * 
     */
    ll ans = 0;
    vector<ll> cntSeq(k+1, 0);
    for (int i = k; i >= 1; --i) {
        ll temp = pow_f((k/i), n);
        ll multiplier = 2;
        while (multiplier*i <= k) {
            temp = (temp - cntSeq[multiplier*i] + M)%M;
            ++multiplier;
        }
        cntSeq[i] = temp;
        ans = (ans + (i*temp)%M)%M;
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve();

    return 0;
}

Measured memory_bytes: 3960
#include "bits/stdc++.h"

using namespace std;

void Main() {
    long long N;
    cin >> N;
    vector<long long> A(N, 0), B(N, 0), C(N, 0);
    for (long long i = 0; i < N; ++i) {
        cin >> A[i];
    }
    for (long long i = 0; i < N; ++i) {
        cin >> B[i];
    }
    for (long long i = 0; i < N; ++i) {
        cin >> C[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    vector<long long> fromAtoB(N, -1);
    vector<long long> fromBtoC(N, -1);
    for (long long i = 0; i < N; ++i) {
        fromAtoB[i] = distance(B.begin(), upper_bound(B.begin(), B.end(), A[i]));
    }
    for (long long i = 0; i < N; ++i) {
        fromBtoC[i] = distance(C.begin(), upper_bound(C.begin(), C.end(), B[i]));
    }

    vector<long long> BC(N, -1);
    for (long long i = 0; i < N; ++i) {
        BC[i] = N - fromBtoC[i];
    }
    vector<long long> accumBC(N, -1);
    for (long long i = N - 1; i >= 0; --i) {
        if (i == N - 1) {
            accumBC[i] = BC[i];
        }
        else {
            accumBC[i] = accumBC[i + 1] + BC[i];
        }
    }

    long long ans = 0;
    for (long long i = 0; i < N; ++i) {
        long long k = fromAtoB[i];
        if (k == N) {
            break;
        }
        ans += accumBC[k];
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 8780
import Data.List

dirToInt :: Char -> Char -> Int
dirToInt ch d
  | ch == d = 1
  | otherwise = 0

minimize :: String -> Int
minimize xs = pred $ minimum $ zipWith (+) ls rs
  where ls = scanl1 (+) $ map (dirToInt 'W') xs
        rs = scanr1 (+) $ map (dirToInt 'E') xs

main :: IO ()
main = getLine >> getLine >>= print . minimize

Measured memory_bytes: 70012
#include <iostream>

using namespace std;

int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    int ans = r*100 + g*10 + b;
    if (ans % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void) {
  int n;
  string s;
  string x, y;
  cin >> n;
  cin >> s;
  for (int i = 0; i < n / 2; i++)
    x += s[i];
  for (int i = n / 2; i < n; i++)
    y += s[i];
  cout << (x == y ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

const int MOD = 1e9 + 7;
i64 mod_pow(i64 x, i64 n = MOD - 2) {
	i64 ret = 1;
	while(n) {
		if(n & 1) (ret *= x) %= MOD;
		(x *= x) %= MOD;
		n >>= 1;
	}
	return ret;
}

std::vector<i64> fact, inv;
i64 comb(int n, int r) {
//	if(n == 0) return 1;
	return fact[n] * inv[r] % MOD * inv[n - r] % MOD;
}

int main() {
	i64 n, K; scanf("%lld%lld", &n, &K);
	fact.resize(1e5, 1); inv.resize(1e5, 1);
	for(i64 i = 0; i < (int)fact.size() - 1; i++) fact[i + 1] = fact[i] * (i + 1) % MOD;
	for(int i = 0; i < fact.size(); i++) inv[i] = mod_pow(fact[i]);
	
	i64 B = K, R = n - K;
	printf("%lld\n", (R + 1) % MOD);
	for(int k = 2; k <= K; k++) {
		i64 ans = 0;
		i64 tmp = comb(B - 1, k - 1);
		for(i64 j = 0; j < R; j++) {
			i64 X = R - j;
			if(k - 1 > X) continue;
			
			ans += tmp * (j + 1) % MOD * comb(X - 1, k - 2) % MOD;
			ans %= MOD;
		}
		printf("%lld\n", ans);
	}
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int n;
  cin >> n;
  vector<pair<string, pair<int, int>>> vec;
  string s; int p;
  re(i, n) {
    cin >> s >> p;
    vec.pb(mp(s, mp(-p, i+1)));
  }
  sort(all(vec));
  re(i, n) cout << vec[i].second.second << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readlines

def main():

    lines = input()
    n = int(lines[0].strip())

    E = [list(map(int, lines[i].split())) for i in range(1, n+1)]
    E = sorted(E, key=lambda x: x[1])

    cur_t = 0

    for i in range(n):
        cur_t += E[i][0]
        if cur_t > E[i][1]:
            print('No')
            return

    print('Yes')

main()

Measured memory_bytes: 63052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    ll n;cin>>n;
    ll a[n+1];rep(i,1,n)cin>>a[i];
    ll sum[21][n+3];    //2^iの桁で[0,j)の範囲に1が何個あるか
    rep(i,0,20){
        sum[i][0]=-1;
        sum[i][1]=0;
        sum[i][n+2]=inf;
    }
    rep(i,0,20){
        rep(j,2,n+1){
            if((a[j-1]>>i)&1){
                sum[i][j]=sum[i][j-1]+1;
            }else{
                sum[i][j]=sum[i][j-1];
            }
        }
    }
    ll ans=0;
    rep(i,1,n){
        ll mini=n+1;
        rep(j,0,20){
            ll l=i;
            ll r=n+2;
            while(r-l>1){
                ll mid=(l+r)/2;
                if(sum[j][mid]>=sum[j][i]+2){
                    r=mid;
                }else{
                    l=mid;
                }
            }
            mini=min(mini,r-i-1);
        }
        ans+=mini;
    }
    cout<<ans<<endl;
    
    
        
    return 0;
}





Measured memory_bytes: 37968
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n;
    cin >> n;

    if (n == 3)
    {
        cout << 2 << " " << 5 << " " << 63 << endl;
        return 0;
    }

    V res{2, 4, 3, 9};

    n -= 4;
    int n_ = n - (n % 2);

    for (int i = 8; i + 2 <= 30000; i += 6)
    {
        if (!n_)
            break;
        n_ -= 2;
        res.push_back(i);
        res.push_back(i + 2);
    }

    for (int i = 15; i + 6 <= 30000; i += 12)
    {
        if (!n_)
            break;
        n_ -= 2;
        res.push_back(i);
        res.push_back(i + 6);
    }

    for (int i = 6; i <= 30000; i += 6)
    {
        if (!n_)
            break;
        n_--;
        res.push_back(i);
    }

    if (n % 2)
        res.push_back(30000);

    for (int i = 0; i < res.size(); i++)
        cout << res[i] << (i == res.size() - 1 ? "\n" : " ");

    return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<string> S(N);
    REP(i, N) cin >> S[i];

    map<string, ll> countString;
    ll countMax = 0;
    REP(i, N)
    {
        if (countString.find(S[i]) == countString.end())
        {
            countString[S[i]] = 1;
        }
        else
        {
            countString[S[i]]++;
        }
        countMax = max(countMax, countString[S[i]]);
    }

    vector<string> ansString;
    REPV(iter, countString)
    {
        if (iter->second == countMax)
        {
            ansString.push_back(iter->first);
        }
    }
    sort(ALL(ansString));
    REPV(iter, ansString) cout << *iter << endl;
}


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

#define REP(i, n) for (int i = 0; i < (int)n; i++)
using lli = long long int;

lli N;

int main() {
  cin >> N;

  lli r = 0;
  lli m = 0;
  lli a;
  REP(i, N) {
    cin >> a;
    if (m > a) r += m - a;
    m = max(m, a);
  }
  cout << r << endl;

  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N;
  cin >> N;
  cout << N * N * N << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;


int main(){
  ll n,s;
  cin >> n >> s;
  vector<ll> A(n);
  vector<vector<ll>> dp(n+1,vector<ll>(s+1,0));
  vector<vector<ll>> sum(n+1,vector<ll>(s+1,0));
  dp[0][0] = 1;
  rep(i,n){
    cin >> A[i];
  }
  rep(i,n){
    rep(j,s+1){
      dp[i+1][j] = 2 * dp[i][j];
      dp[i+1][j] %= mod;
      if(j - A[i] >= 0){
        dp[i+1][j] += dp[i][j-A[i]];
        dp[i+1][j] %= mod;
      }
    }
  }
  cout << dp[n][s] << endl;
}

Measured memory_bytes: 144208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	sort(a.begin(),a.end());
	int cnt=1,ans=0;
	rep(i,n-1){
		if(a[i]!=a[i+1] && cnt%2==1){
			ans++;
			cnt=1;
		}
		else if(cnt%2==0 && a[i]!=a[i+1]){
			cnt=1;
		}
		else{
			cnt++;
		}
	}
	if(cnt%2==1) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#define INF 0x3f3f3f3f;

using namespace std;

string s[200005];

bool cmp(string a,string b) {
        return a.compare(b)<0;
}

int main() {
    int n,i;
    scanf("%d",&n);
    for(i=0; i<n; i++)
        cin>>s[i];
    sort(s,s+n,cmp);
    int m=1,cnt=1;
    for(i=1; i<n; i++) {
        if(s[i].compare(s[i-1])==0)
            cnt++;
        else
            cnt=1;
        m=max(cnt,m);
    }
    cnt=1;
    if(m==1)
        cout<<s[0]<<endl;
    for(i=1; i<n; i++) {
        if(s[i].compare(s[i-1])==0)
            cnt++;
        else
            cnt=1;
        if(cnt==m)
            cout<<s[i]<<endl;
    }
}

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

money=1000
kabu=0

for i in range(n-1):
    if(a[i]<a[i+1]):
        nokori=money%a[i]
        #print(nokori)
        money=nokori+(money-nokori)//a[i]*a[i+1]
    #print(i,money)

print(money)

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

int main()
{
	int n = 0 , m = 0;
	for(n = m = 1;n<=9;n++)
	{
		for(m=1;m <= 9;m++)
		{

		cout << n << "x" << m << "=" << n*m << endl;

		}
	}
	return 0;
}

Measured memory_bytes: 0
x,y,z = map(int,input().split())
aa = x
b1 = 0
b2 = 0
for a in range(aa):
  x -= z
  if x < y:
    break
  x -= y
  if x < z:
    break
  b2 += 1
if b1 <= b2:
  print(b2)
else:
  print(b1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;

ll a;
string s;

void input(void){
   cin>>a>>s;
}
string solve(void){
    if(a<3200)return "red";
    return s;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    cout<<solve()<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int W = scanner.nextInt();
        int H = scanner.nextInt();
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int r = scanner.nextInt();
        if (x + r <= W && x >= r && y + r <= H && y >= r) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}

Measured memory_bytes: 26076
def solve():
  l,r = (int(i) for i in input().split())
  mod = 2019
  if r-l >= 2019:
   print(0)
   exit()
  l %= mod
  r %= mod
  ans = 10**15
  if l >= r :
    print(0)
    exit()
  elif l == 0 or r == 0:
    print(0)
    exit()
  else:
    for i in range(l,r):
      for j in range(i+1,r+1):
         ans = min(ans,(i*j)%mod)
  print(ans%mod)

solve()

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

const ll INF = 1LL<<60;

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n;
  cin >> n;
  vector<ll> a(n), s(n+1,0);
  rep(i,n) {
    cin >> a[i];
    s[i+1] = s[i] + a[i]; //累積和
  }
  vector<vector<ll> > dp(n+5, vector<ll>(n+5,INF));
  rep(i,n+2) dp[i][i] = 0;
  rep(i,n) dp[i][i+1] = 0;
  for (int w = 2; w <= n; ++w) {
    for (int l = 0; l <= n-w; ++l) {
      int r = l + w;
      if (w == 2) dp[l][r] = a[l] + a[l+1];
      else {
        for (int k = l+1; k < r; ++k) {
          dp[l][r] = min(dp[l][r], dp[l][k] + dp[k][r] + (s[r] - s[l]));
        }
      }
    }
  }
  cout << dp[0][n] << endl;
  return 0;
}

Measured memory_bytes: 1536
import java.io.*;
import java.util.*;

class Main{
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

    int N = Integer.parseInt(in.readLine());

    Long[] a = Arrays.stream(in.readLine().split(" ")).map(Long::parseLong).toArray(Long[]::new);

    long sum = 0;
    for(int i=0;i<N;i++){
      sum += a[i];
    }
    long min=Long.MAX_VALUE;
    long sunuke = sum, arai = 0;
    for(int i=0;i<N-1;i++){
      sunuke -= a[i];
      arai += a[i];
      if(Math.abs(sunuke-arai)<min){
        min = Math.abs(sunuke-arai);
      }
    }
    System.out.println(min);
  }
}


Measured memory_bytes: 63760
#include<bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> point;
namespace std{
    bool operator < (const point& a, const point& b) {
        return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
    }
}
double cross(const point& a, const point& b) {
    return imag(conj(a)*b);
}
double dot(const point& a, const point& b) {
    return real(conj(a)*b);
}

// 直線はvector<point>の型を継承
struct line : public vector<point> {
    line(const point &a, const point &b){
        push_back(a); push_back(b);
    }
};

double line_cross(const line &a, const line &b) {
    return cross(a[1] - a[0], b[1] - b[0]);
}

double line_dot(const line &a, const line &b) {
    return dot(a[1] - a[0], b[1] - b[0]);
}

int main()
{
    double x0, y0, x1, y1;
    cin >> x0 >> y0 >> x1 >> y1;
    line P1(point(x0,y0), point(x1,y1));
    int q;
    cin >> q;
    for(int i = 0; i < q; ++i) {
        double x2, y2;
        cin >> x2 >> y2;
        line P2(P1[0], point(x2,y2));
        double tmp = line_cross(P1,P2);
        if(tmp>0.0) {
            cout << "COUNTER_CLOCKWISE" << endl;
        }
        else if(tmp < 0.0) {
            cout << "CLOCKWISE" << endl;
        }
        else {
            tmp = line_dot(P1,P2);
            double p1 = line_dot(P1,P1);
            double p2 = line_dot(P2,P2);
            if(tmp < 0.0) { cout << "ONLINE_BACK" << endl; continue; }
            if(p1 < p2) { cout << "ONLINE_FRONT" << endl; continue; }
            cout << "ON_SEGMENT" << endl;
        }
    }
    return 0;
}


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

using namespace std;

int main(){
    long long n, sum = 0;
    cin >> n;
    vector<long long> a(n), cnt(100001);;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cnt[a[i]]++;
        sum += a[i];
    }
    long long q;
    cin >> q;
    vector<long long> b(q), c(q);
    for(int i = 0; i < q; i++) cin >> b[i] >> c[i];
    for(int i = 0; i < q; i++){
        sum += cnt[b[i]] * (c[i] - b[i]);
        cnt[c[i]] += cnt[b[i]];
        cnt[b[i]] = 0;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 6372
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e5 * 2 + 10, INF = 1e9 + 10, MOD = 1e9 + 7;

vector<vector<ll>> graph;

bool used[SIZE];

void dfs(int v) {
    used[v] = 1;
    for (auto to : graph[v]) {
        if (!used[to]) dfs(to);
    }
}

int main()
{
    fastInp;

    ll n, m;
    cin >> n >> m;

    graph.resize(n);
    for (int i= 0; i < m; i++) {
        ll u, v;
        cin >> u >> v;
        u--; v--;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    for (int i = 0; i < n; i++) {
        if (graph[i].size() % 2 != 0) {
            cout << "No";
            return 0;
        }
    }

    ll cnt = 0;
    for (int i = 0; i < n; i++) {
        if (graph[i].size() >= 4) cnt++;
        if (graph[i].size() >= 6) {
            cout << "Yes";
            return 0;
        }
    }

    if (cnt >= 3) {
        cout << "Yes";
        return 0;
    }

    for (int i = 0; i < n; i++) {
        if (graph[i].size() >= 4) {
            dfs(i);
            for (int t = 0; t < n; t++) {
                if (graph[t].size() == 4 && t != i) {
            
            for (int j = 0; j < graph[i].size(); j++) {
                ll v = graph[i][j];
                ll par = i;
                while (graph[v].size() != 4) {
                    if (graph[v][0] == par) {
                        par = v;
                        v = graph[v][1];
                    } else {
                        par = v;
                        v = graph[v][0];
                    }
                    
                }
                if (v == i) {
                    cout << "Yes";
                    return 0;
                }
            }
            }
            }
            break;
            
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 10152
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int ASC(const int *a,const int *b){
	return (*a - *b);
}

int main(int argc, char const *argv[])
{
	int n;
	int p[100003];
	scanf("%d",&n);
	for (int i = 0; i < n; ++i)	scanf("%d",&p[i]);
	qsort(p,n,sizeof(int),ASC);
	if(p[n / 2 - 1] == p[n / 2])	puts("0");
	else printf("%d\n", (p[n / 2] - p[n / 2 - 1]));
	return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define fast                                                                   \
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define ll long long
#define f(i, n) for (int i = 0; i < n; i++)
#define ff(i, n) for (int i = 1; i <= n; i++)
#define F first
#define S second
#define vpii vector<pair<int,int> >
#define sz size()
#define all(v) v.begin(),v.end()
#define pb push_back   
#define PB pop_back
#define vl vector<int>
#define mp make_pair
#define mod 1000000007
typedef unsigned long long ull;
const int N = 200005;
const int MOD = 998244353 ;




void solve(){
    int a, b, c, k, cnt = 0;
    cin>>a>>b>>c>>k;
    while(b <= a)b *= 2,cnt++;
    while(c <= b)c *= 2,cnt++;
    if(cnt <= k){cout<<"Yes";return ;}
    cout<<"No";
}

int32_t main() {
    fast
    int t;
    t = 1;
    //cin >> t;
    while(t--)solve();
    return 0;
}


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

int main(){
    int n;
    
    cin >> n;
    
    bool x = false;
    
    for(int i = 1; i < 10; i++){
        if (n%i == 0 && n/i < 10){
            x = true;
        }
    }
    
    if(x){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
}

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

int main(){
    set<int> x;
    int n, a;
    scanf("%d", &n);
    for(int i=1;i<=n;i++) scanf("%d", &a), x.insert(a);   
    if(x.size() == n) printf("YES\n");
    else printf("NO\n");
}

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

#define chmax(a, b) (a) = ((a) < (b)) ? (b) : (a)
#define YMAX 1000000007
#define mend '\n'

typedef long long ll;

using namespace std;

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

  bool ans = false;
  int count = 0;

  for(int i = 0;i < N;i++) {
    int a, b;
    cin >> a >> b;

    if(a == b) {
      count++;
    } else {
      count = 0;
    }

    if(count == 3) {
      ans = true;
    }
  }

  if(ans) {
    cout << "Yes" << mend;
  } else {
    cout << "No" << mend;
  }
}


Measured memory_bytes: 3628
N, M = map(int, input().split())
edges = [[] for i in range(N)]

for i in range(M):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  edges[a].append(b)

for i in edges[0]:
  if N-1 in edges[i]:
    print("POSSIBLE")
    exit()
print("IMPOSSIBLE")    

Measured memory_bytes: 29036
i = int(input())
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[i-1])


Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
#include <algorithm>
#include <vector>
#define ll long long
using namespace std;
const int N=1100005, INF=1<<27;
int in[N], n, cc[1209];
bool used[N];
char str[N];
vector<int>g[1209];

int lowbit(int t)
{
	return t&(t^(t-1));
}

int sum(int end)
{
	int ans=0;
	while(end>0)
	{
		ans+=in[end];
		end-=lowbit(end);
	}
	return ans;
}

void add(int pos ,int num)
{
	while(pos<=n)
	{
		in[pos]+=num;
		pos+=lowbit(pos);
	}
}

void solve()
{
	for(int i=1; i<=n+1; i++)
	{
		add(i,1);
	}
	ll ans = 0;
	int v, u, size;
	char s;
	for(int i=1; i<=n; i++)
	{
		if(!used[i])
		{
			s = str[i];
			size = g[s].size();
			u = g[s][size-1];
			if(i == u)
			{
				ans+=(sum(n)-sum(i))>>1;
			}
			else
			{
				ans += sum(n) - sum(u);
			}
			add(u,-1);
			add(i,-1);
			used[i]=used[u]=1;
			g[s].erase(g[s].end()-1);
		}
	}
	cout<<ans;
}

int main()
{
		scanf("%s", str+1);
		n = strlen(str+1);
		for(int i=1; i<=n; i++)
		{
			cc[str[i]]++;
			g[str[i]].push_back(i);
		}
		int ac = 0;
		for(int i=0; i<26; i++)
		{
			if(cc['a'+i]&1) ac++;
			if(cc['A'+i]&1) ac++;
		}
		if(ac>1)
		{
			printf("-1");
		}
		else
		{
			solve();
		}
	return 0;
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a==b){
    cout << "a == b" << endl;
  }else if(a>b){
    cout << "a > b" << endl;
  }else{
    cout << "a < b" << endl;
  }
}


Measured memory_bytes: 3076
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
using namespace std;

signed main()
{
	int A, B, C;
	cin >> A >> B >> C;
	cout << ((A <= C && C <= B) ? "Yes" : "No") << endl;
}

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

int bubblesort(int A[], int n){
	int s=0;
	bool flag=1;
	for(int i=0;flag;i++){
		flag=0;
		for(int j=n-1;j>=i+1;j--){
			if(A[j]<A[j-1]){
				swap(A[j],A[j-1]);
					flag=1;
					s++;
			}
		}
	}
	return s;
}

int main()
{
	int A[100],n,s;
	
	cin>>n;
	for(int i=0;i<n;i++) cin>>A[i];
	
	s=bubblesort(A,n);
	
	for(int i=0;i<n;i++) {
		if(i) cout<<" ";
		cout<<A[i];
	}
	cout<<endl;
	cout<<s<<endl;
	
	return 0;
}

Measured memory_bytes: 3108
class Node:
    def __init__(self, key):
        self.key = key
        self.parent = self.left = self.right = None
    
class Tree():
    def __init__(self, root=None):
        self.root = root
    
    def insert(self, node):
        y = None
        x = self.root
        while x is not None:
            y = x
            if node.key < x.key:
                x = x.left
            else:
                x = x.right
        
        node.parent = y
        if y is None:   # Tree が空だった場合
            self.root = node
        elif node.key < y.key:
            y.left = node
        else:
            y.right = node
    
    def print_inorder_tree_walk(self):
        def work(node):
            if node is None:
                return
            work(node.left)
            print('', node.key, end='')
            work(node.right)

        work(self.root)
        print()
    
    def print_preorder_tree_walk(self):
        def work(node):
            if node is None:
                return
            print('', node.key, end='')
            work(node.left)
            work(node.right)

        work(self.root)
        print()

    def find(self, key):
        x = self.root
        while x is not None:
            if key == x.key:
                return True
            elif key < x.key:
                x = x.left
            else:
                x = x.right
        return False

import sys

n = int(input())
T = Tree()
for _ in range(n):
    command, *args = sys.stdin.readline().split()
    if command[0] == 'i':   # insert key
        T.insert(Node(int(args[0])))
    elif command[0] == 'f': # find
        if T.find(int(args[0])):
            print('yes')
        else:
            print('no')
    else:   # print
        T.print_inorder_tree_walk()
        T.print_preorder_tree_walk()


Measured memory_bytes: 85580
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void) {
	int n,d,x;
	cin >> n >> d >> x;
	for(int i=0; i<n; i++){
		int temp;cin >> temp;
		for(int j=0; 1+j*temp<=d; j++)x++;
	}
	cout << x << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int flg,i,j,k,a[100][100],w,h,cnt;
	char s[101];
	scanf("%d %d",&h,&w);
	for(i=0;i<h;i++){
		scanf("%s",s);
		for(j=0;j<w;j++){
			flg=0;
			cnt=0;
			for(k=j;k>=0;k--){
				if(s[k]=='c'){
					flg=1;
					a[i][j]=cnt;
					break;
				}
				cnt++;
			}
			if(flg==0){
				a[i][j]=-1;
			}
//			printf("%d\n",flg);
		}
	}
	for(i=0;i<h;i++){
		for(j=0;j<w-1;j++){
			printf("%d ",a[i][j]);
		}
		printf("%d\n",a[i][w-1]);
	}
	return 0;
}	

Measured memory_bytes: 636
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    I = [0] * N
    T, F = {}, {}
    for i, a in enumerate(A):
        if a not in F:
            F[a] = i
        I[i] = F[a]
        if a in T:
            I[T[a]] = i
        T[a] = i
    t, i = 0, 0
    while i < K - 1:
        if I[t] <= t:
            i += 1
        t = (I[t] + 1) % N
        if t == 0:
            i = K - (K % (i + 1))
    R = []
    while t < N:
        if I[t] <= t:
            R.append(A[t])
            t += 1
        else:
            t = I[t] + 1
    print(' '.join(map(str, R)))

main()


Measured memory_bytes: 58920
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}
//}}}

void main() {
  Scanner sc = new Scanner;

  int N;
  sc.scan(N);

  int[] p = new int[N];
  int[] pNum = new int[N];
  foreach (i; 0 .. N) {
    sc.scan(p[i]);
  }

  int res = 0;
  int[] getWere;
  int cnt;
  foreach (i; 0 .. N) {
    if (p[i] == i + 1) {
      cnt++;
      getWere ~= i + 1;
    }
  }

  sort(getWere);
  int getWereOneNum = 0;
  foreach (i; 1 .. getWere.length) {
    if (getWere[i] - getWere[i - 1] == 1) {
      swap(getWere[i], getWere[i - 1]);
      getWereOneNum++;
      i++;
    }
  }

  writeln(cnt - getWereOneNum);
}


Measured memory_bytes: 4412
#include<iostream>
using namespace std;
int main()
{
       int n;
	cin>>n;
	int n1,n2,n3;
	n1=n%10;
	n2=n/10%10;
	n3=n/100%10;
	if(n1==7||n2==7||n3==7)
	cout<<"Yes";
	else
	cout<<"No";
}

Measured memory_bytes: 3560
/*
 *Author - Abhas Jain
 */
 
#include <bits/stdc++.h>
 
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define endl '\n'
#define pb push_back
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
 
typedef long long ll;
typedef long double ld;
 
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
 
const ld PI = 3.141592653589793;
const ll INF = 9223372036854775807ll;
const ll mod = 1e9 + 7;
 
void solve() 
{
    int n;
    cin >> n;
    int tot = 0;
    for (int i = 1; i <= n; ++i) {
    	if (i < 10) tot++;
    	else if (i >= 100 && i < 1000) tot++;
    	else if (i >= 10000 && i < 100000) tot++;
    }
    cout << tot << endl;
}
 
int main( )
{   
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    solve();
    return 0;
}

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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    int N;
    cin >> N;
    vector<int> d;

    for (int i = 0; i < N; ++i)
    {
        int temp;
        cin >> temp;
        d.push_back(temp);
    }

    sort(d.begin(), d.end());
    d.erase(unique(d.begin(), d.end()), d.end());

    cout << d.size() << endl;
}


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

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

   int a, b;
   cin >> a >> b;
   cout << a * b << endl;
   return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#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 = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    rep(i, 0, s.size()){
        if(i % 2 == 0) cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 592
n,m,q = map(int,input().split())
A = []
B = []
C = []
D = []
for i in range(q):
  a,b,c,d = map(int,input().split())
  A.append(a-1)
  B.append(b-1)
  C.append(c)
  D.append(d)
  
from collections import deque
que = deque([[1]])
M = 0

while que:
  
  lst = que.popleft()
  if len(lst) == n:
    s = 0
    for i in range(q):
      if lst[B[i]] - lst[A[i]] == C[i]:
        s += D[i]
    if M < s:
      M = s
      
  else:    
    for j in range(lst[-1],m+1):
      lst2 = lst +[j]
      que.append(lst2)
    
print(M)  

Measured memory_bytes: 16328
A, B, C, D, E, F = map(int, input().split(' '))
maxconc = 0.0
maxwater = 100*A
maxsugar = 0

for i in range(F//(100*A)+1):
  for j in range((F-100*A*i)//(100*B)+1):
    if i == 0 and j == 0:
      continue
    S =min(E*(A*i+B*j),F-100*(A*i+B*j))
    
    sugar=0
    for c in range(S//C+1):
      d = (S-c*C)//D
      sugar = max(sugar,c*C+d*D)
    conc = sugar / (sugar +100*(A*i+B*j))
    if conc > maxconc:
      maxconc = conc 
      maxwater = 100*(A*i+B*j)
      maxsugar = sugar
print('{0} {1}'.format(maxwater+maxsugar,maxsugar))    

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

int main() {
    string s;
    cin >> s;
    if (s == "AAA" || s == "BBB") cout << "No";
    else cout << "Yes";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A[5];
  for (int i = 0; i < 3; i++) cin >> A[i];
  sort(A, A + 3);
  int res = 0;
  for (int i = 1; i <= 2; i++) {
    res += A[i] - A[i - 1];
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String S=sc.next();
        String T=sc.next();
        int[] start=new int[26];
        int[] goal=new int[26];
        for(int i=0; i<26; i++) {
            start[i]=-1;
            goal[i]=-1;
        }

        for(int i=0; i<S.length(); i++) {
            int a=S.charAt(i)-'a';
            int b=T.charAt(i)-'a';
            if(start[a]!=-1 || goal[b]!=-1) {
                if(start[a]!=b || goal[b]!=a) {
                    System.out.println("No");
                    System.exit(0);
                }
            }
            else {
                start[a]=b;
                goal[b]=a;
            }
        }
		System.out.println("Yes");
    }
}


Measured memory_bytes: 27448
#include <stdio.h>

int main (void)
{
	long a,b,d,r;
	double A,B,f;

	scanf("%ld %ld", &a, &b);

	d=a/b;
	r=a%b;
	A=a;
	B=b;
	f=A/B;

	printf("%ld %ld %f\n", d,r,f);

	return 0;
}

Measured memory_bytes: 636
#include<stdio.h>
#include<string.h>
int main(void)
{
	int  sx, sy, x1, y1, x2, y2, count1 = 0, count2 = 0, i, n, t;
	scanf("%d%d%d%d", &x1, &y1, &x2, &y2);

	sx = x2 - x1; sy = y2 - y1;

	if (sx < 0)sx = sx - sx * 2;
	if (sy < 0)sy = sy - sy * 2;
	for (i = 0; i < sy; i++)
	{
		printf("U");
		count1++;
	}
	for (i = 0; i < sx; i++)
	{
		printf("R");
		count2++;
	}
	i = 0;
	while (count1 != i)
	{
		printf("D");
		i++;
	}
	i = 0;
	while (count2 != i)
	{
		printf("L");
		i++;
	}


	printf("L");

	for (i = 0; i < sy + 1; i++)
	{
		printf("U");
	}
	for (i = 0; i < sx + 1; i++)
	{
		printf("R");
	}
	printf("D");


	printf("R");
	i = 0;
	while (sy + 1 != i)
	{
		printf("D");
		i++;
	}
	i = 0;
	while (sx + 1 != i)
	{
		printf("L");
		i++;
	}
	printf("U");



return 0;
}

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

int main(){
    int a, b, c;
    int cnt = 0;
    cin >> a >> b >> c;
    for(int i=0; i<=b-a; i++){
        if(c % (a+i) == 0){
            cnt++;
        }
    }
    cout << cnt << endl;
}

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

typedef long long ll;
const ll mod = 1e9 + 7;
const int N=2000000;
const int M=2000;

void Run()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
ll a[N];
int main()
{
    Run();
    int n,cnt=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]%2==1&&i%2==0)
            cnt++;
    }
    cout<<cnt;
}


Measured memory_bytes: 3620
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <assert.h>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    set<int> st;
    REP(i,k){
        if (a + i > b) break;
        st.insert(a + i);
        st.insert(b - i);
    }
    for (int x : st) cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int  long long 
main(){
	int n;
	cin>>n;
	int i=(int)sqrt(n)+1;
	for(;i>=1;i--){
		if(n%i==0){
			cout<<(n/i)+i-2<<"\n";
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void swap(int &a, int &b) {
	int aux = a;
	a = b;
	b = aux;
}
int main() {
	int x, y, z; cin >> x >> y >> z;
	swap(x, y); swap(x, z);
	cout << x << " " << y << " " << z << endl;
	return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while ((str = reader.readLine()) != null) {
			StringTokenizer st = new StringTokenizer(str);
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			System.out.println(String.format("%d %d", getGCD(a,b), getLCM(a,b)));
		}
		reader.close();
	}

	private int getGCD(int a, int b) {
		int ans = 1;
		for (int i = 1; i <= a; i++) {
			if (a % i == 0) {
				if (b % (a / i) == 0) {
					ans = a / i;
					break;
				}
			}
		}
		return ans;
	}
	
	private int getLCM(int a, int b) {
		int ans = 0;
		int m = 1;
		while (true) {
			if (b * m % a == 0) {
				ans = b * m;
				break;
			}
			m++;
		}
		return ans;
	}
}


Measured memory_bytes: 24600
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    ll a[200010];
    cin >> N;
    rep(i,0,N){
        cin >> a[i];
    }
    ll sum[200010] = {};
    rep(i,0,N){
        sum[i + 1] = sum[i] + a[i];
    }

    ll ans = 1e18;
    rep(i,0,N-1){
        ll x = sum[i+1];
        ll y = sum[N] - sum[i+1];
        ans = min(abs(x-y), ans);
    }
    print(ans);
}


Measured memory_bytes: 3328
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var arr = new int[10001];
            var n = int.Parse(Console.ReadLine());
            
            
            var result = 0;
            for(var x = 1; x <= 100; x++)
            {
                for(var y = 1; y <= 100; y++)
                {
                    for(var z = 1; z <= 100; z++)
                    {
                        var val = Math.Pow(x, 2) + Math.Pow(y, 2) + Math.Pow(z, 2) + x * y + y * z + z * x;
                        if(val > 10000) continue;
                        arr[(int)val] += 1;
                    }
                }
            }
            
             for(var i = 1; i <= n; i++)
            {
                Console.WriteLine(arr[i].ToString());
            }
        }
    }
}


Measured memory_bytes: 27596
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair



int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	string s;
	int k;
	cin >> s >> k;
	for (int i = 0; i < (int)s.length(); i += k)
		cout << s[i];
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
from itertools import*
from collections import*
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


n,*a=map(int,open(0).read().split())
print(sum(cmb(v,2)for k,v in Counter(accumulate(a)).items() if v>1)+list(accumulate(a)).count(0))

Measured memory_bytes: 39176
loop {
  n, x = gets.chomp.split(' ').map { |i| i.to_i }
  if n == 0 and x == 0 then break
  else
    ary = Array.new
    num = 0
    (1..n).each { |i| ary.push(i) }
    while ary.size > 1
      remain = x - ary.pop
      (1..ary.last).each { |i|
        (i..ary.last).each { |j|
          unless i == j
            if i + j == remain then num += 1 end
          end
        }
      }
    end
    puts num
  end
}

Measured memory_bytes: 6104
n=int(input())
A=list(map(int,input().split()))
X=[0]*n
s=0
for i in range(n):
    s+=((-1)**i)*A[i]
X[0]=s//2
for i in range(n-1):
    X[i+1]=A[i]-X[i]
print(*[2*x for x in X])

Measured memory_bytes: 16924