akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define lint long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
struct Nums{
    long long n;
    vector<long long> kaijo;
    Nums(int N){
        n=N;
        kaijo.push_back(1);
        for(long long i=1;i<=n;i++){
            kaijo.push_back((kaijo[i-1]*i)%MOD);
        }
    }
    long myPow(long x, long n, long m){
        if(n == 0)
            return 1;
        if(n % 2 == 0)
            return myPow(x * x % m, n / 2, m);
        else
            return x * myPow(x, n - 1, m) % m;
    }
    long long modinv(long long a, long long m) {
        if(a==1){
            return 1;
        }
        long long b = m, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }
    long long comb(long long N,long long K,long long rest){
        long long res=kaijo[N]*modinv(kaijo[K],rest)%rest;
        res*=modinv(kaijo[N-K],rest);
        res%=rest;
        return res;
    }
};

signed main(){
  int n;cin>>n;
  vector<int> a(n+1);
  vector<int> pos(n+1,-1);
  int left,right;
  Nums lib(n+5);
  rep(i,n+1){
      cin>>a[i];
      if(pos[a[i]]==-1){
          pos[a[i]]=i;
      }
      else{
          left=min(pos[a[i]],i);
          right=max(pos[a[i]],i);
      }
  }
  //cout<<left<<" "<<right<<endl;
  rep1(k,n+1){
      //cout<<k<<endl;
      int res=lib.comb(n+1,k,MOD);
      if(n-right+left>=k-1)res-=lib.comb(n-right+left,k-1,MOD);
      res+=MOD;
      res%=MOD;
      cout<<res<<"\n";
  }
  return 0;
}

Measured memory_bytes: 3700
function main()
    n,m=myreads(Int)

    # -----------Union-Find-----------
    par=Vector{Int}([i for i=1:n])
    siz=ones(Int,n)
    function root(x::Int)
        index=par[x]
        while par[index]!=index
            index=par[index]
        end
        return index
    end
    function unite(x::Int,y::Int)
        rx,ry=root(x),root(y)
        if rx==ry
            return 0
        elseif rx>ry
            rx,ry=ry,rx
        end
        par[ry]=rx
        siz[rx]+=siz[ry]
    end
    function same(x::Int,y::Int)
        isequal(root(x),root(y))
    end
    # --------------------------------

    for i=1:m
        a,b=myreads(Int)
        unite(a,b)
    end
    println(maximum(siz))
end

# ----------input function----------
sread()=chomp(readline())
sreads(sp=" ")=split(readline(),sp)
myread(ty)=parse(ty,sread())
myreads(ty)=parse.(ty,sreads())
main()

Measured memory_bytes: 218924
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;

 
const int MAX_N = int(1e6) + 10;
const long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 
 
inline ll mul(ll a,ll b){
 
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}
 
  
 
 
#define all(x) (x).begin(),(x).end()




//s.reserve(32768); //updated !
//s.max_load_factor(0.25);


ll a[200005];


int main(){
 
    

    int n;
    cin>>n;

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

    sort(a,a+n);

    ll ans=a[n-1];
    int c=n-2;
    for(int i=n-2;i>=0;i--){
        if(c>0){
            ans+=a[i];
            c--;
            if(c>0){
                ans+=a[i];
                c--;
            }
        }
    }

    cout<<ans<<"\n";

    



    
    
    




    

}
    

    






    
    

    
 
    
 

 
 
    
 
 


