akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

import collections
import math


class Vector2(collections.namedtuple("Vector2", ["x",  "y"])):

    def __add__(self, other):
        return Vector2(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Vector2(self.x - other.x, self.y - other.y)

    def __mul__(self, scalar):  # cross product
        return Vector2(self.x * scalar, self.y * scalar)

    def __neg__(self):
        return Vector2(-self.x, -self.y)

    def __pos__(self):
        return Vector2(+self.x, +self.y)

    def __abs__(self):  # norm
        return math.sqrt(float(self.x * self.x + self.y * self.y))

    def dot(self, other):  # dot product
        return self.x * other.x + self.y * other.y

    def cross(self, other):  # cross product
        return self.x * other.y - self.y * other.x


if __name__ == '__main__':

    a, b, c, d = map(int, input().split())
    p1 = Vector2(a, b)
    p2 = Vector2(c, d)
    base = p2 - p1
    q = int(input())
    ans = []
    for _ in range(q):
        e, f = map(int, input().split())
        p = Vector2(e, f)
        hypo = Vector2(e - a, f - b)
        proj = p1 + base * (hypo.dot(base) / float(base.x**2 + base.y**2))
        x = p + (proj - p) * 2
        ans.append(x)

    for x in ans:
        print(x.x, x.y)



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

int main() {
	long long n,a,b;cin >>n>>a>>b;
	if((b-a)%2==0){
		cout << (b-a)/2 << endl; 
	} else {
		cout << min(a-1,n-b) + (b-a)/2 + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 384
/*/ Author: KaySeeKay /*/

#include<bits/stdc++.h>
using namespace std;  

/*/---------------------------Defines-----------------------------------------/*/

#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)  
#define fn1 for( int i =1;i<=n; i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;  
const int INF = 1e18L;
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/*/-----------------------------Debug begins----------------------------------/*/
vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    if(n>0)
    s << arr[n - 1] ;
    s<< "]";
    return s.str();
}
#define trace(args...) {__trace_begin(__LINE__); __trace(split(#args, ',').begin(), args);}
inline void __trace_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __trace_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __trace_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __trace_out_var(T val) { cerr << val; }
inline void __trace(vector<string>::iterator it) { cerr << endl; }
 
template<typename T, typename... Args>
inline void __trace(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __trace_out_var(a);
    cerr << "; ";
    __trace(++it, args...);
}
/*/-----------------------------Code begins----------------------------------/*/
int ar[N];
int dp[N];
signed main(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  IOS;
  int T=1;
  // cin >> T;
  while(T--){
    int n ,x,m;
    cin >> n >>x>>m;
    ar[1]=x;
    int ans = x;
    map<int,int>mp;
    mp[x]++;
    dp[1]=x;
    for(int i=2;i<=n;i++){
      ar[i]= (ar[i-1]%m*ar[i-1]%m)%m;
      if(mp.count(ar[i])==0)mp[ar[i]]=i;
      else{

          int prv= mp[ar[i]];
          int psum = dp[prv];
          int cur= ans+ar[i]- psum;
          int cnt = i-prv ;
          int rem = n-i;
          ans+=(rem/cnt)*cur;
          int rm = rem%cnt;
          ans+=dp[prv+rm]-dp[prv-1];
          // trace(ans, prv, i , ar[i]);
          break;
      }
      //492443256176507
      mp[ar[i]]=i;
      ans+=ar[i];
      dp[i]=ans;
      if(ar[i]==0)break;
    }
   
    cout <<ans;
  
  }
  return 0;
}

Measured memory_bytes: 7452
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    int N;
    cin >> N;
    int ans = 0;
    rep1(i,N) ans += sz(to_s(i))&1;
    pr(ans);
}


Measured memory_bytes: 256
def main():
    N, Y = map(int, input().split())
    for i in range(N+1):
        for j in range(N+1-i):
            tmp = 10000 * i + 5000 * j + 1000 * (N - i - j)
            if tmp == Y:
                print(i, j, N - i - j)
                exit()

    print(-1,-1,-1)



if __name__ == "__main__":
    main()

Measured memory_bytes: 9088
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
#include<cmath>
#include<utility>
typedef long long ll;
int main() {
	std::string s, t;
	std::string end;
	std::cin >> s >> t;
	for (int i = 0; i < s.length(); i++) {
		end = s.back();
		s = end + s;
		s.pop_back();
		if (s == t) {
			std::cout << "Yes" << std::endl;
			return 0;
		}
	}
	std::cout << "No" << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

typedef pair<int,int> P;
int h,w;
char M[55][55];
int d[55][55];
int dx[]={0,-1,1,0};
int dy[]={-1,0,0,1};

void bfs(){
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            d[i][j]=INF;
        }
    }
    queue<P> que;
    que.push(make_pair(0,0));
    d[0][0]=0;
    while(!(que.empty())){
        P p=que.front();
        que.pop();
        for(int i=0;i<4;i++){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            if(0<=nx&&nx<=h-1&&0<=ny&&ny<=w-1&&M[nx][ny]=='.'&&d[nx][ny]==INF){
                que.push(make_pair(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
            }
        }
    }
}

int main(){
    cin>>h>>w;
    int cnt=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>M[i][j];
            if(M[i][j]=='.')cnt++;
        }
    }
    bfs();
    int ans;
    if(d[h-1][w-1]==INF)ans=-1;
    else ans=cnt-d[h-1][w-1]-1;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;


int main(){
  int n;cin>>n;
  int l[n];
  int k = 0;
  fol(i,n){
    cin>>l[i];
    k += l[i];
  }
  sort(l,l+n);
  k -= l[n-1];
  if(l[n-1] < k){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
s=input()
make=0
kati=0
nagasa=len(s)
for i in range(nagasa):
    if s[i]=='o':
        kati+=1
    if s[i]=='x':
        make+=1

#print(kati,make)

if make<8:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 2940
def get_lcs(master, slave)
  # NOTE: result[cs_length] = end_position
  slave.each_char.reduce([-1]) do |result, new_char|
    new_result = result.dup
    rest_result = result.each_with_index.to_a
    master.each_char.with_index.find_all { |c, _| c == new_char }
      .each do |_, new_pos|
        taken = rest_result.take_while { |pos, _| new_pos > pos }
        if taken.any?
          _, use_cs_length = taken.last
          new_result[use_cs_length + 1] = new_pos
          rest_result = rest_result[taken.length..-1]
        end
      end
    new_result
  end.length - 1
end

n = gets.chomp.to_i
n.times do
  master = gets.chomp
  slave = gets.chomp
  puts get_lcs(master, slave)
end



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

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    int inzero = 0;
    rep(i, n) if (a[i] == 0) inzero = 1;
    if (inzero) {
        cout << 0 << endl;
        return;
    }

    ll ans = 1;
    rep(i,n) {
        if (log10(ans) + log10(a[i]) > 18.0) {
            cout << -1 << endl;
            return;
        }
        ans *= a[i];
    }
    if (ans > (ll)1e18) {
        cout << -1 << endl;
        return;
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 4048
n , k = map(int, input().strip().split(' '))

w = [0] * n
d = [0] * n
p = None
for i in range(n):
    w[i], d[i] = map(int, input().strip().split(' '))
    p1 = w[i] + (k - 1) * d[i]
    if p == None or p1 < p:
        p = p1


p1 = 1
p2 = p

def getk(p):
    kk = 0
    for i in range(n):
        if p <w[i]:
            kk += 0
        else:
            kk += (p - w[i]) // d[i] + 1
        if kk > k:
            return kk
    return kk

def search(pmin, pmax):
    if pmin == pmax:
        return pmin
    else:
        mid = (pmin + pmax) // 2
        findk = getk(mid)
        if (findk >= k):
            return search(pmin, mid)
        else:
            return search(mid+1, pmax)


print(search(p1, p2))


Measured memory_bytes: 11792
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

map<pair<int, int>, int> edge_index_dict;
vector<vector<int>> edges;

vector<int> backtrace;
void dfs(int v, int prev) {
    for(auto nei: edges[v]) {
        if (nei == prev) continue;
        backtrace[nei] = v;
        dfs(nei, v);
    }
}

ll powll(ll a, ll n) {
    ll ans = 1;
    REP(i, n) ans *= a;
    return ans;
}

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;

    backtrace.resize(N);
    edges.resize(N);
    REP(n, N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].pb(b);
        edges[b].pb(a);
        edge_index_dict[mp(a, b)] = n;
        edge_index_dict[mp(b, a)] = n;
    }
    
    int M;
    cin >> M;

    // 各ルールが使う辺
    vector<vector<int>> rule_to_route(M);

    REP(m, M) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        // uからvまでで辿る辺j
        vector<int> route;
        dfs(u, -1);
        int curr = v;
        while(true) {
            auto prev = backtrace[curr];
            route.pb(edge_index_dict[mp(prev, curr)]);
            if (prev == u) break;
            curr = prev;
        }
        // cerr << "m route:"; for(auto r: route) cerr << r << " "; cerr << endl;
        rule_to_route[m] = route;
    }

    // 包除原理で、条件を満たさないものを数える
    ll ans = 0;
    ll sign = 1;
    FOR(size, 1, M + 1) {
        vector<int> shff(M);
        REP(i, size) shff[i] = 1;
        sort(ALL(shff));

        ll local_num = 0;
        do {
            // size個のルールで使う辺の集合を求める
            vector<int> edge_union(N-1);
            REP(r, M) {
                // r番目のルールで使う辺
                if (shff[r]) {
                    for (auto edge_idx: rule_to_route[r]) {
                        edge_union[edge_idx] += 1;
                    }
                }
            }
            int free_edge_num = 0;
            REP(n, N-1) free_edge_num += (edge_union[n] == 0);
            local_num += powll(2, free_edge_num);
            // cerr << "free_edge:" << free_edge_num << endl;

        }while(next_permutation(ALL(shff)));
        ans += local_num * sign;
        sign *= -1;
    }

    cout << (powll(2, N - 1) - ans) << endl;
    return 0;
}


Measured memory_bytes: 384
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b, c, d = map(int, input().split())
    print(max(a * b, c * d))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940
from collections import deque
import copy
h,w,n=map(int,input().split())
field=[list(input()) for i in range(h)]
queue=deque([])
place=[[0,0] for _ in range(n)]
for i in range(h):
    for j in range(w):
        if field[i][j]=='S':
            queue.append([i,j,0])
            field[i][j]='.'
        elif field[i][j]!='X' and field[i][j]!='.':
            fact=int(field[i][j])
            field[i][j]='.'
            place[fact-1][0]=i
            place[fact-1][1]=j
#print(place)
#print(field)
ans=0
for i in range(n):
    if 1<=i:
        queue=deque([[place[i-1][0],place[i-1][1],0]])
#        print(queue)
    y=place[i][0]
    x=place[i][1]
    fi=copy.deepcopy(field)
    while True:
        hnow=queue[0][0]
        wnow=queue[0][1]
        time=queue[0][2]
        queue.popleft()
        time+=1
        if hnow+1<h:
            if hnow+1==y and wnow==x:
                break
            elif fi[hnow+1][wnow]=='.':
                fi[hnow+1][wnow]='v'
                queue.append([hnow+1,wnow,time])
        if wnow+1<w:
            if hnow==y and wnow+1==x:
                break
            elif fi[hnow][wnow+1]=='.':
                fi[hnow][wnow+1]='v'
                queue.append([hnow,wnow+1,time])
        
        if 0<=hnow-1:
            if hnow-1==y and wnow==x:
                break
            elif fi[hnow-1][wnow]=='.':
                fi[hnow-1][wnow]='v'
                queue.append([hnow-1,wnow,time])
        
        if 0<=wnow-1:
            if hnow==y and wnow-1==x:
                break
            elif fi[hnow][wnow-1]=='.':
                fi[hnow][wnow-1]='e'
                queue.append([hnow,wnow-1,time])
#        print(queue)
    ans+=time
print(ans)


Measured memory_bytes: 32680
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rusha scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define rushb scanf("%d",&t);while(t--)
#define debug(x) cout<<" L-B-W-- "<<x<<" --N-B\n"
#define pb push_back
//#define pii pair<int,int>
#define vii vector<int>
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof a)
#define all(x) (x.begin(),x.end())
#define judgef printf("%s\n",f?"Yes":"No")
#define Judgef printf("%s\n",f?"YES":"NO")
#define sz(x) ((int)(x).size())
#define sf(x) (sizeof(x))
using namespace std;
typedef long long ll;
typedef double db;
const double pai = acos(-1.0);
const double eps = 1e-8;
const int mod=998244353;
//const int mod=1e9+7;
const int inf=1e9+7;
//const ll inf=0x7f7f7f7f1234abcd;
const int maxn=2e5+10;
inline ll ksm(ll x,ll y){ ll res=1; while(y){if(y&1) res=res*x%mod;x=x*x%mod; y>>=1;} return res; }
inline ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}
ll lcm(ll a, ll b) { return a * b / __gcd(a, b); }

