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

using namespace std;

int main() {
  int n,m,tmp=0,ans=0;
  cin>>n>>m;
  int h[100000],ab[100000];
  for(int i=0;i<n;i++){
    cin>>h[i];
    ab[i]=0;
  }
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    ab[x-1]=max(ab[x-1],h[y-1]);
    ab[y-1]=max(ab[y-1],h[x-1]);
  }
  /*
  for(int i=0;i<n;i++){
    if(ab[i]==0){
        ab[i]=0;
    }
    }*/

  for(int i=0;i<n;i++){
    if(ab[i]<h[i]){
        ans++;
    }
  }
  
  cout<<ans;
  return 0;
}
    
  
  
  

Measured memory_bytes: 4416
from math import gcd
K = int(input())
plus = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        temp = gcd(a, b)
        if temp != 1:
            for c in range(1, K+1):
                plus += gcd(temp, c)
        else:
            plus += K
print(plus)

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

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
#define FOR_ITER(x, a) for(auto x = a.begin(); x != a.end(); ++x)



using namespace std;
typedef unsigned char byte;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<ll, ll> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }

using namespace std;


int main(){
//    int n, l;
//    cin >> n >> k;
//    vector<bool> dislike(10, false);
//
//    FOR(i, 0, k) {
//        int t;
//        cin >> t;
//        dislike[t] = true;
//    }

    ll a, b, c;
    cin >> a>>b>>c;
    ll rs = b/c - (a -1)/c;
    if(a == 0 && c != 1) rs += 1;
    cout <<rs<< endl;


    return 0;
}


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, M;
int k[110], s[110][110], p[110];
int G[110][110];
signed main() {
    cin >> N >> M;
    rep(i, M) {
        cin >> k[i];
        rep(j, k[i]) {
            cin >> s[i][j], s[i][j]--;
            G[i][s[i][j]] = 1;
        }
    }
    rep(i, M) { cin >> p[i]; }
    int ans = 0;
    rep(i, bit(N)) {
        vint cnt(M);
        rep(j, N) {
            rep(k, M) {
                cnt[k] += ((i >> j) & 1) * G[k][j];
            }
        }
        bool f = 1;
        rep(j, M) { f &= cnt[j] % 2 == p[j]; }
        ans += f;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
#define PI 3.14159265358979323846

int main(){
    int a, b, x; cin >> a >> b >> x;
    double theta;
    if(x >= a*a*b/2)
        theta = atan(2.0*b/a - 2.0*x/(a*a*a));
    else
        theta = PI / 2 - atan(2.0*x/(a*b*b));
    theta = theta / PI * 180;
    cout << setprecision(12) << theta << endl;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 D;
  std::cin >> D;
  std::cout << "Christmas";
  for (i64 i = D; i < 25; ++i) {
    std::cout << " Eve";
  }
  std::cout << std::endl;
  return 0;
}

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

ll N;
const ll MAX_N = 3.0e5 + 100;
vector<bitset<60> > A;
const int MOD = 1.0e9 + 7;

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        bitset<60> bt(a);
        A.push_back(bt);
    }

    ll ans = 0;
    for (int i = 0; i <= 60; i++) {
        ll one = 0;
        for (int j = 0; j < N; j++) {
            if (A[j][i] == 1) one++;
        }

        ll a = one * (N - one) % MOD;
        ll b = (ll)pow(2, i) % MOD;
        ans = (ans + a*b % MOD) % MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5232
import sys
#sys.stdin = open('a_3.txt', 'r')
chars = list(raw_input())
#N, E, S, W
directions = [0 for _ in range(4)]

for c in chars:
	if c == 'N':
		directions[0] = 1
	elif c == 'E':
		directions[1] = 1
	elif c == 'S':
		directions[2] = 1
	else:
		directions[3] = 1

if ((directions[0] == directions[2]) and (directions[1] == directions[3])):
	print 'Yes'
else:
	print 'No'


Measured memory_bytes: 2568
import sys
input = sys.stdin.readline
n, m = map(int, input().split())

parent = [i for i in range(n + 1)]
rank = [0] * (n + 1)
weight = [0] * (n + 1)

def find(x):
    if parent[x] == x:
        return x
    else:
        y = find(parent[x])
        weight[x] += weight[parent[x]]
        parent[x] = y
        return y

def union(x, y, w):
    rx = find(x)
    ry = find(y)
    if rank[rx] < rank[ry]:
        parent[rx] = ry
        weight[rx] = w - weight[x] + weight[y]
    else:
        parent[ry] = rx
        weight[ry] = -w - weight[y] + weight[x]
        if rank[rx] == rank[ry]:
            rank[rx] += 1

def same_check(x, y):
    return find(x) == find(y)

def diff(x, y):
    return weight[x] - weight[y]

ans = "Yes"
for i in range(m):
    l, r, d = map(int, input().split())
    if same_check(l, r):
        if diff(l, r) != d:
            ans = "No"
            break
    else:
        union(l, r, d)
print(ans)

Measured memory_bytes: 10204
#include<iostream>
int main()
{
	using namespace std;
	int N;
	cin >> N;
	for (int c=cin.ignore(1).get(); c != '\n'; c = cin.get())
		cout.put("ABCDEFGHIJKLMNOPQRSTUVWXYZ"[(c - 'A' + N) % 26] );
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std; 
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int x,k,d;
	cin>>x>>k>>d;
	if(x==0){
		if(k%2==0){
			cout<<"0";
		}
		else{
			cout<<d;
		}
	}
	else if(x<0){
		long long int l=abs(x);
		long long int s=l/d;
		long long int dd=s*d;
		long long int kd=k-s;
		if(kd>=0){
			if(kd%2==0){
				cout<<abs(x+dd);
			}
			else{
				cout<<min(abs(x+dd-d),abs(x+dd+d));
			}	
		}
		else{
			cout<<abs(x+(k*d));
		}
	}
	else{
		long long int l=x;
		long long int s=l/d;
		long long int dd=s*d;
		long long int kd=k-s;
		if(kd>=0){
			if(kd%2==0){
				cout<<abs(x-dd);
			}
			else{
				cout<<min(abs(x-dd-d),abs(x-dd+d));
			}	
		}
		else{
			cout<<x-(k*d);
		}
	}
   	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll N, x; cin >> N >> x;
  vector<ll> a(N); rep(i,N) cin >> a[i];
  vector<ll> b = a;
  ll ans = 0;
  rep(i,N){
    if(i==0) continue;
    if(a[i-1]+a[i] > x){
      ans += a[i-1]+a[i]-x;
      a[i] = max(ll(0), x-a[i-1]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int x = 0,y = 0,n_x,n_y,memo = 0,n,h,w;
    cin >> h >> w >> n;
    cin >> x >> y;
    rep(i,1,n){
        cin >> n_x >> n_y;
        if((x <= n_x && y <= n_y) || (x >= n_x && y >= n_y)){
            memo += max(abs(n_x-x),abs(n_y-y));
        }
        else{
            memo += abs(n_x-x)+abs(n_y-y);   
        }
        x = n_x,y = n_y;
    }
    
    
    cout << memo << endl;
    return 0;   
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-4;
const int MAX=1e6+10;
const ll mod=1e9+7;
/****************************************  head  ****************************************/
int main()
{
	int i,j,flag;
	string a,b;
	while(cin>>a>>b)
	{
		flag=0;
		for(i=0;i<110;i++)
		{
			if(a==b) flag=1;
			for(j=sz(a)-1;j;j--) swap(a[j],a[j-1]);
		}
		flag?puts("Yes"):puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
 
#define INF 10000000000000LL
 
int N;
vector<ll> A;
vector<int> G[100005];
 
ll dfs(int v, int p){
  if(p!=-1 && G[v].size() == 1) return A[v];
 
  ll sum = 0;
  vector<ll> c;
  rep(i,G[v].size()){
    if(G[v][i] == p) continue;
    ll res = dfs(G[v][i], v);
    if(res<0 || res > A[G[v][i]]) return -INF;
    sum += res;
    c.push_back(res);
  }
  if(c.size() == 1){
    if(A[v]==c[0]) return c[0];
    return -INF;
  }
 
  ll T = 2LL*A[v] - sum;
  if(T<0 || T>A[v]) return -INF;

  sum += T;
  rep(i,c.size()){
    if(c[i] > sum/2) return -INF;
  }
  return T;
}
 
 
bool solve(){
  ll sum = 0;
  ll leaf1 = -1;
  rep(i,N){
    if(G[i].size() == 1){
      sum += A[i];
      leaf1 = i;
    }
  }
  /*
  if(sum%2!=0) return false;
  ll n = sum/2;
  rep(i,N){
    if(A[i] > n) return false;
  }
  */
  ll res = dfs(leaf1,-1);
  if(res == A[leaf1]) return true;
  return false;
}
 
int main(){
  cin >> N;
  rep(i,N){
    ll a;
    cin >> a;
    A.push_back(a);
  }
  rep(i,N-1){
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
 
  if(solve()) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}


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

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

    if(x/a >= 0.5 * a * b){
        cout << fixed << setprecision(10) << atan(2 / (a * a) * (a * b - x/a)) * 180.0 / M_PI << endl;
    }else{
        cout << fixed << setprecision(10) << atan(a * b * b / x / 2.0) * 180.0 / M_PI << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

  ll n;
	cin >> n;
	vll a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];
	ll cnt = 0;
	vll check(n, 0);
	for (ll i = 0; i < n; i++) {
		if (check[i] == 1) continue;
		if (a[a[i] - 1] - 1 == i) {
			cnt++;
			check[a[i] - 1]++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 1792
s_text = list(map(int, input().split()))
output = [0] * s_text[0]
flag = True
for i in range(s_text[1]):
    text = list(map(int, input().split()))

    if text[0] == 1 and text[1] == 0 and s_text[0] != 1:
        flag = False
    if output[text[0] - 1] == 0 or output[text[0] - 1] == text[1]:
        output[text[0] - 1] = text[1]
    else:
        flag = False

if output[0] == 0 and s_text[0] != 1:
    output[0] = 1

if flag:
    print("".join(map(str, output)))
else:
    print("-1")

Measured memory_bytes: 38256
//control+option+n to run!
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define NEGFOR(i, a, b) for (ll i = (a); i > (b); i--)
#define vll vector <long long>
#define sll set <long long>
#define ld long double
#define inf 1000000000000000000
#define mll multiset <long long>
#define nn <<"\n"
#define F(i,b) for (ll i=0; i<b; i++)
//10^8 operations per second
//greatest int is 2,147,483,647
//greates long long is 9.22337204e18

//ALL FUNCTIONS SHOULD BE LL!!!!
long long power(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = power(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}


ll log(ll base, ll number)
{

  int x = base;
  int count = 1;
  while (base < number)
  {
    base *= x;
    count++;
  }
  return count;
}

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

  //idea is to just take min(dp[i-1] and dp[i-2] plus the respective jumps)
  ll n,k;
  cin>>n>>k;
  vll v(n+1);

  FOR(i,1,n+1){
    cin>>v[i];
  }

  vll dp(n+1,inf);

  dp[1]=0;
  FOR(i,2,n+1){
    FOR (j,(ll)max(i-k,(ll)0),i){
      dp[i]=min(dp[j]+abs(v[i]-v[j]),dp[i]);
    }
    
  }

  cout<<dp[n];
  cout << "\n"; //GET RID OF THIS FOR THE ACTUAL PROGRAM!!!!
}


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

const int MAXN = (int) 2e5;
const int LOG  =  (int) 17;


int v[MAXN + 1];
int rmq[2][MAXN + 1][LOG + 1];

char lg[MAXN + 1];

struct Data {
    int l, r;
    int pos;
    bool operator <(const Data &other) const {
         return v[pos] > v[other.pos];
    }
};

std::priority_queue <Data> pq;


inline int check(int l, int r, int p) {
    p %= 2;
    int p2 = lg[r - l + 1];
    if(v[rmq[p][l][p2]] < v[rmq[p][r - (1 << p2) + 1][p2]])
       return rmq[p][l][p2];
    return rmq[p][r - (1 << p2) + 1][p2];
}

int main() {
    FILE * fi, * fout;
    int i, n;
    //fi = fopen("A.in" ,"r");
    //fout = fopen("A.out" ,"w");
    fi=stdin;
    fout=stdout;
    fscanf(fi,"%d" ,&n);
    int pos;
    int min = (1 << 30);
    for(i = 1; i <= n; i++) {
        fscanf(fi,"%d" ,&v[i]);
        if(i % 2 == 1 && v[i] < min && i < n) {
           pos = i;
           min = v[i];
        }
    }
    for(i = 2; i <= n; i++)
        lg[i] = lg[i >> 1] + 1;
    v[0] = (1 << 30);
    for(i = 1; i <= n; i++)
        rmq[i & 1][i][0] = i;
    for(int p2 = 1; (1 << p2) <= n; p2++)
        for(i = 1; i + (1 << p2) <= n + 1; i++)
            for(int r = 0; r < 2; r++)
               if(v[rmq[r][i][p2 - 1]] < v[rmq[r][i + (1 << (p2 - 1))][p2 - 1]])
                  rmq[r][i][p2] = rmq[r][i][p2 - 1];
               else
                  rmq[r][i][p2] = rmq[r][i + (1 << (p2 - 1))][p2 - 1];
    pq.push({1, n, pos});
    while(!pq.empty()) {
         Data x = pq.top();
         pq.pop();
         pos = check(x.pos, x.r, x.l + 1);
         fprintf(fout,"%d %d " ,v[x.pos],v[pos]);
         if(x.l < x.pos - 1)
           pq.push({x.l, x.pos - 1, check(x.l, x.pos - 2, x.l)});
         if(x.pos + 1 < pos - 1)
           pq.push({x.pos + 1, pos - 1, check(x.pos + 1, pos - 2, x.pos + 1)});
         if(pos + 1 < x.r)
           pq.push({pos + 1, x.r, check(pos + 1, x.r - 1, pos + 1)});
    }
    //fclose(fi);
    //fclose(fout);
    return 0;
}


Measured memory_bytes: 31224
import sys
input = sys.stdin.readline
def main():
    a, b, c, d = map(int, input().split())
    ans = 0
    o = a*c
    p = a*d
    q = b*c
    r = b*d
    ans = max(o, p,q, r)
    print(ans)

        



if __name__ == '__main__':
    main()

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

int get_luggage_num(int *w, int n, int P, int k){
    int count = 0, temp_sum = 0, truck_sum = 1;
    for (int i = 0; i < n; i++){
        temp_sum += w[i];
        if (temp_sum > P){
            truck_sum += 1;
            temp_sum = w[i];
        }
        if (truck_sum <= k && temp_sum <= P){
            count += 1;
        } else {
            break;
        }
    }
    return count;
}

// int check(int *w, int n, int P, int k){
//     int i = 0;
//     for (int j = 0; j < k; j++){
//         long long s = 0;
//         while (s + w[i] <= P){
//             s += w[i];
//             i++;
//             if (i == n) return n;
//         }
//     }
//     return i;
// }

int main(){
    int n, k, v, P = 0;
    int *w;

    scanf("%d %d", &n, &k);
    w = new int[n];
    for (int i = 0; i < n; i++){
        scanf("%d", &w[i]);
        // if (P < w[i]){
        //     P = w[i];
        // }
    }

    // while (true){
    //     v = get_luggage_num(w, n, P, k);
    //     if (v < n){
    //         P += 1;
    //     } else {
    //         break;
    //     }
    // }
    // printf("%d\n", P);

    // [answer]
    long long left = 0, right = 100000 * 10000, mid;
    while (right - left > 1){
        mid = (left + right) / 2;
        v = get_luggage_num(w, n, mid, k);
        // printf("mid = %lld\n", mid);
        // printf("get_luggage_num : %d\n", v);
        // v = check(w, n, mid, k);
        // printf("check : %d\n", v);
        // printf("\n");
        if (v >= n) right = mid;
        else left = mid;
    }
    printf("%lld\n", right);
    delete[] w;
}



Measured memory_bytes: 3420
#define _GLIBCXX_DEBUG
#include"bits/stdc++.h"

using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define AToB(i,a,b) for(int i=a;i<(ll)(b+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back

#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

//pair
#define fir first
#define sec second

//types
#define ll long long
#define vec vector
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T = int>
void print(vec<T> v){ for (T item: v) { cout << item << " "; } cout << endl; }

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__
#define next next__
#define prev prev__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

void Main() {
    //code here
    map<int, int> divs;
    OneToN(i1, 200) {
        int count = 0;
        OneToN(i2, i1) {
            if (i1%i2 == 0) {
                count ++;
            }
        }
        divs[i1] = count;
    }

    int n = gi;
    int res = 0;
    OneToN(i, n) {
        if (i%2 != 0) {
            if (divs[i] == 8) {
                res += 1;
                //print(i);
            }
        }
    }
    print(res);
}

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

Measured memory_bytes: 256
N, Q = map(int, input().split())
string = input()
 
counter = [0]*(N+1)

for i in range(N):
    counter[i+1] = counter[i] + (1 if string[i:i+2] == "AC" else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(counter[r-1] - counter[l-1])

Measured memory_bytes: 7748
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
typedef long long ll;

int main(){
	ll n, m, d;
	cin >> n >> m >> d;

	double res = 0;
	if (d == 0) {
		res = n;
	}
	else if (n > 2 * d) {
		//res = 1.0 * 2 * d + 2 * (n - 2 * d);
		res = 2 * (n-d);
	} else {
		res = 1.0 * (n - d) * 2;
	}
	res = res / pow(n,2) * (m-1);
	printf("%.10f\n", res);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a,b,n,i;
	int suma=0,sumb=0;
	while(1){
		cin>>n;
		if(n==0)break;
		suma=0;sumb=0;
		for(i=0;i<n;i++){
			cin>>a>>b;
			if(a==b){
				suma+=a;
				sumb+=b;
			}
			else if(a>b){
				suma+=a+b;
			}else{
				sumb+=a+b;
			}
		}
		cout<<suma<<" "<<sumb<<endl;
	}
	return 0;
}

Measured memory_bytes: 2968
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ULL unsigned long long
#define LL long long
#define Max 100005
#define mem(a,b) memset(a,b,sizeof(a));
#define pb push_back
#define mp make_pair
#define input ios::sync_with_stdio(false);cin.tie(0);
#define debug printf("debug!!!\n");
const LL mod=1e9+7;
const ULL base=131;
const LL LL_MAX=9223372036854775807;
using namespace std;
LL dp[Max][15];
string s;
int main()
{
    cin>>s;
    if(s[0]=='?')
        for(int i=0;i<=9;i++)
            dp[0][i]=1;
    else
        dp[0][(s[0]-'0')]=1;
    int len = s.size();
    for(int i=1;i<len;i++){
        if(s[i]=='?'){
            for(int j=0;j<=12;j++)
                for(int k=0;k<=9;k++){
                    int t=(j*10+k)%13;
                    dp[i][t]=(dp[i][t]+dp[i-1][j])%mod;
                }

        }else{
            for(int j=0;j<=12;j++){
                int t=(j*10+(s[i]-'0'))%13;
                dp[i][t]=(dp[i][t]+dp[i-1][j])%mod;
            }
        }
    }
    printf("%lld\n",dp[len-1][5]);
    return 0;
}


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

long long hasil,x,h;

main () {
	cin >> x;
	h = x % 1000;
	if (x % 1000 == 0) {
		h = 1000;
	}
	hasil = 1000 - h;
	cout << hasil << endl;
}

Measured memory_bytes: 3636
from operator import itemgetter

n, m = map(int, input().split())

# 区間の終端でソート
ab = sorted([tuple(map(int, input().split())) for i in range(m)], key=itemgetter(1))
# 前回除いた橋
removed = -1
ans = 0

for a, b in ab:
    # a が removed より大きい = まだ取り除いてない
    if a > removed:
        removed = b - 1
        ans += 1

print(ans)

Measured memory_bytes: 18980
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
const int maxn = 1e6+10;
int a[maxn];
int dp[maxn];
int main()
{
    int n;
    memset(dp,INF,sizeof dp);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",a+i);
    }
    dp[1]=0;
    for(int i=1;i<=n-1;i++)
    {
        dp[i+1]=min(dp[i+1],dp[i]+abs(a[i+1]-a[i]));
        dp[i+2]=min(dp[i+2],dp[i]+abs(a[i+2]-a[i]));
    }
    printf("%d\n",dp[n]);
    return 0;
}


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

#define ll long long
#define ld long double
#define pb push_back
#define pr pair<ll, ll>
#define vct vector<ll>
#define vpt vector<pr>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define F(i, n) for (i = 0; i < (1LL*n); i++)
#define Fr(i, n) for (i = n - 1; i >= 0; i--)

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, long long, custom_hash>
void prv(vct v)
{
    for (ll i = 0; i < v.size(); i++)
        cout << v[i] << " ";
    cout << "\n";
}
ll poww(ll x, ll y, ll m)
{
    ll res = 1;
    while (y)
    {
        if (y % 2 == 0)
        {
            x = (x * x) % m;
            y = y / 2;
        }
        else
        {
            res = (res * x) % m;
            y--;
        }
    }
    return res;
}
void deb(string s, ll n)
{
    cout << s << " : " << n << "\n";
}
void prn(ll n) { cout << n << "\n"; }
void prs(string n) { cout << n << "\n"; }

mat mt;
void setmtsize(ll m,ll n, ll ini=0){
    mt.resize(m,vector<ll>(n,ini));
}
void prmt(mat m){
    for(ll i=0;i<(1LL*m.size());i++)prv(m[i]);
}
vct divsors(ll n)
{
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++)
    {if(n%i==0){ans.push_back(i);if(i!=(n/i))ans.push_back(n/i);}}
    sort(ans.begin(),ans.end());
    return ans;
}
vct sieve(ll n){
    vct ans(n+1,-1);
    for(ll i=2;i<=n;i++){
        if(ans[i]==-1){
            for(ll j=i;j<=n;j+=i)if(ans[j]==-1)ans[j]=i;
        }
    }
    return ans;
}
ll n, k, m, l, r, x, y, z, ans=0;
ll t, t1, t2;
// ll q;
ll i, j;
ll a, b, c;
ll mod = 1000000007;
ll cas=0;
ll cnd(ll n){
    ll an=0;
    while(n){
        an++;
        n/=10;
    }
    return an;
}
void solve()
{
    ans=-1;
    cin>>n;
    ll cd=cnd(n);
    string s(cd,'7');
    ll num=stoi(s);
    ans=cd;
    if(num<n){num=num*10+7;ans++;}
    umap mp;
    while(true){
        if(num%n==0)break;
        ll rem=num%n;
        if(mp.find(rem)!=mp.end()){
            ans=-1;
            break;
        }
        mp[rem]=1;
        num=rem*10+7;
        ans++;
    }
    prn(ans);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    
    ll t = 1;
    // cin >> t;
    cas=1;
    // stress();
    while (t--){
        solve();
        cas++;
    }
    return 0;
}

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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

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

  int sum = 0;
  VI v(m);
  REP(i, m) {
    cin >> v[i];
    sum += v[i];
  }

  if (n - sum < 0) {
    ANS(-1);
  } else {
    ANS(n - sum);
  }

  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
const double pi = 3.141592653589793;
int64_t M = 1000000000000000000;
int main(){
    int n;
    cin>>n;
    vector<int64_t> a(n);
    bool z=false;
    rep(i,n){
        cin>>a[i];
        if(a[i]==0){
            z=true;
        }
    }
    if(z){
        cout<<0<<endl;
        return 0;
    }
    int64_t sum=1;
    int64_t lim=M;
    rep(i,n){
        if(lim<a[i]){
            cout<<-1<<endl;
            return 0;
        }
        lim /=a[i];
        //cout<<lim<<" ";
        sum *= a[i];
    }
   // cout<<endl;
    if(sum<=M){
        cout<<sum<<endl;
    }
    else{
        cout<<-1<<endl;
    }
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//Get the highest value and key from a map.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

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

  cout << (p + (a * 3)) / 2 << endl;;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
 
using namespace std;
 
int main()
{
  int A,B;
  cin>>A>>B;
  if(A == 1 && B != 1)
  {
    cout<<"Alice"<<endl;
  }
  else if(A != 1 && B == 1)
  {
    cout<<"Bob"<<endl;
  }else if(A == 1 && B == 1)
  {
    cout<<"Draw"<<endl;
  }else{
    if(A<B)
    {
      cout<<"Bob"<<endl;
    }else if(A > B)
    {
      cout<<"Alice"<<endl;
    }else
    {
      cout<<"Draw"<<endl;
    }
  }
}

Measured memory_bytes: 256
#[allow(dead_code)]
const MOD: usize = 1_000000000 + 7;

fn main() {
    let mut cin = Scanner::new();
    let a = cin.next_isize();
    let b = cin.next_isize();
    println!("{}", -a + 2 * b);
}


struct Scanner {
    reader: std::io::Stdin,
    tokens: std::collections::VecDeque<String>,
}

impl Scanner {
    fn new() -> Self {
        Scanner {
            reader: std::io::stdin(),
            tokens: std::collections::VecDeque::new(),
        }
    }

    fn next(&mut self) -> String {
        if self.tokens.is_empty() {
            let mut s = String::new();
            loop {
                self.reader.read_line(&mut s).ok();
                let s = s.trim();
                if s.len() != 0 {
                    for it in s.split_whitespace() {
                        self.tokens.push_back(it.into())
                    }
                    break;
                }
            }
        }
        self.tokens.pop_front().unwrap()
    }

    fn next_generics<T>(&mut self) -> T where
        T: std::str::FromStr + std::marker::Copy,
        <T as std::str::FromStr>::Err: std::fmt::Debug
    {
        self.next().parse().unwrap()
    }
    
    #[allow(dead_code)] fn next_i32(&mut self) -> i32 { self.next_generics::<i32>() }
    #[allow(dead_code)] fn next_i64(&mut self) -> i64 { self.next_generics::<i64>() }
    #[allow(dead_code)] fn next_u64(&mut self) -> u64 { self.next_generics::<u64>() }
    #[allow(dead_code)] fn next_usize(&mut self) -> usize { self.next_generics::<usize>() }
    #[allow(dead_code)] fn next_isize(&mut self) -> isize { self.next_generics::<isize>() }
}



Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using 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 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()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
bool func(ll x){
  for(int i=0;i*i<=x;i++){
    if(i*i==x){
      return true;
    }
  }
  return false;
}
int main(){
  ll n,d;
  cin >> n >> d;
  ll x[n][d];
  rep(i,n){
    rep(j,d){
      cin >> x[i][j];
    }
  }
  ll sum=0;
  ll tmp;
  rep(i,n){
    REP(j,i+1,n){
      tmp=0;
      rep(k,d){
        tmp += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      if(func(tmp)){
        sum++;
      }
    }
  }
  cout << sum;
}


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 = Integer.parseInt(sc.next());
    int M = Integer.parseInt(sc.next());

    long ans = 1;
    long mod = 1000000007;

    // 素数因数分解した結果のべき乗の部分のみ
    int p[] = new int[20];
    int pCount = 0;

    int m = M;
    for (int i = 2; i <= m; i++) {
      if (M % i == 0) {
        for (int j = 0; j < 32; j++) {
          if (M % i == 0) {
            p[pCount]++;
            M = M / i;
          } else {
            break;
          }
        }
        pCount++;
        if (M == 1) {
          break;
        }
      }
    }

    combination c = new combination(N + 50, mod);

    for (int i = 0; i < 20; i++) {
      ans = (ans * c.C(N - 1 + p[i], p[i])) % mod;
    }

    System.out.println(ans);

  }

  static class combination {
    public int n;
    public long p;
    public long factTable[];
    public long reverceTable[];

    public combination(int n, long p) {
      this.n = n;
      this.p = p;
      factTable = new long[n + 1];
      factTable[0] = 1;
      for (int i = 1; i <= n; i++) {
        factTable[i] = factTable[i - 1] * i % p;
      }
      reverceTable = new long[n + 1];
      reverceTable[0] = 1;
      reverceTable[n] = 1;
      long x = factTable[n];
      long m = p - 2;
      while (m > 0) {
        if ((m & 1) == 1) {
          reverceTable[n] = reverceTable[n] * x % p;
        }
        x = x * x % p;
        m >>= 1;
      }
      for (int i = n - 1; i > 0; i--) {
        reverceTable[i] = reverceTable[i + 1] * (i + 1) % p;
      }
    }

    public long C(int n, int r) {
      if (r < 0 || n < r) {
        return 0;
      } else if (r == n || r == 0) {
        return 1;
      } else {
        return (factTable[n] * reverceTable[r] % p) * reverceTable[n - r] % p;
      }
    }
  }
}

Measured memory_bytes: 25172
let input = require('fs').readFileSync('/dev/stdin', 'utf8');
let Arr = (input.trim()).split("\n");
let N1 = Number(Arr[0]);
let arr1 = Arr[1].split(" ").map(Number);
let arr2 = Arr[3].split(" ").map(Number);

const binarySearch = (key) => {
  let mid;
  let left = 0;
  let right = N1;
  if (key < arr1[0] || arr1[N1-1] < key) return 0;
  while (left < right) {
    mid = Math.floor((left + right) / 2);
    if (key < arr1[mid]) right = mid;
    else if (key > arr1[mid]) left = mid + 1;
    else return 1;
  }
  return 0;
}

console.log(arr2.map(e => binarySearch(e)).reduce((a, b) => a + b, 0));




Measured memory_bytes: 34896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		int max = a[0];
		int sum = 1;
		for (int i = 1; i < n; i++) {
			if (a[i] >= max) {
				sum++;
				max = a[i];
			}
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 21972
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int d[202020];
typedef long long ll;
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)scanf("%d", &d[i]), d[i] = i - d[i];
	ll ans = 0;
	for (int i = 0; i < num; i++)
	{
		if (d[i] < 0)goto l01;
		if (i != 0 && d[i - 1] > d[i])goto l01;
		if (i != 0 && d[i - 1] == d[i])ans++;
		if (i != 0 && d[i - 1] < d[i])ans += i - d[i];
	}
	printf("%lld\n", ans);
	if (false)
	{
	l01:;
		printf("-1\n");
	}
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s,t; cin>>s>>t;
  ll n=s.size();
  rep(i,n){
    s=s.substr(1,n-1)+s[0];
    if(s==t){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<stack>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;

struct Point{
	double x,y;
};

struct Line{
	double x[2],y[2];
};

int main(){
	Point p;
	Line l;
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&l.x[0],&l.y[0],&l.x[1],&l.y[1],&p.x,&p.y)!=EOF){
		if(l.x[0]==l.x[1]){
			printf("%lf %lf\n",p.x+(l.x[0]-p.x)*2,p.y);
		}
		else if(l.y[0]==l.y[1]){
			printf("%lf %lf\n",p.x,p.y+(l.y[0]-p.y)*2);
		}
		else{
			double a[2],b[2],x;
			a[0] = (l.y[1]-l.y[0])/(l.x[1]-l.x[0]);
			b[0] = l.y[0]-a[0]*l.x[0];
			a[1] = -(l.x[1]-l.x[0])/(l.y[1]-l.y[0]);
			b[1] = p.y-a[1]*p.x;
			x = -(b[0]-b[1])/(a[0]-a[1]);
			printf("%lf %lf\n",p.x+(x-p.x)*2,a[1]*(p.x+(x-p.x)*2)+b[1]);
		}
	}
	return 0;
}

Measured memory_bytes: 1232
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> a(n);
  vector<int> b(m);
  inputV(a, n);
  inputV(b, m);
  a.push_back(x);
  b.push_back(y);
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if( a[n] < b[0] && x < y ) cout << "No War" << endl;
  else cout << "War" << endl;

  return 0;
}

//


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    int n;
    cin>>n;
    string s = to_string(n);
    int sum = 0;
    const int C = '0';
    for (int i=0; i<s.size(); ++i) {
        int c = s[i] - C;
        sum += c;
    }
    if (n % sum == 0) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl


int main() {
    int N, M;  cin >> N >> M;
    vector<int> k(M);
    vector<vector<int>> s(M);   
    rep(i, M) {
        cin >> k[i];
        rep(j, k[i]) {
            int t;
            cin >> t;
            s[i].push_back(t);
        }
    }
    vector<int> p(M);
    rep(i, M)  cin >> p[i];

    int ans = 0;
    for (int bit=0; bit < (1<<N); bit++) { // 00...0 ~ 11...1
        bool flag = true;
        for (int j=0; j<M; j++) {  // 電球 1 ~ M まで
            int cnt = 0;
            rep(l, k[j]) {  // 電球 j のスイッチについて
                int temp = s[j][l]-1;
                if (bit & (1<<temp)) ++cnt;
            }
            if (cnt % 2 != p[j]) {
                flag = false;
                break;
            }
        }
        if (flag) ++ans;
    }

    print(ans);

     
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define DEBUG 0
#define NINF -1
#define PINF 1E9+1

#define MAX_LEN 100001

char *s;

int main()
{
	int n,num0,num1,i;
	s = (char *)malloc(sizeof(char) * MAX_LEN);
	if (s==NULL) {
		perror("malloc");
		exit(1);
	}
	scanf("%s",s);

	n = 0;
	num0 = 0;
	num1 = 0;
	for (i=0;i<MAX_LEN;i++) {
		if (s[i]=='\0' || s[i]=='\n') break;
		if (s[i]=='0') num0++;
		else           num1++;
		n++;
	}

	if (num0>num1) printf("%d\n",num1*2);
	else           printf("%d\n",num0*2);

	free(s);
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
typedef pair<double,double> pdd;
const double EPS=1e-9;
#define debug(c) (cerr<<#c<<": "<<c<<"\n")
#define fi first
#define se second
#define mod 1000000007
#define pi acos(-1)
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
map<ll,set<ll> > row;
map<ll,set<ll> > col;
set<ll> rval;
map<ll,ll> rcnt;
int main()
{
	ios;
	ll h,w,m,x,y,maxr=0,maxc=0,len,i,j;
	cin>>h>>w>>m;
	for(i=1;i<=m;i++)
	{
		cin>>x>>y;
		row[x].insert(y);
		col[y].insert(x);
		ll l=row[x].size();
		maxr=max(maxr,l);
		l=col[y].size();
		maxc=max(maxc,l);
	}
	for(auto it=row.begin();it!=row.end();it++)
	{
		if((it->se).size()==maxr)
			rval.insert(it->fi);
	}
	len=0;
	for(auto it=col.begin();it!=col.end();it++)
	{
		if((it->se).size()==maxc)
		{
			for(auto it1=(it->se).begin();it1!=(it->se).end();it1++)
				rcnt[*it1]++;
			len++;
		}	
	}
	for(i=1;i<=h;i++)
	{
		if(rval.find(i)!=rval.end())
		{
			if(rcnt[i]!=len)
			{
				cout<<maxr+maxc<<endl;
				exit(0);
			}
		}
	}
	cout<<maxr+maxc-1<<endl;
}


Measured memory_bytes: 120844
n = int(input())
s = input()
rgb = ['R','G','B']

ans = 0
for j in range(1,n-1):
    rgb_tmp = [i for i in rgb if i!=s[j]]
    for a in range(2):
        color_i, color_k = rgb_tmp[a], rgb_tmp[a-1]
        ans += s[:j].count(color_i) * s[j+1:].count(color_k)
        
        for b in range(min(j,n-j-1)+1):
            if s[j-b] == color_i and s[j+b] == color_k:
                ans-=1
print(ans)
        


Measured memory_bytes: 68904
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define EB emplace_back
#define fi first
#define se second
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
 
#define INF ((1ll<<60)-233)
#define sqr(x) ((x)*(x))
#define debug puts("wzpkking")

using namespace std;

const int N=105;
char mp[N][N];
int n,m,ex,ey,ans;
int sr[N][N],sc[N][N];
int dp[N][N][N];
void mx(int &x,int y){
	x<y?x=y:0;
}
int main(){
	scanf("%d%d",&n,&m); CLR(dp,-1);
	For(i,1,n) scanf("%s",mp[i]+1);
	For(i,1,n) For(j,1,m)
		if (mp[i][j]=='o') sr[i][j]=sc[i][j]=1;
		else if (mp[i][j]=='E') ex=i,ey=j;
	For(i,1,n) For(j,1,m)
		sr[i][j]+=sr[i][j-1],
		sc[i][j]+=sc[i-1][j];
	int L=ey-1,R=m-ey,U=ex-1,D=n-ex;
	dp[0][0][0]=0;
	For(l,0,L) For(r,0,R) For(u,0,U) For(d,0,D){
		if (dp[r][u][d]==-1) continue;
		ans=max(ans,dp[r][u][d]);
		int up=max(ex-u,d+1),dn=min(ex+d,n-u);
		int le=max(ey-l,r+1),ri=min(ey+r,m-l);
		if (up>dn||le>ri) continue;
		if (u<U-d) mx(dp[r][u+1][d],dp[r][u][d]+sr[ex-u-1][ri]-sr[ex-u-1][le-1]);
		if (d<D-u) mx(dp[r][u][d+1],dp[r][u][d]+sr[ex+d+1][ri]-sr[ex+d+1][le-1]);
		if (r<R-l) mx(dp[r+1][u][d],dp[r][u][d]+sc[dn][ey+r+1]-sc[up-1][ey+r+1]);
		if (l<L-r) mx(dp[r][u][d]  ,dp[r][u][d]+sc[dn][ey-l-1]-sc[up-1][ey-l-1]);
	}
	printf("%d",ans);
}

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

int top, S[1000];

void push(int x) {
    S[++top] = x;
}

int pop() {
    top--;
    return S[top + 1];
}

int main(int argc, char *argv[])
{
    int a, b;
    top = 0;
    char s[100];
    while ( scanf("%s", s) != EOF ) {
        if (s[0] == '+') {
            a = pop();
            b = pop();
            push(a + b);
        } else if (s[0] == '-') {
            b = pop();
            a = pop();
            push(a - b);
        } else if (s[0] == '*') {
            a = pop();
            b = pop();
            push(a * b);
        } else {
            push(atoi(s));
        }
    }

    cout << pop() << endl;

    return 0;
}



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

/**
 * Created by khrom on 2017/06/29.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        List<String> nums = new ArrayList<>();
        int index = scanner.nextInt();
        for (int i = 0; i < index; i++) {
            nums.add(scanner.next());
        }
        StringBuilder strb = new StringBuilder();
        for (int i = nums.size() - 1; i >= 0; i--) strb.append(nums.get(i) + " ");
        strb.deleteCharAt(strb.length() - 1);
        System.out.println(strb.toString());
    }
}

Measured memory_bytes: 26208
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

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

            int N = Integer.parseInt(s);

            System.out.println(N % 2 == 0 ? N : 2 * N);
        }
    }
}


Measured memory_bytes: 21588