akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    cin>>a>>b;

    if((a==3 && b==2) || (a==2 && b==3))
        cout<<"1";
    else if((a==3 && b==1) || (a==1 && b==3))
        cout<<"2";
    else if((a==1 && b==2) || (a==2 && b==1))
        cout<<"3";
}


Measured memory_bytes: 256
from collections import Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        while n % f == 0:
            a.append(f)
            n //= f
        f += 2
    if n != 1:
        a.append(n)
    return a

x = int(input())
y = Counter(prime_factorize(x))

num = 0
for v in y.values():
    now_v = v
    i = 1
    while True:
        if now_v < i:
            break
        now_v -= i
        num += 1
        i += 1

print(num)

Measured memory_bytes: 9468
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
int v[101010];
int cnt[2][101010];

int main(){
	cin >> n;
	REP(i, n){
		cin >> v[i];
	}
	REP(i, n){
		cnt[i%2][v[i]]++;
	}
	vector<pair<int, int>>v[2];
	REP(i, 2)REP(j, 101010){
		v[i].emplace_back(make_pair(cnt[i][j], j));
	}
	sort(ALL(v[0]));
	reverse(ALL(v[0]));
	sort(ALL(v[1]));
	reverse(ALL(v[1]));
	int ans = HINF<int>();
	if(v[0][0].second != v[1][0].second){
		ans = min(ans, n - v[0][0].first - v[1][0].first);
	}else{
		ans = min(n - v[0][0].first - v[1][1].first, n - v[0][1].first - v[1][0].first);
	}
	cout << ans << endl;
}

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

char map[8][8];

void dfs(int x, int y)
{
    map[x][y] = '0';
    
    for(int i = 1; i <= 3; ++i){
        if(x + i < 8 && map[x + i][y] == '1') dfs(x + i, y);
        if(0 <= x - i && map[x - i][y] == '1') dfs(x - i, y);
        if(y + i < 8 && map[x][y + i] == '1') dfs(x, y + i);
        if(0 <= y - i && map[x][y - i] == '1') dfs(x, y - i);
    }
}