int t,n,m,k;

int main(){
    scanf("%d%d",&n,&m);
    if(n>m) puts("safe");
    else puts("unsafe");


















    return 0;
}


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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    int n;
    cin >> n;

    string s;
    cin >> s;

    int ans=0;
    for (int i = 0; i < n; i++) {
        set<char> v;
        for (int j = 0; j < i; j++) {
            v.insert(s[j]);
        }

        set<char> w;
        for (int j = i; j < n; j++) {
            w.insert(s[j]);
        }

        int count=0;
        for (char ch: v){
            if (w.find(ch) != w.end()) count++;
        }
        ans = max(ans, count);
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
    // insert code here...
    string word, sentence;
    cin>>word;
    transform(word.begin(), word.end(), word.begin(), ::toupper);
    int c=0;
    
    while(true){
        cin>>sentence;
        if(sentence=="END_OF_TEXT")break;
        transform(sentence.begin(), sentence.end(), sentence.begin(), ::toupper);
        if (word==sentence) {
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3160
#include<stdio.h>
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using lb=long double;
using db=double;
const ll mod=1e9+7;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define INF 1e10+7
int n;
const long double pi=2*asin(1.0);
const int maxn = 2e5+2;
ll a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        sum+=a[i];
    }
    ll temp=0;
    ll minn=INF;
    for(int i=0;i<n-1;i++)
    {
        temp+=a[i];
        minn=min(minn,llabs((sum-temp)-temp));
    }
    cout<<minn<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int ,int> P;

const int INF  = 0x3f3f3f3f;
const int MAXN = 1e5+7;
int dp[MAXN];
int a[MAXN];
int main() {
        int n;
        while(cin>>n) {
                for(int i=0;i<n;++i)
                        cin>>a[i];
                int ans = 0;
                int num = 0;
                for(int i=1;i<n;++i) {
                        if(a[i]<=a[i-1])        num++;
                        else                    num = 0;
                        ans = max(ans,num);
                }
                cout<<ans<<endl;
        }
        return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const ll MOD =(ll)(1e9 + 7);

const int MAX_N = 112345;
int C[MAX_N];

int main2() {
  int N = nextInt();
  REP(i, N) { C[nextInt()]++; }

  ll ans = 1;
  if (N % 2 == 0) {
    for (int i = 1; i < N; i += 2) {
      if (C[i] == 2) {
        ans *= 2;
        ans %= MOD;
      } else ans = 0;
    }
  } else {
    for (int i = 0; i < N; i += 2) {
      int d = (i == 0 ? 1 : 2);
      if (C[i] == d) {
        if (i > 0) ans *= 2;
        ans %= MOD;
      } else ans = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 640
#参考 #4023546 by kamina_zzz
N,W = gets.split.map &:to_i
D = [[0, 0]]
m = 0
N.times {
  w,v = gets.split.map &:to_i
  next if w+m > W
  D[0,D.size].each {|d|
    D << [d[0]+w, d[1]-v] if d[0]+w+m <= W
  }
  m = 0
  D.sort!.uniq! {|d| m>d[1] ? m=d[1] : m}
  m = D[0][0]
}
p -D[-1][1]

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define N 100005
#define in insert
#define pb push_back
#define mp make_pair
#define F first
#define pf push_front
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}

int main(){
    ll n; cin>>n;
    ll sum=0;
    for(ll i=1;i<=n;i++){
        if(i%3==0 && i%5==0){
            
        }
        else if(i%3==0){
            
        }
        else if(i%5==0){
            
        }
        else sum+=i;
    }
    cout<<sum;
    
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>//WA 1 may 2020
using namespace std;
int main()
{
    long long  k,a,b,i,x,y,flag=0;
    cin>>k>>a>>b;

    for(i=a;i<=b;i++)
    {
        if(i%k==0){
            flag=1;break;
        }
    }
 if(flag)
        cout<<"OK"<<endl;
else
        cout<<"NG"<<endl;

    return 0;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
using namespace std;
const int N=5005;
int n,A,B,a[N];
int p[N];
ll f[2][N];
int main(){
	scanf("%d%d%d",&n,&A,&B);
	For(i,1,n) scanf("%d",&a[i]),p[a[i]]=i;
	For(i,1,n) For(j,0,n){
		int co=(j==p[i]?0:(j<p[i]?B:A));
		f[i&1][j]=min(j==0?1ll<<60:f[i&1][j-1],f[(i&1)^1][j]+co);
	}
	printf("%lld\n",f[n&1][n]);
}

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

int main() {
  string s;int q;
  cin >> s >> q;
  string first;//逆向きに足していく！
  int rev=0;
  rep(i,q){
    int t;cin >> t;
    if(t==1){
      rev=1-rev;
      string m=first;
      first=s;
      s=m;
    }
    if(t==2){
      int f;cin >> f;
      char c;cin >> c;
      if(f==2)s=s+c;
      else first+=c;
    }
   // cout << first << ' ' << s << endl;
  }
  reverse(first.begin(),first.end());
  cout << first << s << endl;
}

Measured memory_bytes: 1496
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

signed main() {
  ll A, B;
  cin >> A >> B;
  ll g = gcd(A, B);
  auto f = factorize(g);
  ll ans = f.size() + 1;
  COUT(ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  char a,b,c,d;
  cin>>a>>b>>c>>d;
  if((a==b&&c==d&&b!=c)||(a==c&&b==d&&a!=b)||(a==d&&b==c&&a!=b)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 105
#define WHITE 0
#define GRAY 1
#define BLACK 2
void DFS(void);
void DFSVisit(int);
 
int G[MAX][MAX];
int d[MAX];
int f[MAX];
int color[MAX];
int n;
int t;
 

void DFSVisit(int u){
 
    int v;
 
    color[u] = GRAY;
    d[u] = ++t;
    for(v = 1; v <= n; v++){
        if(G[u][v] == 1 && color[v] == WHITE)
            DFSVisit(v);
    }
    color[u] = BLACK;
    f[u] = ++t;
}
void DFS(void){
 
    int u;
 
    for(u = 1; u <= n; u++){
        color[u] = WHITE;
    }
    t = 0;
    for(u = 1; u <= n; u++){
        if(color[u] == WHITE)
            DFSVisit(u);
    }
}
 
int main(){
 
    int i,j,u,k,ne;
 
    scanf("%d",&n);
    for(i = 1; i <= n; i++){
        for(j = 1; j <= n; j++){
            G[i][j] = 0;
        }
    }
    for(i = 1; i <= n;i++){
        scanf("%d",&u);
scanf("%d",&k);
        for(j = 1; j <= k; j++){
            scanf("%d",&ne);
            G[i][ne] = 1;
        }
    }
    DFS();
    for(i = 1; i <= n; i++){
        printf("%d %d %d\n",i,d[i],f[i]);
    }
 
    return 0;
}
 

Measured memory_bytes: 644
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,C = LI()
    a = [LI() for _ in range(n)]
    u = [_[0] for _ in a]
    x = [_[1] for _ in a]
    b = [0] * n
    c = [0] * n
    d = [0] * n
    e = [0] * n
    b[0] = x[0]
    c[-1] = x[-1]
    for i in range(1, n):
        b[i] = b[i-1] + x[i]
    for i in range(n-2, -1, -1):
        c[i] = c[i+1] + x[i]
    d[0] = x[0] - u[0]
    e[-1] = x[-1] - (C-u[-1])
    for i in range(1, n):
        d[i] = max(b[i]-u[i], d[i-1])
    for i in range(n-2, -1, -1):
        e[i] = max(c[i]-(C-u[i]), e[i+1])

    r = max(d[-1], e[0], 0)
    for i in range(n):
        if i < n-1 and r < b[i] - u[i] * 2 + e[i+1]:
            r = b[i] - u[i] * 2 + e[i+1]
        if i > 0 and r < c[i] - (C-u[i]) * 2 + d[i-1]:
            r = c[i] - (C-u[i]) * 2 + d[i-1]


    return r



print(main())



Measured memory_bytes: 42840
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner date = new Scanner(System.in);

		int num;
		
		while (date.hasNextInt()) {
			int cnt = 0;
			num = date.nextInt();
			for (int a = 0; a < 10; a++) {
				for (int b = 0; b < 10; b++) {
					for (int c = 0; c < 10; c++) {
						for (int d = 0; d < 10; d++) {
							int sum = a + b + c + d;
							if (sum == num) {
								cnt++;
							}
						}
					}
				}
			}
			System.out.println(cnt);
		}
		
	
	}

}

Measured memory_bytes: 18852
#include <stdio.h>

int main(void){

    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);

    do {
        a-=d;
        c-=b;
    } while(a>0 && c>0);

    if(c>0){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 1648
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long llong;
typedef pair<llong, llong> pii;

int n;
llong C;
llong X[100001];
int V[100001];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> C;
    for (int i = 1; i <= n; ++i) cin >> X[i] >> V[i];
    priority_queue<pii> pq1, pq2;
    pq1.emplace(0, n + 1);
    pq2.emplace(0, n + 1);
    llong sum = 0;
    for (int i = n; i; --i) {
        sum += V[i];
        pq1.emplace(sum - (C - X[i]), i);
        pq2.emplace(sum - (C - X[i] << 1), i);
    }
    sum = 0;
    llong mx1 = 0, mx2 = 0;
    llong ans = 0;
    for (int i = 0; i <= n; ++i) {
        sum += V[i];
        mx1 = max(mx1, sum - X[i]);
        mx2 = max(mx2, sum - (X[i] << 1));
        while (pq1.top().second <= i) pq1.pop();
        while (pq2.top().second <= i) pq2.pop();
        ans = max(ans, max(pq1.top().first + mx2, pq2.top().first + mx1));
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;

int main() {
    long long X, Y;
    cin >> X >> Y;

    long long ans = 0;
    while (X <= Y) {
        ans++;
        X *= 2;
    }
    cout << ans << endl;
}


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

#ifdef _DEBUG
#define debug(x) cout << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#define INFILE freopen("input.txt", "r", stdin)
#else
#define debug(x)
#define INFILE
#endif

#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL9_MOD = 1000000009LL;
static constexpr ll LL7_MOD = 1000000007LL;
static constexpr ll INF = 1LL << 60;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

ll dp[3010][3010];

int main(int argc, char* argv[]) {
  INFILE;

  ll n;
  cin >> n;

  vector<ll> seq(n);
  scan(seq);
  int sign = n % 2 ? 1 : -1;

  REP(i, 0, n) { dp[i][i + 1] = seq[i] * sign; }

  REP(k, 2, n + 1) {
    sign *= -1;
    REP(i, 0, n + 1 - k) {
      int start = i, end = i + k;
      auto change = sign > 0 ? chmax<ll> : chmin<ll>;

      ll result = sign * seq[start] + dp[start + 1][end];
      change(result, sign * seq[end - 1] + dp[start][end - 1]);
      dp[start][end] = result;
    }
  }

  cout << dp[0][n] << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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;
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


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

int main()
{
	int n;
	cin>>n;
	int a[1000];
	for(int i=0;i<n;i++){
        cin>>a[i];
	}
	sort(a,a+n);
	int ans=a[n-1]-a[0];
	cout<<ans;
}


Measured memory_bytes: 256
def main():
    n=int(input())
    a=[0]*(n-1)
    b=[0]*(n-1)
    for i in range(n-1):
        a[i],b[i] = map(int,input().split())
    import collections
    k=collections.Counter(a+b).most_common()[0][1]
    color_list=list(range(k))
    
    tree=[[] for _ in range(n)]
    for i in range(n-1):
        tree[a[i]-1].append(b[i])
        
    q = collections.deque([(0,1,0)])#親、子、色
    ans=dict()
    while q:
        parent,togo,old_color = q.popleft()
    #    print(parent,togo,old_color)
        col=1
        for togotogo in tree[togo-1]:
    #        print(togotogo)
            if togotogo == parent:
                continue
            if col == old_color:
                col+=1
            q.append((togo,togotogo,col))
            ans["_".join(map(str,(togo,togotogo)))]=col
            col+=1
        
    print(k)
    for i in range(n-1):
        s=str(a[i])+"_"+str(b[i])
        print(ans[s])
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 110164
#include<stdio.h>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
double f(double x){
	double w=1.0/x;
	return w;
}
int main(){
	int n;
	cin >>n;
	double a[105];
	double sum1=0.0;
	for(int i=0;i<n;i++){
		cin >>a[i];
		sum1+=f(a[i]);
	}
	cout<<1.0/sum1;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<sstream>
#include<cmath>
#include<cstring>
#include <algorithm>
 using namespace std;
 struct fan
{
	int a;
	int b;
};
bool compare(fan zuo, fan you)
{
	return zuo.b<=you.b;
}

int main()
{
	fan range[100001];
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		int x, l;
		cin >> x >> l;
		range[i].a=x-l;
		range[i].b=x+l;
	}
	sort(range+1, range+n+1, compare);
	int count=1;
	int tem=range[1].b;
	for(int i=2;i<=n;i++)
	{
		if(range[i].a>=tem)
		{
			count++;
			tem=range[i].b;
		}
	}
	cout << count;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll a, b;
  cin >> a >> b;
  auto f = [&](ll x) {
    if (x % 4 == 3) {
      return 0LL;
    }
    if (x % 4 == 1) {
      return 1LL;
    }
    if (x % 4 == 0) {
      return (ll)x;
    }
    return (ll)(x + 1);
  };
  ll ans = f(b) ^ f(a - 1);
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        String line = null;
        try {
            line = br.readLine();
            line = line.trim();
 
            String[] words = line.split(" ");
            String longest = "", most = null;
 
            int[] count = new int[words.length];
            int max = -1;
 
            for (int i = 0; i < words.length; i++) {
                if (longest.length() < words[i].length())
                    longest = words[i];
                for (int j = i + 1; j < words.length; j++) {
                    if (words[i].equals(words[j])) {
                        count[i]++;
                    }
                }
                if (count[i] > max) {
                    most = words[i];
                    max = count[i];
                }
            }
            System.out.println(most + " " + longest);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
 
}

Measured memory_bytes: 23952
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int [] s = new int[n];
        long d = 0;
        for(int i = 0;i < n;i ++) {
            s[i] = in.nextInt();
            s[i] -= i + 1;
        }
        Arrays.sort(s);
        for(int i = 0;i < n;i ++) {
            d += Math.abs(s[i] - s[n / 2]);
        }
        System.out.println(d);
    }
}

Measured memory_bytes: 64544
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr ll mod = 1000000007;
ll dp[101][4][4][4];

bool ok(int j, int k, int l, int m) {
    if (j == 0 && k == 1 && l == 2) return false;
    if (j == 1 && k == 0 && l == 2) return false;
    if (j == 0 && k == 2 && l == 1) return false;
    if (j == 0 && l == 1 && m == 2) return false;
    if (j == 0 && k == 1 && m == 2) return false;
    return true;
}

int main() {
    ll n;
    cin >> n;
    for (int i = 0; i < 4; i++)
        for (int j = 0; j < 4; j++)
            dp[2][i][j][0] = 1;
    for (int i = 3; i <= n; i++) {
        for (int j = 0; j < 4; j++) {
            for (int k = 0; k < 4; k++) {
                for (int l = 0; l < 4; l++) {
                    for (int m = 0; m < 4; m++) {
                        if (ok(j, k, l, m)) dp[i][j][k][l] = (dp[i][j][k][l] + dp[i - 1][k][l][m]) % mod;
                    }
                }
            }
        }
    }
    ll s = 0;
    for (int i = 0; i < 4; i++)for (int j = 0; j < 4; j++)for (int k = 0; k < 4; k++) s = (s + dp[n][i][j][k]) % mod;
    cout << s << endl;
}

Measured memory_bytes: 256
n=int(input())
U=list()
for i in range(n):
	i=input()
	U.append(i)
m=a=r=c=h=0
for x in U:
	if x[0]=='M':
		m+=1
	if x[0]=='A':
		a+=1
	if x[0]=='R':
		r+=1
	if x[0]=='C':
		c+=1
	if x[0]=='H':
		h+=1
sig=(m+a+r)*c*h+m*a*(r+c+h)+(m+a)*r*(c+h)
print(sig)


Measured memory_bytes: 9752
n,m=map(int,input().split())
p=[i for i in range(n+1)]
def root(n):
  pathroot=[]
  while p[n]!=n:
    pathroot.append(n)
    n=p[n]
  for node in pathroot:
    p[node]=n
  return n
def same(n,m):
  return root(p[n])==root(p[m])
def union(n,m):
  p[root(n)]=root(m)
for i in range(m):
  a,x,y=map(int,input().split())
  if a==1:
    if same(x,y):
      print(1)
    else:
      print(0)
  else:
    union(x,y)


Measured memory_bytes: 5984
#include <iostream>

using namespace std;

int main(void)
{
    int N, H[100000], i, num, a, b, count=0, st_count[100000], j=0, max=0;

    cin >> N;

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

    for(i=1; i<N; i++){
	b = H[i];

	if(a >= b){
	    count++;
	}

	else{
	    st_count[j] = count;

	    j++;

	    count = 0;
	}

	a = H[i];
    }

    st_count[j] = count;

    for(i=0; i<=j; i++){
	if(max < st_count[i]){
	    max = st_count[i];
	}
    }

    cout << max << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll k;
	vector<ll> v(50);

	cin >> k;

	REP(i, 50) {
		v[i] = i;
	}

	ll x = k / 50;
	ll y = k - x * 50;

	REP(i, 50) {
		v[i] += x;
	}

	REP(i, y) {
		v[i] += 50;
		REP(j, 50) {
			if (i != j) {
				v[j]--;
			}
		}
	}

	cout << 50 << endl;
	cout << v << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt(), x = scanner.nextInt();
			if (n == 0 && x == 0) break;
			int cnt = 0;
			for (int i = 1; i <= n - 1; ++i) {
				for (int j = i + 1; j <= n; ++j) {
					int k = x - (i + j);
					if (i <= j && j <= k && 1 <= k && k <= n && k != i && k != j) ++cnt;
				}
			}
			System.out.printf("%d\n", cnt);
		}
	}
}



Measured memory_bytes: 26464
#include <stdio.h>
int main(void){
    int n ;
    scanf("%d" , &n);
    int a[n];
    for(int i = 0 ; i < n ; i++){
        scanf("%d" , &a[i]);
    }
    
    for(int j = n - 1 ; j >= 1 ; j--){
        printf("%d" , a[j]);
        printf(" ");
    }
    printf("%d" , a[0]);
    printf("\n");
    return 0;
    
}


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

int even_func(int a) {
    return a / 2;
}

int odd_func(int a) {
    return 3 * a + 1;
}

int main(void){
    
    int res=0, i=0;
    vector<int> v(1);
    cin >> v[0];
    
    while(1) {
        // cout << v[i] << endl;
        
        if (v[i] % 2 == 0) v.push_back(even_func(v[i]));
        else v.push_back(odd_func(v[i]));
        
        for (int j = 0; j < v.size()-1; j++) {
            if (v[i+1] == v[j]) {
                res = i + 2;
            }
        }
        if (res > 0) break;
        i++;
    }
  
    cout << res << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
struct edge{int from, to;};

int main(){
    int n,m;
    cin>>n>>m;
    int a[m],b[m];
    rep(i,m) cin>>a[i]>>b[i];
    int count[n];
    rep(i,n) count[i]=0;

    rep(i,m){
        count[a[i]-1]+=1;
        count[b[i]-1]+=1;
    }

    rep(i,n){
        cout<<count[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 384
import numpy as np

n,k,q=map(int,input().split())
a=np.ones(n)*k - q
for i in range(q):
	b=int(input())
	a[b-1]+=1
b=a>0

for j in range(n):
	if b[j]:
		print('Yes')
	else:
		print('No')

Measured memory_bytes: 15276
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false); 
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    
    public static int[] generatePrimes(int n) {
		boolean[] prime = new boolean[n + 1];
		Arrays.fill(prime, 2, n + 1, true);
		for (int i = 2; i * i <= n; i++)
			if (prime[i])
				for (int j = i * i; j <= n; j += i)
					prime[j] = false;
		int[] primes = new int[n + 1];
		int cnt = 0;
		for (int i = 0; i < prime.length; i++)
			if (prime[i])
				primes[cnt++] = i;
		return Arrays.copyOf(primes, cnt);
	}
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}	
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}		    
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}	    	  	
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}		
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}	
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}	    	
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}	    	
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}				
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        long n = in.nextLong();
        long mn=0l;
        for(long i=1L;i*i<=n;i++)
        {
            if(n%i==0) mn = i;
        }
        long mx = n/mn;
        out.println(mn+mx-2);
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector <int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int Alice = 0;
  int Bob = 0;
  for (int i = N-1; i >= 0; i-=2) {
    Alice += a[i];
  }
  for (int i = N-2; i >= 0; i-=2) {
    Bob += a[i];
  }
  cout << Alice-Bob << endl;
  return 0;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int po = Math.min(a + b, c);
        po = Math.min(po + 1, c);
        System.out.println(po + b);
    }
}


Measured memory_bytes: 21972
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

const int MOD = 1000000007;

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

    ll N, K;
    cin >> N >> K;
    vector<vector<ll>> g(N, vector<ll>());
    Rep (i, N-1) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    ll ans = K;
    stack<ll> q;
    vector<bool> visited(N, false);
    q.push(0);
    visited[0] = true;
    while (!q.empty()) {
        ll now = q.top();
        q.pop();
        ll color = K-2;
        if (now == 0) color = K-1;
        for (ll v : g[now]) {
            if (visited[v]) continue;
            ans *= color;
            ans %= MOD;
            q.push(v);
            visited[v] = true;
            color--;
        }
    }

    cout << ans << "\n";
}

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