Measured memory_bytes: 5140
/*
2020-04-20
atcoder ABC
D - Lunlun Number
*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    //変数定義, 入力処理
    // vector<vector<int>> data(31, vector<int>(4)); //二次元配列
    long long K, ans;
    cin >> K;
    //処理
    queue<long long> q;
    rep(i, 9) {
        q.push(i + 1);
    }
    rep(i, K - 1) {
        long long q_front = q.front();
        q.pop();
        if (q_front % 10 != 0) {
            q.push(q_front * 10 + q_front % 10 - 1);
        }
        q.push(q_front * 10 + q_front % 10);
        if (q_front % 10 != 9) {
            q.push(q_front * 10 + q_front % 10 + 1);
        }
    }
    ans = q.front();

    //出力処理
    cout << ans << endl;
    return 0;
}


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

//#pragma GCC optimize("Ofast")

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const int NN = 1e9 + 7;
const int N = 2e6 + 7;
const int M = 26;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;
const int B = sqrt(N);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve1()
{
    string s;
    cin >> s;
    int n = (int)s.size();
    if( s[0] != '1' || s[n - 1] != '0' ){
        cout << "-1\n";
        return;
    }
    for( int i = 0; i < n - 1; i++ ){
        if( s[i] != s[n - 2 - i] ){
            cout << "-1\n";
            return;
        }
    }
    int l = 1 , r = n;
    for( int i = 0; i < n - 1; i++ ){
        if( s[i] == '1' ){
            cout << l++ << " " << l << "\n";
        }else{
            cout << l << " " << r-- << "\n";
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


Measured memory_bytes: 3792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        int H,W;
        String work[] = new String[2];
 
        while(true){
 
            try {
                work = br.readLine().split("[\\s]+");
 
                if(work[0].equals("0") && work[1].equals("0"))break;
 
                H = Integer.parseInt(work[0]);
                W = Integer.parseInt(work[1]);
 
                for(int row = 0; row < H; row++){
                    for(int col = 0; col < W; col++){
                        if((row+col)%2 == 0){
                            System.out.printf("#");
                        }else{
                            System.out.printf(".");
                        }
                    }
                    System.out.printf("\n");
                }
 
                System.out.printf("\n");
 
 
            } catch (IOException e) {
 
                e.printStackTrace();
            }
        }
    }
}


Measured memory_bytes: 61368
#include <iostream>
#include <cmath>
using namespace std;
int main() {
  int n;
  cin >> n;
  int max_two_exp = 1;
  for (int i = 1; i < n; i++) {
    int two_exp = pow(2, i);
    if (max_two_exp < two_exp && two_exp <= n) max_two_exp = two_exp;
    else break;
  }
  cout << max_two_exp;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<array<int64_t, 2>>> E(n);

    for (int i = 0; i < m; i++){
        int l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        E[l].push_back({r, d});
        E[r].push_back({l, -d});
    }

    vector<bool> visited(n);
    map<int, int64_t> D;
    auto dfs = [&](auto i, auto self) -> bool{
        if (visited[i])
            return true;
        if (D.empty())
            D[i] = 0;

        visited[i] = true;
        bool res = true;
        for (const auto &e: E[i]){
            int r = e[0];
            int64_t d = e[1];
            if (D.count(r) != 0 and D[r] != D[i] + d)
                return false;
            D[r] = D[i] + d;
            res &= self(r, self);
        }
        return res;
    };

    for (int i = 0; i < n; i++){
        D.clear();
        if (!dfs(i, dfs)){
            puts("No");
            return 0;
        }
    }

    puts("Yes");
}


Measured memory_bytes: 24832
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

namespace mp = boost::multiprecision;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 200005;

int N;
int H[MAX_N];
int A[MAX_N];

class Node {
public:
    Node(LL v = unitValue) : value(v) {

    }

    Node operator + (const Node& monoid) const {
        return Node(max(this->getValue(), monoid.getValue()));
    }

    static Node unit() {
        return Node(unitValue);
    }

    void setValue(LL l) {
        this->value = l;
    }

    LL getValue() const {
        return this->value;
    }

private:
    LL value;
    static const LL unitValue = 0;
};

template <class T>
class SegmentTree {
public:
    SegmentTree(int size) {
        init(size);
    }

    void init(int size) {
        vec.clear();
        k = 1;
        while(k < size) {
            k *= 2;
        }
        for(int i = 0; i < 2*k; i++) {
            vec.push_back(T::unit());
        }
    }

    void update(int i, T x) { //iをxに変更する
        i += k-1;
        vec[i] = x;
        while(i > 0) {
            i = (i-1)/2;
            vec[i] = vec[i*2+1] + vec[i*2+2];
        }
    }

    T find(int l, int r) {
        return _find(l, r, 0, 0, k);
    }

private:
    vector<T> vec;
    int k;

    T _find(int l, int r, int k, int x, int y) {
        if (r <= x || y <= l) { //重なってない場合
            return T::unit();
        } else if (l <= x && y <= r) { //完全にかぶってる場合
            return vec[k];
        } else { //中途半端にかぶってる場合
            int mid = (x+y)/2;
            T lNode = _find(l, r, 2*k+1, x, mid);
            T rNode = _find(l, r, 2*k+2, mid, y);
            return lNode + rNode;
        }
    }
};

SegmentTree<Node> dp(MAX_N);
vector<int> hvec;
unordered_map<int, int> hIndex;

signed main()
{
  cin >> N;
  REP(n,N) {
    cin >> H[n];
    hvec.emplace_back(H[n]);
  }
  REP(n,N) {
    cin >> A[n];
  }

  sort(hvec.begin(), hvec.end());
  REP(n,N) {
    hIndex[hvec[n]] = n;
  }

  REP(n,N) {
    dp.update(hIndex[H[n]], dp.find(0,hIndex[H[n]]).getValue() + A[n]);
  }

  cout << dp.find(0,N+1).getValue() << endl;

  return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n),s(n);
    ll ans=0;
    for(int i = 0;i < n;i ++){
        cin >> a[i];
        if(i==0) s[i]=a[i];
        else s[i]=s[i-1]+a[i];
    }
    sort(s.begin(),s.end());
    for(int i = 0;i < n;i ++){
        if(s[i]==0) ans ++;
    }
    for(int i = 1;i < n;i ++){
        ll cnt = 1;
        while(i<n&&s[i]==s[i-1]){
            cnt ++;
            i ++;
        }
        ans += cnt*(cnt-1)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

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

    int a;
    cin >> a;

    int now = 2;
    ll cnt = a - 1;
    rep(i, 0, n - 1)
    {
        cin >> a;

        if (a < now)
            continue;
        else if (a == now)
            ++now;
        else if (a % now == 0)
            cnt += (ll) (a - 1) / now;
        else
            cnt += (ll) a / now;
    }

    cout << cnt << endl;
    return 0;
}


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

int main() {
    int N, p[101], m[101][101];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> p[i] >> p[i+1];
    }
    
    for (int i = 1; i <= N; i++) m[i][i] = 0;

    for (int l = 2; l <= N; l++) {
        for (int i = 1; i <= N - l + 1; i++) {
            int j = i + l - 1;
            m[i][j] = (1 << 21);
            for (int k = i; k <= j - 1; k++) {
                m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i - 1] * p[k] * p[j]);
            }
        }
    }
    
    cout << m[1][N] << endl;

    return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,a,b) for(ll i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(ll, N);
  int mn = to_string(N).length();
  rep(i, 1, sqrt(N) + 1) {
    if (N % i == 0) {
      mn = min(mn, (int)to_string(N / i).length());
    }
  }
  print(mn);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int h,w;
    while(true){
        cin >> h>>w;
        if(h==0&&w==0)break;
        if(h<1||w<1)continue;
        
        for(int r=0;r<h;r++){
            for(int c=0;c<w;c++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
package main

import (
        "fmt"
)

func solution(a []int) int {
        out := 0
        for i := range a {
                if a[i] == 0 {
                        out = i + 1
                }
        }
        return out
}

func main() {
        a := make([]int, 5)
        for i := range a {
                fmt.Scan(&a[i])
        }
        fmt.Println(solution(a))
}

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

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

int main()
{
  int k;
  cin >> k;
  
  long long ans = 0;
  for(int a = 1; a <= k; ++a)
  {
    for(int b = 1; b <= k; ++b)
    {
      for(int c = 1; c <= k; ++c)
      {
        ans += gcd(gcd(a, b), c);
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <bitset>
#include <vector>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <iomanip>
using namespace std;

struct Point{
    double x;
    double y;
};



int main(){
    
    int A,B,H,M;
    cin>>A>>B>>H>>M;
    
    //cout<<M_PI<<endl;
    double rad_h=((double)(H*60+M)/(60*12))*2.0*M_PI;
    double rad_m=((double)M/60)*2.0*M_PI;
    
    Point p_h,p_m;
    p_h.x=A*cos(rad_h);
    p_h.y=A*sin(rad_h);

    p_m.x=B*cos(rad_m);
    p_m.y=B*sin(rad_m);
    //cout<<"長針:"<<p_h.x<<":"<<p_h.y<<" 短針:"<<p_m.x<<":"<<p_m.y<<endl;
    double ans=sqrt((p_h.x-p_m.x)*(p_h.x-p_m.x)+(p_h.y-p_m.y)*(p_h.y-p_m.y));
    cout<<fixed<<setprecision(15)<<ans<<endl;
    
   
}



Measured memory_bytes: 3936
N=input()
A=map(int,raw_input().split())
B=map(int,raw_input().split())
need=0
Ans=0

for a,b in zip(A,B):
    if b>a:
        need+=b-a
        Ans+=1
        
index=0

Gap=[a-b for a,b in zip(A,B)]
Gap.sort(reverse=True)

while need>0:
    if Ans+index>=N:
        break
    need-=Gap[index]
    index+=1
    
if need<=0:
    print Ans+index
else:
    print "-1"

Measured memory_bytes: 20088
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

#define ll long long


int main()
{
	ll l, r;
	cin >> l >> r;

	ll res = 2019;

	if (r - l > 2018)
	{
		cout << 0 << endl;
	}
	else
	{
		for (int i = 0; l + i < r; i++)
		{
			for (int j = i + 1; l + j <= r; j++)
			{
				if (((l + i) * (l + j)) % 2019 < res)
				{
					res = ((l + i) * (l + j)) % 2019;
				}
			}
		}

		cout << res << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()	{
  unsigned long long a, b, c;
  cin >> a >> b >> c;
  unsigned long long x = (a - 1) / c;
  if (a == 0) x = -1;
  unsigned long long y = b / c;
  cout << y - x << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n, q;
int main() {
    cin >> n;
    vector<int> a(n, 0);
    for(int i = 0; i < n; ++i) cin >> a.at(i);
    // cout << "ok" << endl;
    set<int> st;
    for(int bit = 0; bit < (1<<n); ++bit) {
        int sum = 0;
        for(int i = 0; i < n; ++i) {
            if(bit & (1<<i)) sum += a.at(i);
        }
        st.insert(sum);
    }
    cin >> q;
    for(int i = 0; i < q; ++i) {
        int m;
        cin >> m;
        if(st.find(m) != st.end()) cout << "yes" << endl;
        else cout << "no" << endl;
    } 
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> s(N);
    int sum = 0;
    rep(i, 0, N){
        cin >> s.at(i);
        sum += s.at(i);
    }
    sort(all(s));
    rep(i, 0, N){
        if(sum % 10 != 0){
            cout << sum << endl;
            return 0;
        }
        else{
            if (s.at(i)%10 != 0){
                sum -= s.at(i);
            }
        }
    }
    cout << 0 << endl;
}


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

int di[9] = {0, 0, 0, 1, 1, 1, 2, 2, 2};
int dj[9] = {0, 1, 2, 0, 1, 2, 0, 1, 2};

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt[9][9] = {};
    for(int i = 1; i < s.length(); i++){
        int from = s[i-1]-'1', to = s[i]-'1';
        cnt[from][to]++;
        cnt[to][from]++;
    }
    vector<int> ans(9), arr(9);
    for(int i = 0; i < 9; i++)  arr[i] = i;
    int ma = 1<<30;
    do{
        int rev[9];
        for(int i = 0; i < 9; i++){
            rev[arr[i]] = i;
        }
        int tmp = 0;
        for(int i = 0; i < 9; i++){
            for(int j = i+1; j < 9; j++){
                int dist = abs(di[rev[i]]-di[rev[j]])+abs(dj[rev[i]]-dj[rev[j]]);
                tmp += dist * cnt[i][j];
            }
        }
        if(tmp < ma){
            ma = tmp;
            ans = arr;
        }
    }while(next_permutation(arr.begin(), arr.end()));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cout << ans[i*3+j]+1;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3284
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    ll a,b;cin>>a>>b;
  	if(a==b) cout << 2*a << ednl;
    else cout << (a<b?2*b-1:2*a-1) << ednl;
}


Measured memory_bytes: 256
import fractions

A,B=list(map(int,input().split()))    

maxn=10**6
prime=[1]*(maxn+1)
prime[0]=0
prime[1]=0

for i in range(2,maxn+1):
    if prime[i]==0:
        continue

    for j in range(2,maxn//i+1):
        prime[i*j]=0

C=fractions.gcd(A,B)
cnt=1

for i in range(2,maxn+1):
    if prime[i]==0:
        continue

    if C%i==0:
        while C%i==0:
            C//=i
        cnt+=1

if C>1:
    cnt+=1

print(cnt)

Measured memory_bytes: 12772
#include <iostream>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
using namespace std;

void solution(const vector<vector<bool> > wallX, const vector<vector<bool> > wallY)
{
    int goalX = wallX[0].size()-2;
    int goalY = wallX.size()-1;

    queue<int> length;
    queue<int> currX;
    queue<int> currY;
    length.push(1);
    currX.push(0);
    currY.push(0);
    set<pair<int, int> > history;
    history.insert(make_pair(0, 0));

    while(length.size() > 0){
        int x = currX.front();
        int y = currY.front();
        if(x == goalX && y == goalY)
            break;
        if(!wallX[y][x] && history.find(make_pair(y,x-1))==history.end()){
            length.push(length.front()+1);
            currX.push(x-1);
            currY.push(y);
            history.insert(make_pair(y, x-1));
        }
        if(!wallX[y][x+1] && history.find(make_pair(y,x+1))==history.end()){
            length.push(length.front()+1);
            currX.push(x+1);
            currY.push(y);
            history.insert(make_pair(y, x+1));
        }
        if(!wallY[y][x] && history.find(make_pair(y-1,x))==history.end()){
            length.push(length.front()+1);
            currX.push(x);
            currY.push(y-1);
            history.insert(make_pair(y-1, x));
        }
        if(!wallY[y+1][x] && history.find(make_pair(y+1,x))==history.end()){
            length.push(length.front()+1);
            currX.push(x);
            currY.push(y+1);
            history.insert(make_pair(y+1, x));
        }

        length.pop();
        currX.pop();
        currY.pop();
    }

    if(length.size() > 0){
        cout << length.front() << endl;
    }else{
        cout << '0' << endl;
    }
}

int main()
{
    for(;;){
        int x, y;
        cin >> x >> y;
        if(x == 0 && y == 0)
            break;

        vector<vector<bool> > wallX(y, vector<bool>(x+1, true));
        vector<vector<bool> > wallY(y+1, vector<bool>(x, true));

        int tmp;
        for(int i=0; i<y-1; ++i){
            for(int j=0; j<x-1; ++j){
                cin >> tmp;
                wallX[i][j+1] = (tmp == 1);
            }
            for(int j=0; j<x; ++j){
                cin >> tmp;
                wallY[i+1][j] = (tmp == 1);
            }
        }

        for(int i=0; i<x-1; ++i){
            cin >> tmp;
            wallX[y-1][i+1] = (tmp == 1);
        }

        solution(wallX, wallY);
    }

    return 0;
}

Measured memory_bytes: 956
sx, sy, tx, ty = gets.split.map(&:to_i)
ans = ""
if sx == tx
	ans += "U"*(ty-sy)
	ans += "L"+"D"*(ty-sy)+"R"
	ans += "R"+"U"*(ty-sy)+"L"
	ans += "U"+"LL"+"D"*(ty-sy+2)+"RR"+"U"
elsif sy == ty
	ans += "R"*(tx-sx)
	ans += "U"+"L"*(tx-sx)+"D"
	ans += "D"+"R"*(tx-sx)+"U"
	ans += "R"+"UU"+"L"*(tx-sx+2)+"DD"+"R"
else
	ans += "U"*(ty-sy)+"R"*(tx-sx)+"D"*(ty-sy)+"L"*(tx-sx)
	ans += "L"+"U"*(ty-sy+1)+"R"*(tx-sx+1)+"D"
	ans += "R"+"D"*(ty-sy+1)+"L"*(tx-sx+1)+"U"
end
puts ans

Measured memory_bytes: 1916
#include<stdio.h>

int main(){
	int n, m, c;
	scanf("%d%d%d", &n,&m,&c);
	int a[n][m], b[m];
	for(int i=0; i<m; i++){
		scanf("%d", &b[i]);
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			scanf("%d", &a[i][j]);
		}
	}
	
	int sum[n];
	for(int i=0; i<n; i++){
		sum[i] = 0;
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			sum[i] += a[i][j]*b[j];
		}
		sum[i] += c;
	}
	
	int count=0;
	for(int i=0; i<n; i++){
		if(sum[i] > 0) count++;
	}
	printf("%d", count);
	
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}

signed main() {
	int h;
	cin >> h;
	int ans = 0;
	int now = 1;
	while (h > 0) {
		ans += now;
		h /= 2;
		now *= 2;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        os: chars,
        es: chars,
    }
    let mut v = Vec::new();
    for (i,o) in os.iter().enumerate() {
        v.push(*o);
        if let Some(e) = es.get(i) {
            v.push(*e);
        }
    }
    println!("{}",
        v.into_iter().collect::<String>());
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
   string a, b, c;
   cin >> a >> b >> c;
   if(a[a.size()-1] == b[0] && c[0] == b[b.size()-1]){
    cout << "YES" << "\n";
   }
   else{
    cout << "NO" << "\n";
   }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f;
const ll mod = 1e9 + 7;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
int n;
char s[N];
ll cnt[N];

void solve()
{
    cin >> n;
    scanf("%s", s + 1);
    for (int i = 1; i <= n; ++i)
        cnt[s[i] - 'a']++;
    ll ans = 1;
    for (int i = 0; i < 26;++i)
    {
        ans *= (cnt[i] + 1);
        ans %= mod;
    }
    ans--;
    ans += mod, ans %= mod;
    printf("%lld\n", ans);
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 2304
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int x = in.nextInt();
            int y = in.nextInt();
            int z = in.nextInt();

            out.print((x - z) / (y + z));
        }

    }
}



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

set<int> zet;
int N,k;
pair<int,int> p[200001];
int ans;

int main(){
  cin >> N >> k; int x;
  for (int i=0;i<N;i++){
    cin >> x;
    zet.insert(x);
    p[i].second = i;
    p[x].first += 1;
  }
  p[N].second = N;
  sort(p,p+N+1);
  int n=0;
  while (p[N-n].first != 0){
    n += 1;
  }
 
  pair<int,int> p2[n];
  int j = 0;
  while (n){
    p2[j].first = p[N-j].first;
    p2[j].second = p[N-j].second;
    j += 1;
    n -= 1;
  }
  sort(p2,p2+j);j=0;
  while (zet.size() > k){
    zet.erase(p2[j].second);
    ans += p2[j].first;
    j+=1;
  }
  cout << ans;
  return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector <int> a(n);
  for (int i=0;i<n;i++) cin>>a.at(i);
  int p=a.at(0),sum=1;
  while(p!=2){
    p=a.at(p-1);
    sum++;
    if (sum>n-1){
      sum=-1;
      break;
    }
  }
    cout<<sum<<endl;
}

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

int main() {
    string s;
    cin >> s;

    int n = (int)s.size();
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }

    for (int i = 0; i < n - 2; i++) {
        if (s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }

    cout << "-1 -1" << endl;
    return 0;
}

Measured memory_bytes: 512
n,c = map(int,input().split())
D = [list(map(int,input().split())) for _ in range(c)]
C = [list(map(int,input().split())) for _ in range(n)]

color_count = [[0]*c for i in range(3)]
for i in range(n):
    for j in range(n):
        color_count[(i+j)%3][C[i][j]-1] += 1

min_wrongness = 10**9

for i in range(c):
    for j in range(c):
        for k in range(c):
            if i!=j and j!=k and k!=i:
                wrongness = 0
                for l in range(3):
                    for m in range(c):
                        if l == 0:
                            wrongness += D[m][i]*color_count[l][m]
                        elif l == 1:
                            wrongness += D[m][j]*color_count[l][m]
                        else:
                            wrongness += D[m][k]*color_count[l][m]
                min_wrongness = min(min_wrongness,wrongness)
                
print(min_wrongness)

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

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

  vector<int> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }

  int Minterval= -1;
  for(int i=1; i<N; i++){
    Minterval= max(Minterval, data.at(i)- data.at(i-1));
  }
  Minterval= max(Minterval, L+ data.at(0)- data.at(N-1));

  cout << L- Minterval << endl;
}

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

using namespace std;

long long a[200010];
long long l[200010];
long long r[200010];
int main() {
    
    int n;
    cin >> n;

    for (int i = 0; i < n; ++i)
        cin >> a[i];

    l[0] = a[0];

    for (int i = 1; i < n; ++i) 
        l[i] += a[i] + l[i - 1];

    for (int i = n - 1; i >= 0; i--)
        r[i] += a[i] + r[i + 1];
    

    long long ans = LLONG_MAX;

    for (int i = 0; i < n - 1; ++i) {
        ans = min(ans, abs(l[i] - r[i + 1]));
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 4992
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<bits/stdc++.h>            
#include<cmath>                  
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define pb push_back 
#define mkp make_pair    
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define rall(v )  reverse(v.begin(), v.end())      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vll vector< pair<ll,ll> > 
#define mpl map<ll, ll>
#define ee cout<<endl
#define pr pair<ll,ll>
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x*x)%MOD;if(p%2==0) return x;else return (x*n)%MOD;}
/*ll vis[100023];
ll a[100023];
vl v0[100023];
vl v1[100023];
vl V[100023];
ll col[100023];
ll ans=0;
vl L[100023];
ll mx=0;
void dfs(ll node,ll f)
{
	if(vis[node]==1)
	return;
	vis[node]=1;
	mx=max(mx,f);
	L[f].pb(node);
	for(i=0;i<V[node].size();i++)
	{
		dfs(V[node][i],f+1);
	}
}
*/
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;
	   //cin>>t;
	      while(t--)
{
/*
7 4 3*/
ll  n,m;
ll k;
cin>>n>>k>>m;
n=abs(n);
if(n/m>=k)
cout<<n-m*k;
else
{k-=n/m;
n-=(n/m)*m;
k=k%2;
if(k==0)
cout<<abs(n);
else
cout<<abs(n-m);
}
ee;
/*
5
4 4 9 7 5*/
/*ll n,j,k,l,i,m;
cin>>n;
ll a[n];
fo(i,n)
cin>>a[i];
//sort(a,a+n);
ll ans=0;
for(i=0;i<n-2;i++)
{
	for(j=i+1;j<n-1;j++)
	{
		for(k=j+1;k<n;k++)
		{
			if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[k]+a[j]>a[i]&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k])
			ans++;
		}
	}
}
cout<<ans;
ee;
*/
	/*
string a;
ll c=0,i;
ll mx=0;
cin>>a;
fo(i,a.length())
{
	if(a[i]=='R')
	c++;
	else
	c=0;
	mx=max(mx,c);
}
cout<<mx;
ee;*/
/*ll n,m,j,k,l,i;
cin>>n;
ll a[n],b[n];
string s;
fo(i,n-1)
{
	cin>>a[i]>>b[i];
	V[a[i]].pb(b[i]);
	V[b[i]].pb(a[i]);
}
cin>>s;
ans=0;
mx=0;
fo(i,n)
vis[i+1]=0;
dfs(1,1);
ll h=2;
ans=0;
for(i=mx;i>=1;i--)
{
	if(L[i].size()>=h)
	{
		ans=-1;
		break;
	}
}
*/

/*
1  
7  
1 2  
1 3  
2 4  
2 5  
3 6  
3 7  
0010010*/
}
return 0;
}
