int main()
{
    int n, x, y;
    cin >> n;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < 8; ++j){
            for(int k = 0; k < 8; ++k){
                cin >> map[k][j];
            }
        }
        cin >> x >> y;
        x--; y--;
        
        dfs(x, y);
        cout << "Data " << i + 1 << ":" << endl;
        for(int j = 0; j < 8; ++j){
            for(int k = 0; k < 8; ++k){
                cout << map[k][j];
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Mx 2000001
#define inf 1e15
const L MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a1,a2,a3,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,
q,q1,q2,q3,q4,r,s,t,u,v,x,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id1,id2,id3,id4,lim;

L A[Mx];

bool isValid(L X){
  c=k;
  for(L i=0;i<n;i++){
    d=(A[i]/X);
    if(A[i]%X)d++;
    d--;
    if(c<d)return false;
    c=c-d;
  }
  return true;
}
void solve(){
  l=1;r=1e9;
  L mid;
  while(l<=r){
    mid=(l+r)/2;
    if(isValid(mid)){
      c1=mid;
      r=mid-1;
    }else{
      l=mid+1;
    }
  }
  printf("%lld\n",c1);
}
int main()
{
    scanf("%lld%lld",&n,&k);
    for(L i=0;i<n;i++){
      scanf("%lld",&A[i]);
    }
    solve();
    return 0;
}
/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 5256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const ll INF=2e15;
const double PI=acos(-1);


vector<pair<ll,int>> vectorCnt(vector<ll> a) {
    sort(a.begin(),a.end());
    int n=a.size();
    vector<pair<ll,int>> b;
    int cnt=1;
    rep(i,n-1) {
            if (a[i+1]!=a[i]) {
                b.push_back(make_pair(a[i],cnt));
                cnt=1;
            } else {
                ++cnt;
            }
    }
    b.push_back(make_pair(a[n-1],cnt));
    return b;
}


int main() {
    ios_base::sync_with_stdio(false); 

    ll n,m;
    cin >> n >> m;
    vector<ll> a(n+1);
    ll ans=0;
    rep(i,n) cin >> a[i+1];
    rep(i,n) {
        a[i+1]+=a[i];
        a[i+1]=a[i+1]%m;
    }
    vector<pair<ll,int>> b=vectorCnt(a);
    rep(i,b.size()) {
        ll cnt=b[i].second;
        ans+=cnt*(cnt-1)/2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5892
#include<bits/stdc++.h>
using namespace std;
vector<int> com[100001];vector<int> cost[100001];bool bo[100001];int iti[100001];
void dfs(int now){
  bo[now]=true;
  for(int i=0;i<com[now].size();i++){
    if(bo[com[now][i]]){
      if(iti[com[now][i]]!=iti[now]+cost[now][i]){
        cout<<"No"<<endl;
        exit(0);
      }
    }
    else{
      iti[com[now][i]]=iti[now]+cost[now][i];
      dfs(com[now][i]);
    }
  }
}
  
  
int main(){
  int n,m;cin>>n>>m;
  int l[m],r[m],d[m];
  for(int i=0;i<m;i++){
    cin>>l[i]>>r[i]>>d[i];
    com[l[i]].push_back(r[i]);
    com[r[i]].push_back(l[i]);
    cost[l[i]].push_back(d[i]);
    cost[r[i]].push_back(-d[i]);
  }
  for(int i=0;i<n;i++){
    if(bo[i])continue;
    iti[i]=0;
    dfs(i);
  }
  cout<<"Yes"<<endl;
}

  

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

int main() {
    int N,M;
    long totalSec=0;
    cin >> N;
    long T[N];
    for(int i=0;  i<N; i++)
    {
        cin >> T[i];
        totalSec += T[i];
    }

    cin >> M;
    int P[M];
    long X[M];
    for(int i=0; i<M; i++)
    {
        cin >> P[i] >> X[i];
    }

    for(int i=0; i<M; i++)
    {
        cout << totalSec - T[P[i]-1] + X[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define trace(...)
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr(a,b,c) for(int a=b; a<c; a++)
#define pb push_back
const int mod=1e9+7;
int power(int x, unsigned int y, int p)
{
    int res = 1;

    x = x % p;

    while (y > 0)
    {

        if (y & 1)
            res = (res*x) % p;

        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
const int INF=1e18;
signed main()
{
    fastio;
    int n,k;
    cin>>n>>k;
    int h[n];
    fr(i,0,n)
    {
        cin>>h[i];

    }
    int dp[n+1];
    fr(i,0,n)
    {
        dp[i]=INF;
        //cout<<dp[i]<<" ";
    }

    dp[0]=0;

    fr(i,0,n)
    {
       fr(j,i+1,i+k+1)
       {
           if(j<n)
           {
               dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
           }
       }
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lli long long int
#define f(i,a,b) for(i=a;i<b;i++)
#define ff first
#define sc second
#define pb push_back
#define full(v) v.begin(),v.end()
#define ms(a) memset(a,0,sizeof(a))
#define mod 1000000007
#define mod2 998244353
#define msb(b) memset(b,true,sizeof(b))
#define msf(b) memset(b,false,sizeof(b))
#define MAXN 100005
// bool prime[1000000]; // 10**6
// lli pri[100000],x=0;
/*void sieve()
{
  msb(prime);
  prime[0]=prime[1]=false;
  for(int p=2;p*p<=1000000;p++)
  {
    if(prime[p])
    {
      for(int i=p*2;i<=1000000;i+=p)
        prime[i]=false;
      // a[x++]=p;
    }
  }
} */

int main()
{
    fio;
    int t,n,i,k;
    cin >> k;
    string s;
    cin >> s;
    n = s.length();
    if(n <= k)
        cout << s << endl;
    else
    {
        f(i,0,k)
            cout << s[i];
        cout<<"..."<<endl;
    }
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;
template<class T> T gcd(T a,T b) {return b?gcd(b,a%b):a;}

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


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

    vll v=divisor(m);
    sort(all(v));
    ll ans=0;
    each(it,v)
    {
        if(n*it>m)break;
        ans=max(ans,it);
    }
    //each(it,v)cout<<it<<endl;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let N = scan.word::<usize>();
    let K = scan.word::<usize>();
    let mut p = scan.list::<usize>(N);

    p.sort();
    let total = p[..K.min(N)].iter().sum::<usize>();

    println!("{}", total);
}


Measured memory_bytes: 2104
import math
k = int(input())
cnt = 0
for a in range(1, k+1):
    for b in range(a+1, k+1):
        for c in range(b+1, k+1):
            cnt += math.gcd(math.gcd(a, b), c) * 6

for a in range(1, k+1):
    for b in range(a+1, k+1):
        cnt += math.gcd(a, b) * 6

for i in range(1, k+1):
    cnt += i
print(cnt)


Measured memory_bytes: 9200
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define vi vector<int>
#define LLMAX 4000000000000000000LL
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
struct edge
{
	int t, f, w;
	bool operator < (const edge& e) const
	{
		return w > e.w;
	}
	edge(int from, int to, int weight)
	{
		t = to;
		f = from;
		w = weight;
	}
};
#define ii pair<int,int>
#define MOD 1000000007
const double EPS = (1e-5);
long long binpow(long long a, long long b){long long res = 1;while (b > 0){if (b & 1)res = res * a;a = a * a;b >>= 1;}return res;}
int findXOR(int n){switch (n % 4){case 0:return n;case 1:return 1;case 2:return n + 1;case 3:return 0;}}
int rangeXOR(int l, int r){return (findXOR(l - 1) ^ findXOR(r));}
int getbit(int mask, int bit){return (mask & (1 << bit));}void setbit(int& mask, int bit, int val){if (val)mask |= (1 << bit);else mask &= ~(1 << bit);}
//ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
//ll lcm(ll a, ll b){return a * (b / gcd(a, b));}
const int N = 1e5+10;
const int M = 1e6+3;
const ll INF = 1e9;
int h[N];
int dp[N];
void solve()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> h[i];
	for (int i = 0; i < n; ++i)
		dp[i] = INF;
	dp[0] = 0;
	for (int i = 1; i < n; ++i)
	{
		dp[i] = min(abs(h[i] - h[i - 1]) + dp[i - 1], dp[i]);
		if (i - 2 >= 0)
			dp[i] = min(abs(h[i] - h[i - 2]) + dp[i - 2],dp[i]);
	}
	cout << dp[n - 1] << '\n';
}
int main(void)
{
	//freopen("commandos.in", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int tc = 1;
	//cin >> tc;
	//scanf("%d", &tc);
	while (tc--)
	{
		solve();
	}
}

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

typedef long long ll;

const ll lim=1e18;

ll a,b,c,k;

int main()
{
	scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
	if(abs(a-b)>lim)
		puts("Unfair");
	if(k&1)
		printf("%lld",b-a);
	else
		printf("%lld",a-b);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k;
long long ans;
int main() {
	cin>>n>>k;
	for (int b=k+1;b<=n;++b) {
		ans+=(b-k)*(n/b+1)-min(b-k,b-n%b-1)-!k;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  int ans=a+b-n;
  cout<<min(a,b)<<' ';
  if(ans<0)cout<<0<<endl;
  else cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
#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>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int n;
void solve(){
   vector<ll>a,l(n+2),r(n+2);
    a.push_back(0);
    rep(i,n){
        ll ai;
        cin>>ai;
        a.push_back(ai);
    }
    a.push_back(0);
    l[0]=0,r[n+1]=0;
    for(int i=1;i<=n+1;i++){
        l[i]=l[i-1]+abs(a[i]-a[i-1]);
    }
    for(int i=n;i>=0;i--){
        r[i]=r[i+1]+abs(a[i]-a[i+1]);
    }
    for(int i=1;i<=n;i++)
    {
        ll ans=l[i]+r[i];
        ans=ans-abs(a[i]-a[i-1]);
        ans=ans-abs(a[i]-a[i+1]);
        ans=ans+abs(a[i-1]-a[i+1]);
        cout<<ans<<endl;
    }

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

    cin>>n;
    solve();
    return 0;
}

Measured memory_bytes: 3700
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    n,q=map(int,input().split())
    P=[[] for _ in range(n)]
    for i in range(n-1):
        a,b=map(int,input().split())
        P[a-1].append(b-1)
        P[b-1].append(a-1)
    X=[0]*n
    for i in range(q):
        p,x=map(int,input().split())
        X[p-1]+=x
    deq=deque([0])
    visited=[False]*n 
    while deq:
        node=deq.popleft()
        if not(visited[node]):
            visited[node]=True
            for p in P[node]:
                if not(visited[p]):
                    X[p]+=X[node]
                    deq.append(p)
    print(*X)

if __name__=='__main__':
    main()

Measured memory_bytes: 94356
#include <bits/stdc++.h>
using  namespace  std;
using ll=long long;
const int mod =1e9+7;
int main(){
  int n;
  cin>>n;
  vector<ll> a(n),sum(n+1,0);
  for(int i=0;i<n;i++)cin>>a.at(i);
  for(int i=0;i<n;i++)sum.at(i+1)=a.at(i)+sum.at(i);
  sort(sum.begin(),sum.end());
  ll count=1,ans=0;
  for(int i=1;i<n+1;i++) {
  if(sum.at(i-1)==sum.at(i)){
    ans+=count;
  count++;
  }
 else count=1;
     }
   cout<<ans<<endl;
   }
  


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <set>
#include <cstdio>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

typedef pair<int,int> P1;
typedef pair<int,P1> P2;
const ll inf=100000000000000;
struct edge{
	int to,cost;
};
int main() {
	string s;

	cin>>s;
	int d[26]={};
	int ma[26]={};
	int ls=s.length();
	rep(i,ls){
		int k=s[i]-'a';
		ma[k]=max(ma[k],d[k]);
		d[k]=-1;
		rep(j,26)d[j]++;
	}

	int t=100000000;
	rep(i,26){
		t=min(t,max(ma[i],d[i]));
	}
	cout<<t<<endl;

	return 0;
}


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

int main() {
    cin.tie(0); 
    ios::sync_with_stdio(false);
    string str;
    cin >> str;
    int n = (int)str.length();
    long long int res = stoll(str);
    for (int bit = 0; bit < (1 << (n - 1)); bit++) {
        deque<int> split;
        for (int i = 0; i < (n - 1); i++) {
            if (bit & (1 << i)) {
                split.push_back(i);
            }
        }
        int prev = 0;
        while (!split.empty()) {
            res += stoll(str.substr(prev, split.front() + 1 - prev));
            prev = split.front() + 1;
            split.pop_front();
            if (split.empty()) {
                res += stoll(str.substr(prev));
                break;
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {
	
	//?????????????????????????????????????????????????????§?????¢???????????????
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int smallerNum = sc.nextInt();
		int maxDef = Integer.MIN_VALUE;
		
		for (int i = 0; i < num - 1; i++) {
			int j = sc.nextInt();
			maxDef = Math.max(maxDef, j - smallerNum);
			smallerNum = Math.min(smallerNum, j);
		}
		System.out.println(maxDef);
	}	
}

Measured memory_bytes: 99816
inpl = lambda: list(map(int,input().split()))
N = int(input())
S = input()
character_pos = [ set() for _ in range(26) ]
ans = 0
continue_list = dict()
for i in range(N):
    s = S[i]
    new_continue_list = dict()
    cpos = character_pos[ord(s)-ord('a')]
    for p in cpos:
        new_continue_list[p] = 1
    cpos.add(i)
    for k, v in continue_list.items():
        if s == S[k+1]  and v + 1 <= i - k - 1:
            new_continue_list[k+1] = v+1
        elif v > ans:
            ans = v
    continue_list = new_continue_list

if len(continue_list.values()) > 0:
    ans = max(ans, max(continue_list.values()))
print(ans)

Measured memory_bytes: 90588
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL gcd(LL a, LL b) {
	return b != 0 ? gcd(b, a % b) : a;
}

LL lcm(LL a, LL b) {
	return a * b / gcd(a, b);
}



LL solve(LL n, LL c, LL d) {
	LL val = 0;
	val+=n / c + n / d;
	val -= n/lcm(c, d);

	return n-val;
}

int main() {
	LL l, r, c, d; cin >> l >> r >> c >> d;

	LL ans = solve(r, c, d) - solve(l-1, c, d);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
    #include<ext/pb_ds/assoc_container.hpp> 
    #include<ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    using namespace std;
    template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
    #define int long long  
    typedef long double ld;
    #define pb push_back
    #define f(i,a,b) for(int i=a;i<b;i++)
    #define fd(i,a,b) for(int i=a-1;i>=b;i--)
    #define pf push_front
    #define fi first
    #define se second
    #define INF 1e18
    const int mod=1e9+7;
    int cnt=0; 
    int dp[100+5][100000+5]={};
    int gcd(int a, int b) 
    { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
    } 
    void swap(int a,int b)
    {
      int temp=a;
      a=b;
      b=temp;
    } 
    signed main() {
 
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
  /*  #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("INPUT.txt", "r", stdin);
    // for writing output to output.txt
    freopen("OUTPUT.txt", "w", stdout);
    #endif
    */
    // -------------------------------------Code starts here--------------------------------------------------------------------- 
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n,w;
        cin>>n>>w;
        pair<int ,int > p[n+1];
        f(i,1,n+1)
        {
          cin>>p[i].fi;
          cin>>p[i].se;
        }

        f(i,0,n+1)
        {
          dp[i][0]=0;
        }
        f(i,0,w+1)
        {
          dp[0][i]=0;
        }
        f(i,1,n+1)
        {
          f(j,1,w+1)
          {
            if(j-p[i].fi>=0)
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-p[i].fi]+p[i].se);
            else
              dp[i][j]=dp[i-1][j];
          }
        }
        cout<<dp[n][w]<<endl;
    }
} 

Measured memory_bytes: 80128
#include <map>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <sstream>
#include <vector>
#include <stack>
#include <utility>
#include <math.h>
using namespace std;

typedef long ll;

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

	if (B % A == 0)
	{
		cout << A + B << endl;
	}
	else
	{
		cout << B - A << endl;
	}
}

/*

*/

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = new int[n];
		int max = 0;
		int min = 10000;
		for (int i = 0; i < array.length; i++) {
			array[i] = sc.nextInt();
			if (max < array[i]) {
				max = array[i];
			}

			if (min > array[i]) {
				min = array[i];
			}
		}
		System.out.println(max - min);
		sc.close();
	}

}


Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
#include <chrono>

#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)
#define ff first
#define ss second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const ll mod = 1e9 + 7;
const double eps = DBL_EPSILON;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef LOCAL_DEBUG
	freopen("input.txt", "r", stdin);
#endif
	ll h;
	cin >> h;
	ll ans = 0, cnt = 1;
	while (h) {
		ans += cnt;
		h /= 2;
		cnt *= 2;
	}
	cout << ans;
	return 0;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)


int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> edges(n);
    double ans = n;
    for (int i = 0;i < m;++i) {
        int u,v;
        cin >> u >> v;
        edges[u-1].push_back(v-1);
    }
    for (int i = 0;i < n;++i) {
        vector<double> dp(n,0);
        for (int j = n-2;j >= 0;--j) {
            if (i-j || edges[j].size() < 2) {
                for (int& k : edges[j]) dp[j] += dp[k];
                dp[j] /= edges[j].size();
                dp[j]++;
            } else {
                double mx = 0;
                for (int& k : edges[j]) {
                    dp[j] += dp[k];
                    mx = max(mx,dp[k]);
                }
                dp[j] -= mx;
                dp[j] /= edges[j].size()-1;
                dp[j]++;
            }
        }
        ans = min(ans,dp[0]);
    }
    cout << fixed << setprecision(9) << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let xy1 = (read::<i32>(), read::<i32>());
    let xy2 = (read::<i32>(), read::<i32>());
    print!("{} {} {} {}", xy2.0 - (xy2.1 - xy1.1), xy2.1 + (xy2.0 - xy1.0), xy1.0 - (xy2.1 - xy1.1), xy1.1 + (xy2.0 - xy1.0),);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100010
int n,m,a[MAXN],ans[MAXN],res[MAXN],tmp[MAXN];
long long k;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",&a[i]);
    for(int i=1;i<n;++i)ans[i]=i;
    scanf("%d%lld",&m,&k);
    for(int i=1;i<=m;++i){
        int x;
        scanf("%d",&x);
        swap(ans[x],ans[x-1]);
    }
    for(int i=1;i<n;++i)res[i]=i;
    while(k){
        if(k&1)
            for(int i=1;i<n;++i)res[i]=ans[res[i]];
        for(int i=1;i<n;++i)tmp[i]=ans[ans[i]];
        for(int i=1;i<n;++i)ans[i]=tmp[i];
        k>>=1;
    }
    long long sum=a[1];
    for(int i=1;i<=n;++i){
        printf("%lld.0\n",sum);
        sum+=a[res[i]+1]-a[res[i]];
    }
}

Measured memory_bytes: 3072
#include <stdio.h>
int main(void) {
	int a, b;
	scanf("%d%d", &a, &b);
	if (a < b)
		for (int i = 0; i < b; i++)
			printf("%d", a);
	else
		for (int i = 0; i < a; i++)
			printf("%d", b);
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int n;
void search(vector<vector<int> > &G1, vector<vector<int> > &G2, int *d, bool *v)
{
    int mini, minv;
    while (1)
    {
        bool iscomp = true;
        minv = INFTY;
        rep(i, 0, n)
        {
            if (!v[i] && d[i] < minv)
            {
                mini = i;
                minv = d[i];
                iscomp = false;
            }
        }
        if (iscomp)
            break;
        v[mini] = true;
        rep(i, 0, G1[mini].size())
        {
            int tmp = G1[mini][i];
            if (!v[tmp])
            {
                int tmptime = minv + G2[mini][i];
                if (tmptime < d[tmp])
                    d[tmp] = tmptime;
            }
        }
    }
}
int main()
{
    cin >> n;
    vector<vector<int> > G1(n, vector<int>(0)), G2(n, vector<int>(0));
    int d[n];
    bool v[n] = {};
    rep(i, 0, n) d[i] = INFTY;
    int utmp, ktmp, vtmp, ctmp;
    rep(i, 0, n)
    {
        cin >> utmp >> ktmp;
        rep(j, 0, ktmp)
        {
            cin >> vtmp >> ctmp;
            G1[utmp].push_back(vtmp);
            G2[utmp].push_back(ctmp);
        }
    }
    d[0] = 0;
    search(G1, G2, d, v);
    rep(i, 0, n)
    {
        printf("%d %d\n", i, d[i]);
    }
}


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

int main(){
    int n;
    while(cin >> n, n){
        int c[10] = {};
        int a;
        while(n-- > 0){
            cin >> a;
            c[a]++;
        }
        for(int x : c){
            if(x){
                while(x-- > 0)  printf("*");
                printf("\n");
            }else{
                printf("-\n");
            }
        }
    }
    return 0;
}



Measured memory_bytes: 2992
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//競技プログラミングから逃げるな
//https://www.youtube.com/watch?v=z_B9iJ8r4ic

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/

__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  ll n;cin>>n;
  vector<ll> A(n);
  vector<ll> B(n);
  rep(i,n){
    cin>>A[i];
  }
  rep(i,n){
    cin>>B[i];
  }
  ll nwa = 0;
  ll nwb = 0;
  rep(i,n){
    if(B[i] > A[i]){
      if((B[i]-A[i])%2){
        nwb++;
        B[i]++;
      }
      nwa+=(B[i]-A[i])/2;
    }else{
      nwb+=(A[i]-B[i]);
    }
  }
  cout << YesNo(nwa>=nwb) << endl;
}

Measured memory_bytes: 384
#include<algorithm>
#include<iostream>
using namespace std;
int x[101],y[101];
int main()
{
    int n,m;
    int X,Y;;
    cin>>n>>m>>X>>Y;
    for(int i=1;i<=n;i++)
    {
    	cin>>x[i];
	}
	x[++n]=X;
	sort(x+1,x+n+1);
	int z=x[n]+1;
	for(int i=1;i<=m;i++)
    {
    	cin>>y[i];
	}
	sort(y+1,y+m+1);
	if(z>y[1]||z>Y)
	{
		cout<<"War";
		return 0;
	}
	cout<<"No War";
    return 0;
}

Measured memory_bytes: 256
import math
import sys


def f(n):
    if n % 2 == 0:
        return n / 2
    else:
        return 3 * n + 1


s = int(input())
list = [s]
x = s
cnt = 1
while(True):
    x = f(x)
    cnt += 1
    if x in list:
        break
    else:
        list.append(x)

print(cnt)


Measured memory_bytes: 3316
main = do
    l <- getLine
    let (a:b:[]) = map read $ words l :: [Int]
    putStrLn $ a `compare'` b

compare' :: Int -> Int -> String
compare' a b
    | ordering == LT = "a < b"
    | ordering == EQ = "a == b"
    | ordering == GT = "a > b"
    where ordering = a `compare` b

Measured memory_bytes: 3512
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	int a, b,i=0,n;
	cin >> a >> b;
	n = b;
	while (n > 0) {
		n /= 10;
		i++;
	}
	for (int j = 0; j < i; j++) {
		a *= 10;
	}
	a += b;
	double x = sqrt((double)a);
	if (x - (int)x > 0) { cout << "No"; }
	else { cout << "Yes"; }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

//=============Segment_Tree_with_Lazy_Propagation====
const int MAX_N = 1 << 18;//要変更
int n;
vector<ll> dat(2 * MAX_N - 1, INF);//要変更
vector<ll> lazy(2 * MAX_N - 1, INF);//要変更

void init(ll n_) {
  n = 1;
  while (n < n_) {
    n *= 2;
  }
}

void eval(ll k, ll l, ll r) {
  if (lazy.at(k) != INF) {
    dat.at(k) = min(dat.at(k), lazy.at(k));//要変更
    if (r - l > 1) {
      lazy.at(k * 2 + 1) = min(lazy.at(k * 2 + 1), lazy.at(k));//要変更
      lazy.at(k * 2 + 2) = min(lazy.at(k * 2 + 2), lazy.at(k));//要変更
    }
    lazy.at(k) = INF;
  }
}

void update(ll a, ll b, ll plus, ll k = 0, ll l = 0, ll r = n) {
  if (r <= a || b <= l) {
    eval(k, l, r);//子供のlazyを更新する必要がある
    return;
  }
  if (a <= l && r <= b) {
    lazy.at(k) = min(lazy.at(k), plus);//要変更
    eval(k, l, r);//子供のlazyを更新する必要がある
  }
  else {
    eval(k, l, r);//updateで使う子供のlazeとdat.at(k)の更新
    update(a, b, plus, k * 2 + 1, l, (l + r) / 2);
    update(a, b, plus, k * 2 + 2, (l + r) / 2, r);
    dat.at(k) = min(dat.at(2 * k + 1), dat.at(2 * k + 2));//要変更
  }
}

ll query(ll a, ll b, ll k = 0, ll l = 0, ll r = n) {
  if (r <= a || b <= l) {
    return INF;//要変更
  }
  eval(k, l, r);//dat.at(k)と子供のlazy更新のためreturn datとqueryに必要
  if (a <= l && r <= b) {
    return dat.at(k);
  }
  else {
    ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return min(vl, vr);//要変更
  }
}
//=================================================

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, Q;
  cin >> N >> Q;
  init(Q);
  vector<ll> S(N), T(N), X(N);
  for (ll i = 0; i < N; ++i) {
    ll s, t, x;
    cin >> s >> t >> x;
    S.at(i) = s - x;
    T.at(i) = t - x;
    X.at(i) = x;
  }
  vector<ll> D(Q);
  for (ll i = 0; i < Q; ++i) {
    cin >> D.at(i);
  }
  for (ll i = 0; i < N; ++i) {
    ll s = S.at(i), t = T.at(i);
    ll s_index = lower_bound(D.begin(), D.end(), s) - D.begin();
    ll t_index = lower_bound(D.begin(), D.end(), t) - D.begin();
    update(s_index, t_index, X.at(i));
  }
  for (ll i = 0; i < Q; ++i) {
    ll ans = query(i, i + 1);
    if (ans == INF) {
      ans = -1;
    }
    cout << ans << "\n";
  }
}


Measured memory_bytes: 17584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
int n, k, a[200005], tmp[200005];
int main(){
	scanf("%d%d", &n, &k);
	rep(i,n) scanf("%d", a+i);
	rep(o,k){
		bool al = true;
		int t = 0;
		fill(tmp,tmp+n,0);
		rep(i,n){
			tmp[max(0,i-a[i])]++;
			tmp[min(n,i+a[i]+1)]--;
		}
		rep(i,n) if((a[i] = t += tmp[i]) != n) al = false;
		if(al) break;
	}
	rep(i,n) printf("%d%c", a[i], i==n-1?'\n':' ');
}

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

using namespace std;

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

int main(){
    int n;
    scanf("%d",&n);
    vector<int> V;
    for(int i=0;i<n;i++){
        int t;
        scanf("%d",&t);
        V.push_back(t);
    }
    int x=*max_element(V.begin(),V.end());
    int s=0;
    for(int i=0;i<V.size();i++)
        s+=V[i];
    s-=x;
    if(x<s) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
  cin>>n;
  double p[n+1];
  for(int i=1;i<=n;i++){
  cin>>p[i];
  }
  double dp[n+1][n+1];
  dp[1][0]=1-p[1];
  dp[1][1]=p[1];
  for(int t=2;t<=n;t++){
  dp[t][0]=(double)dp[t-1][0]*(1-p[t]);
  }
  for(int i=2;i<=n;i++){
      for(int j=1;j<=i;j++){
        dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
    }
  }
  int x=(n+1)/2;
  double ans=0;
  for(int i=x;i<=n;i++){
      //cout<<dp[n][1]<<endl;
      ans+=(double)dp[n][i];
  }
  cout<<setprecision(10)<<ans;
  
  return 0;
}

Measured memory_bytes: 70272
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0);
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
int ans = 0;
int n, m;
bool vis[10];
vi adj[10];
void dfs(int u, int cnt){
  if(cnt == n)ans++;
  vis[u] = true;
  for(auto v : adj[u]){
    if(!vis[v])
      dfs(v, cnt + 1);
  }
  vis[u] = false;
}
int main(){
  cin >> n >> m;
  while(m--){
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(0,1);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   inf  1000000007;
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

int  I[100005];

inline void solve(){
    int n; cin>>n; 
    int  a[n+1], lis = 0 ; 
    I[0] = -inf ; 
    for (int i=1;i<=n;i++){
    	cin >> a[i] ; 
    	I[i] = inf ; 
    } 
    reverse (a+1,a+n+1);
    for (int i=1;i<=n;i++) { 
    	int  l = 0, r = lis ; 
    	while (l <= r){ 
    		int  mid = ( l + r ) >> 1 ; 
    		if (I[mid] <= a[i]) l = mid + 1 ; 
    		else r = mid - 1 ; 
    	} 
    	I[l] = a[i] ; 
    	if (l > lis) lis = l ; 
    }
    co (lis) ; 
}

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


Measured memory_bytes: 5160
#include<stdio.h>

int main (void)
{
  int n;
  scanf("%d",&n);

  int a[n],i;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  
  int j;
  for(j=n-1;j>0;j--){
    printf("%d ",a[j]);
  }
  printf("%d",a[0]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i > 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;
int sum(vector<int> vec){
  int s = 0;
  rep(i, vec.size()) s += vec.at(i);
  return s;
}

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  int ans = 0;
  int i = 0;
  vector<int> nums;
  rep(i, c){
    if (a + i <= b) nums.push_back(a + i);
    if (b - i >= a) nums.push_back(b - i);
  }
  sort(all(nums));

  //cout << ans << endl;
  cout << nums.at(0) << endl;
  rep(i, nums.size() - 1){
    if (nums.at(i + 1) != nums.at(i)) cout << nums.at(i + 1) << endl;
  }
}

Measured memory_bytes: 256
MODE = "stdio"
require 'matrix'

tmp = Array.new

class Integer
  def divisor_list2
    return [1] if self == 1
    (1..Math.sqrt(self).to_i).select do |i|
      self%i == 0
    end.map {|e| [e, self/e]}.flatten.uniq.sort
  end
end

if(defined? MODE)
  tmp = STDIN.read.split("\n")
else
  iotmp = "\
  2
  ".split("\n")
  iotmp.each{|s|
    tmp << s.strip
  }
end

n = tmp[0].to_i

puts n**3

Measured memory_bytes: 9264
// D - Wizard in Maze
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(int)(s);i<(int)(e);++i)

pair<int, int> dhw[] = { // <h, w>
        { 1, 0},
{ 0,-1},        { 0, 1},
        {-1, 0},
{ 2,-2},{ 2,-1},{ 2, 0},{ 2, 1},{ 2, 2},
{ 1,-2},{ 1,-1},        { 1, 1},{ 1, 2},
{ 0,-2},                        { 0, 2},
{-1,-2},{-1,-1},        {-1, 1},{-1, 2},
{-2,-2},{-2,-1},{-2, 0},{-2, 1},{-2, 2}
};

int main(){
	int H, W; cin>>H>>W;
	int C[2],D[2]; cin>>C[0]>>C[1]>>D[0]>>D[1];
	C[0]--, C[1]--, D[0]--, D[1]--;
	string S[H]; rp(i, 0, H) cin>>S[i];

	vector<vi> dst(H, vi(W, -1));
	deque<tuple<int, int, int>> dq; // <h, w, gid>
	dq.emplace_front (C[0], C[1], 0);
	while(dq.size()){
		int h, w, gid; tie(h, w, gid) = dq.front(); dq.pop_front();
		if(h < 0 || H <= h || w < 0 || W <= w
		|| dst[h][w] >= 0 || S[h][w] == '#') continue;
		dst[h][w] = gid;
		rp(i, 0, 4) dq.emplace_front(h + dhw[i].first, w + dhw[i].second, gid);
		rp(i, 4, 24) dq.emplace_back(h + dhw[i].first, w + dhw[i].second, gid+1);
	}

	cout<< dst[D[0]][D[1]] <<endl;
}


Measured memory_bytes: 11892
def solve():
    S, T = [_ for _ in raw_input().split()]
    A, B = [int(_) for _ in raw_input().split()]
    U = raw_input()
    if U == S:
        print A - 1, B
    elif U == T:
        print A, B - 1

if __name__ == '__main__':
    solve()


Measured memory_bytes: 27756
def main():
    N, K = map(int, input().split(' '))
    if N % K == 0:
        print(0)
    else:
        N = N % K
        while True:
            sub_N = abs(N - K)
            if N <= sub_N:
                break
            N = sub_N
        print(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
from bisect import*
e=enumerate
M=998244353
R,G,B=[],[],[]
n=int(input())
for i,c in e(input()):
  if c=='R':R+=i,
  elif c=='G':G+=i,
  else:B+=i,
l,m,r=[],[],[]
for i,t in e(zip(R,G,B)):
  a,b,c=sorted(t)
  l+=a,
  m+=b,
  r+=c,
s=1
for i,b in e(m):
  s=s*(bisect(l,b)-i)*(i-bisect(r,b)+1)*(i+1)%M
print(s)

Measured memory_bytes: 18292
#! -*- coding: utf-8-unix -*-
import sys

if __name__=='__main__':
  lines = [x.strip() for x in sys.stdin.readlines() if x != '' and x != '\n']
  for line in lines:
    cs = line.split()
    stack = []
    res = 0.0
    for c in cs:
      res = ''
      if not(c == '-' or c == '+' or c == '*' or c == '/'):
        res = float(c)
      else:
        s1, s2 = stack.pop(), stack.pop()
        if c == '-':
          res = s2 - s1
        elif c == '+':
          res = s2 + s1
        elif c == '*':
          res = s2 * s1
        elif c == '/':
          res = s2 / s1
      stack.append(res)
    assert(len(stack) == 1)
    print stack[0]

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

#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 OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n)
    {
        int a;
        cin >> a;
        mp[a]++;
    }

    int sum = 0;
    for (auto x : mp)
    {
        if (x.second >= 2)
            sum += x.second - 1;
    }
    if (sum % 2 == 0)
        OP(mp.size());
    else
        OP(mp.size() - 1);
    return 0;
}

/*int main()
{
    int n;
    cin >> n;
    int a[(int)1e5 + 1] = {};
    rep(i, n)
    {
        int c;
        cin >> c;
        a[c]++;
    }
    int e = 0, o = 0;
    rep(i, 1e5 + 1)
    {
        if (a[i] != 0)
        {
            if (a[i] % 2 == 1)
                o++;
            else
                e++;
        }
    }
    if (e % 2 == 0)
        OP(o + e);
    else
        OP(o + e - 1);

    return 0;
}*/

Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String tmpStr = br.readLine();

			if(tmpStr == null){
				break;
			}

			int[] a = new int[4];
			int[] b = new int[4];
			boolean[] inA = new boolean[10];
			Arrays.fill(inA, false);

			String[] tmpArray1 = tmpStr.split(" ");
			String[] tmpArray2 = br.readLine().split(" ");

			for(int i = 0; i < 4 ; i++){
				a[i] = Integer.parseInt(tmpArray1[i]);
				b[i] = Integer.parseInt(tmpArray2[i]);
				inA[a[i]] = true;
			}
			
			//??????????????????????????§??????
			int hit = 0;
			int blow = 0;
			for(int i = 0; i < 4; i++){
				if(a[i] == b[i]){
					hit++;
				}
				
				if(inA[b[i]]){
					blow++;
				}
			}
			blow -= hit;
			
			System.out.println(hit + " "+ blow);
		}
	}

}

Measured memory_bytes: 24288
#include <iostream>
#include <string>

using namespace std;

int main(){
    int N;
    string s,t;
    cin >> N;
    cin >> s >> t;
    int n = N;
    for(int i=0;i<N+1;i++){
        if(s==t || s.empty()){
            cout << N*2-n << endl;
            break;
        }else{
            s = s.substr(1,n-1);
            t = t.substr(0,n-1);
            n--;
        }
    }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

long long gcd(long a,long b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
long long lcm(long a,long b){
    return a/gcd(a,b)*b;
}
int main(){
    int n;
    long long t[101];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>t[i];
    }
    for(int i=0;i<n;i++){
        t[i+1]=lcm(t[i],t[i+1]);
    }
    cout<<t[n-1]<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001
#define MOD 1000000007

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<pair<ll,ll>> dp1(N, {0,0});
    vector<pair<ll,ll>> dp2(N, {0,0});
    dp1[0] = {1000 / A[0], 1000 % A[0]};
    dp2[0] = {1000, 0};
    for(int i = 1; i < N; i++){
        if(dp1[i-1].first < dp2[i-1].first / A[i]){
            dp1[i].first = dp2[i-1].first / A[i];
            dp1[i].second = dp2[i-1].first % A[i]; 
        }
        else if(dp1[i-1].first == dp2[i-1].first / A[i]){
            if(dp1[i-1].second < dp2[i-1].first % A[i]){
                dp1[i].first = dp1[i-1].first;
                dp1[i].second = dp2[i-1].first % A[i];
            }
            else dp1[i] = dp1[i-1];
        }
        else dp1[i] = dp1[i-1];
        if(dp2[i-1].first < dp1[i-1].first * A[i] + dp1[i-1].second) dp2[i].first = dp1[i-1].first * A[i] + dp1[i-1].second;
        else dp2[i] = dp2[i-1];
    }
    ll ans = 1000;
    for(int i = 0; i < N; i++){
        ans = max(ans, dp2[i].first);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3612
public class Hello {     public static void Main(){         // 1 行に複数の入力値がある場合の例     
string [] inputs = System.Console.ReadLine().Split(' ');     
int a = int.Parse(inputs[0]);  
int b = int.Parse(inputs[1]);      
int c = (a * b);     
int d = (a + b) * 2;       
System.Console.WriteLine(c + " " + d);     } } 


Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll a, b;
	cin >> a >> b;
	ll n = gcd(a, b);
	ll ans = 0;
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)
			ans++;
		while (n % i == 0)
			n /= i;
	}
	if (n > 1)
		ans++;
	ans++;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256