signed main () {
    int n;
    cin >> n;
    vector < int > a(n), b(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i] >> b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if (n & 1)
        cout << b[n / 2] - a[n / 2] + 1 << '\n';
    else
        cout << b[n / 2] + b[n / 2 - 1] - a[n / 2] - a[n / 2 - 1] + 1 << '\n';
}


Measured memory_bytes: 4776
#include<bits/stdc++.h>
    using namespace std;
     
    #define za ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define mod %1000000007
    #define moz 1000000007
    #define nl "\n"
    #define S second
    #define F first
    #define PB push_back
    #define MP make_pair
    #define V vector
    //#define P pair
    #define LEN length()
    #define SZ size()
    #define loop(i,a,b) for(int i=(a);i<=(b);i++)
    typedef long long ll;
    typedef complex<ll> P;
    #define X real()
    #define Y imag()
     
     
    int main()
    {
        za ;
        int x;
        int arr[100009]={0};
        int n;
        cin >> n;
        loop(i,0,n-1)
        {
            cin >> x;
            arr[x]++;
        }
        int maxi=0;
        loop(i,0,100000-2)
        {
            maxi=max(maxi,(arr[i]+arr[i+1]+arr[i+2]));
        }
        cout << maxi << nl;
    }

Measured memory_bytes: 640