Measured memory_bytes: 3664
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
const ll BIGMOD = 1e9 + 7;
using namespace std;

int main() {
  string str;
  int q;
  deque<char> deq;
  char flag = 1;
  cin >> str;
  cin >> q;
  for (int i = 0; i < str.size(); ++i) deq.push_back(str[i]);
  for (int i = 0; i < q; ++i) {
    int t, f;
    char c;
    scanf("%d", &t);
    if (t == 1) {
      flag *= -1;
      continue;
    }
    scanf("%d %c", &f, &c);
    if (flag == 1) {
      if (f == 1)
        deq.push_front(c);
      else
        deq.push_back(c);
    } else {
      if (f == 1)
        deq.push_back(c);
      else
        deq.push_front(c);
    }
    // for (deque<char>::iterator itr = deq.begin(); itr != deq.end(); ++itr) {
    //   printf("%c", *itr);
    // }
    // cout << endl;
    // cout << "t:" << t << " f:" << f << " c:" << c << endl;
  }

  if (flag == 1) {
    for (deque<char>::iterator itr = deq.begin(); itr != deq.end(); ++itr) {
      printf("%c", *itr);
    }
  } else {
    for (deque<char>::iterator itr = deq.end() - 1; itr >= deq.begin(); --itr) {
      printf("%c", *itr);
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 896
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define N 51
using namespace std;
char Change(char,char);
bool Check(vector<int>,vector<char>,vector<int>,vector<char>);

int main(){
  int n,m,x,y,bx,by;
  char d;
  vector<int> v[N];
  vector<char> c[N],dir[N];
  while(1){
    cin>>n;
    if(!n) break;
    for(int i=0;i<=n;i++){
      cin>>m;
      for(int j=0;j<m;j++){
	cin>>x>>y;
	if(j){
	  v[i].push_back(max(abs(bx-x),abs(by-y)));
	  if(by==y){
	    if(x-bx>0) d='r';
	    else d='l';
	  }else{
	    if(y-by>0) d='u';
	    else d='d';
	  }
	  c[i].push_back(d);
	}
	bx=x,by=y;
      }
      for(int j=0;j<c[i].size()-1;j++) dir[i].push_back(Change(c[i][j],c[i][j+1]));
    }
    for(int i=1;i<=n;i++)
      if(Check(v[0],dir[0],v[i],dir[i])) cout<<i<<endl;
    cout<<"+++++"<<endl;
    for(int i=0;i<=n;i++) v[i].clear(),c[i].clear(),dir[i].clear();
  }
  return 0;
}

char Change(char a,char b){
  if((a=='u'&&b=='r')||(a=='r'&&b=='d')||(a=='d'&&b=='l')||(a=='l'&&b=='u')) return 'l';
  return 'r';
}

bool Check(vector<int> a,vector<char> b,vector<int> c,vector<char> d){
  //if(a.size()!=c.size()) return false;
  if(a==c&&b==d) return true;
  reverse(c.begin(),c.end());
  reverse(d.begin(),d.end());
  for(int i=0;i<d.size();i++) d[i]=='l'?d[i]='r':d[i]='l';
  if(a==c&&b==d) return true;
  return false;
}

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

int main(){
    std::string s;
    std::cin >> s;
    int n = s.size();
    for(int i = 0; i < n; ++i){
        if(i == 5 || i == 13) std::cout << ' '; 
        else std::cout << s[i];
    }
    std::cout << std::endl;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
static const int MAX = 999999;

bool isPrime[MAX + 1];
int numPrime[MAX + 1];

void calcPrime(){
  for(int i = 0; i <= MAX; i++)
    isPrime[i] = true;
  isPrime[0] = isPrime[1] = false;
  for(int i = 0; i * i <= MAX; i++){
    if(isPrime[i]){
      for(int j = i * 2; j <= MAX; j += i)
        isPrime[j] = false;
    }
  }
  int sum = 0;
  for(int i = 0; i <= MAX; i++){
    if(isPrime[i])
      sum++;
    numPrime[i] = sum;
  }
}

int main(){
  int n;
  calcPrime();
  while(cin >> n){
    cout << numPrime[n] << endl;
  }
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  long long ans = 0;
  for(int i=0; i<N-1; i++){
    if(A.at(i+1)<A.at(i)){
      ans += A.at(i)-A.at(i+1);
      A.at(i+1) = A.at(i);
    }
  }
  cout << ans;
  return 0;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 100005;

int K;

long long solve(int W, int H) {
	int S = 3 * H + 2 * K;
	long long ans[2] = {0, 0};
	for (int y = 1; y < H; ++y) {
		for (int d = 0; d * y <= S && d < W; ++d) {
			int R = std::__gcd(d, H) + 2 * K - 2 - d * y;
			int lim = std::min(std::max(R / H, 0), W - d - 1);
			ans[d == 0] += lim;
			for (int x1 = lim + 1; x1 <= lim + 2 && x1 + d < W; ++x1) {
				if (x1 * H - std::__gcd(x1 + d, H - y) - std::__gcd(x1, y) <= R) {
					++ans[d == 0];
				}
			}
		}
	}
	return 2 * ans[0] + ans[1];
}

int main() {
	int W, H;
	read(W), read(H), read(K);
	// W = H = K = 100000;
	print(2 * (solve(W, H) + solve(H, W)));
	debug("%.3lf\n", 1.0 * clock() / CLOCKS_PER_SEC);
}


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

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){

    int x;
    cin >> x;

    int cnt = 1;
    while (true){
        if( (x * cnt) % 360 == 0){
            cout << cnt << endl;
            return 0;
        }
        cnt ++;
    }
    


    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
bool check( int N, const vector<int>& M, int A, int B ){
  for( int i=0; i<N; ++i ){ // ii=0~N
    for( int j=0; j<N; ++j ){
      int i_ = (i+A)%N;
      int j_ = (j+B)%N;
      int i_t = (j+A)%N;
      int j_t = (i+B)%N;
      if( M[i_*N+j_] != M[i_t*N+j_t] ) return false;
    }
  }
  //cerr << A << " " << B << endl;
  return true;
}
int main(int argc, char* argv[] ){
  int N;
  cin >> N;
  vector<int> M(N*N);
  for( int i=0; i<N; ++i ){
	string s;
    cin >> s;
    for( int j=0; j<N; ++j) { M[i*N+j] = s[j]; }
  }
  int count = 0;
  for( int a=0; a<N; ++a ){
    count += check(N,M,a,0) ? N : 0;
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 
 
#define PI 3.14159265
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
//~ const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
 
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

string s;
bool isPal(int l, int r){
	//~ cout<<l<<" "<<r<<" ";
	for(int i = l, j = r; i <= r; i++,j--){
		if(s[i] != s[j]){
			//~ cout<<"n"<<endl;
			return false;
		}
	}
	//~ cout<<"y"<<endl;
	return true;
}
int main(){
	cin>> s;
	int n = (int)s.size();
	int l = 0, r = n;
	if(isPal(l,r-1) && isPal(l,(r)/2-1) && isPal((r+3)/2 - 1,r-1) )
		cout<<"Yes";
	else
		cout<<"No";
    return 0;
}
	


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

int main() {
  int A, B;
  cin >> A >> B;
  
  if (A >= 13) {
    cout << B << endl;
  }
  
  else if (A >= 6) {
    cout << B/2 << endl;
  }
  
  else {
    cout << 0 << endl;
  }
}



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

bool check(int mask, int pos){
    if((mask & (1 << pos)) != 0){
        return true;
    }else{
        return false;
    }
}

int main(){
    vector<char> s(4);
    for(int i=0; i<4; i++){
        cin >> s[i];
    }

    int tmp;
    char op[3];
    for(int i=0; i<8; i++){
        tmp=s[0]-'0';
        for(int j=0; j<3; j++){
            if(check(i,2-j)){
                tmp += s[j+1] - '0';
                op[j] = '+';
            }else{
                tmp -= s[j+1] - '0';
                op[j] = '-';
            }
        }
        if(tmp == 7){
            break;
        }
    }

    for(int i=0; i<3; i++){
        cout << s[i] << op[i];
    }
    cout << s[3] << "=7" << endl;
}

Measured memory_bytes: 256
p1 = 0
p2 = 0
p3 = 0
for i in range(10):
    d = int(raw_input())
    if (d > p1):
        p3 = p2
        p2 = p1
        p1 = d
    elif (d > p2):
        p3 = p2
        p2 = d
    elif (d > p3):
        p3 = d

print p1
print p2
print p3

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

signed main(){
	vector<int> A(3);
	cin>>A[0]>>A[1]>>A[2];
	sort(A.begin(),A.end());
	A[2]-=A[0];
	A[1]-=A[0];
	A[0]=0;
	int ans=0;
	if(A[1]%2==0){
		ans=A[1]/2+A[2]-A[1];
	}
	else{
		A[1]++; A[2]++;
		ans=A[1]/2+A[2]-A[1]+1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
def solve():
  n = int(input())
  ary = []
  minN = None
  summ = 0
  for i in range(n):
    x = int(input())
    summ += x
    if x%10 > 0 and (not minN or minN > x):
      minN = x
  # sum == 10*k
  # return sum(ary)-(min but not *10)
  if summ % 10 > 0:
    return summ
  # sum != 10*k
  elif minN != None:
    return summ - minN
  else:
    return 0
print(solve())

Measured memory_bytes: 3060