akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, ll> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int mod = 1e+9 + 7;
const int INF = 1e+9;

// doubling[k][i] := a[i] から始めて 2^k 回操作を行った時の長さ
ll doubling[70][200005];

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

    int N;
    ll K;
    cin >> N >> K;
    vector<int> a(N);
    vector<vector<int>> pos(2e+5 + 1);  // 要素の位置を表すテーブル
    for(int i = 0; i < N; ++i){
        cin >> a[i];
        pos[a[i]].push_back(i);
    }

    for(int i = 0; i < N; ++i){
        int it = upper_bound(pos[a[i]].begin(), pos[a[i]].end(), i) - pos[a[i]].begin();

        if(it != (int)pos[a[i]].size()){    // (i,N) に同じ要素があるとき
            doubling[0][i] = pos[a[i]][it] - i + 1;
        }
        else{   // (i,N) に同じ要素がないとき
            doubling[0][i] = (N + pos[a[i]][0]) - i + 1;
        }
    }

    for(int k = 1; k < 60; ++k){
        for(int i = 0; i < N; ++i){
            doubling[k][i] = doubling[k-1][i] + doubling[k-1][(i + doubling[k-1][i]) % N];
        }
    }

    // a[0] から操作を行って、K*N を超えない最大値を調べる。
    ll len = 0;
    bool flag = true;   // 更新フラグ　更新がない時にループを抜けられる
    while(flag){
        ll tmp = 0;
        int p = len % N;    // 現在の位置 (modN)
        flag = false;
        for(int i = 0; i < 60; ++i){
            if(len + doubling[i][p] >= K * N)   break;

            tmp = doubling[i][p];
            flag = true;
        }

        if(flag){
            len += tmp;
        }
    }
    int start = len % N;

    deque<int> deq;
    set<int> s;
    for(int i = start; i < N; ++i){
        if(s.find(a[i]) == s.end()){    // deq 内に a[i] がない場合
            deq.push_back(a[i]);
            s.insert(a[i]);
        }
        else{   // deq 内に a[i] がある場合
            while(!deq.empty()){
                int tmp = deq.back();
                deq.pop_back();
                s.erase(tmp);
                if(tmp == a[i])     break;
            }
        }
    }

    while(!deq.empty()){
        cout << deq.front() << " ";
        deq.pop_front();
    }
    cout << "\n";
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; ++i) cin >> v[i];
    for(int i = 0; i < n; ++i)
    {
        int tmp;
        cin >> tmp;
        v[i] -= tmp;
    }

    int ans = 0;
    sort(v.begin(), v.end(), greater<int>());
    for(int i = 0; i < n; ++i)
    {
        if(v[i] <= 0) break;
        ans += v[i];
    }

    cout << ans << endl;
}

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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 2e5+5;

ll n;
pair<ll,ll> a[N];

void solveOd()
{
    sort(a+1 , a+n+1);
    ll ans = 1e9;
    ans -= (a[n/2+1].f-1);

    for(int i=1; i<=n; i++)
    {
        swap(a[i].f , a[i].s);
    }
    sort(a+1 , a+n+1);
    ans -= (1e9 - a[n/2+1].f);
    cout << ans << '\n';
}

void solveEv()
{
    ll ans = 2e9 , tmp;
    sort(a+1 , a+n+1);
    tmp = a[n/2].f + a[n/2+1].f - 1;
    ans -= tmp;

    for(int i=1; i<=n; i++)
    {
        swap(a[i].f , a[i].s);
    }
    sort(a+1 , a+n+1);

    tmp = a[n/2+1].f + a[n/2].f;
    ans -= (2e9-tmp);
    cout << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i=1; i<=n; i++)
    {
        cin >> a[i].f >> a[i].s;
    }

    if (n%2) solveOd();
    else solveEv();


    return 0;
}

Measured memory_bytes: 6716
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
    int x,a,b;
    scanf("%d %d %d",&x,&a,&b);
    int c;
    c=(x-a)/b;
    int d;
    d=x-a-(c*b);
    printf("%d\n",d);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=2e5+10;
const ll MOD=1e9+7;

int N;
string S;
int A[MAX];
void input(){
	cin>>N;
	cin>>S;
	rep(i,2*N){
		if(S[i]=='B')A[i+1]=1;
		else A[i+1]=0;
	}
}

ll ans;
int c[MAX];
void solve(){
  	int tmp=0;
	int ch=1;
	rep1(i,2*N){
		if(A[i]!=tmp){
			c[i]=ch;
		}
		else{
			ch*=-1;
			c[i]=ch;
		}
      tmp=A[i];
	}
//	rep1(i,2*N)cout<<c[i]<<" ";

	ans=1;
	ll t=0;
	bool ok=true;
	rep1(i,2*N){
		if(c[i]==-1)ans=(ans*t)%MOD;
		t+=c[i];
		if(t<0)ok=false;
	}
	if(t!=0)ok=false;

	if(!ok)cout<<0<<endl;
	else{
		rep1(i,N)ans=(ans*(ll)i)%MOD;
		cout<<ans<<endl;
	}
}

void output(){
  
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 2180
#include<bits/stdc++.h>
using namespace std;
static const int MAX=1000;
static const int VMAX=10000;
int n,A[MAX],s;
int B[MAX],T[VMAX+1];

int solve()
{
    int ans=0;

    bool V[MAX];
    for(int i=0;i<n;++i)
    {
        B[i]=A[i];
        V[i]=false;
    }
    sort(B,B+n);
    for(int i=0;i<n;i++)
    {
        T[B[i]]=i;
    }
    for(int i=0;i<n;i++)
    {
        if(V[i])continue;
        int cur=i;
        int S=0;
        int m=VMAX;
        int an=0;
        while(1)
        {
            V[cur]=true;
            an++;
            int v=A[cur];
            m=min(m,v);
            S+=v;
            cur=T[v];
            if(V[cur])break;
        }
        ans+=min(S+(an-2)*m,m+S+(an+1)*s);
    }
    return ans;
}

int main()
{
	cin>>n;
	s=VMAX;
	for(int i=0;i<n;i++)
    {
        cin>>A[i];
        s=min(s,A[i]);
    }
    int ans=solve();
    cout<<ans<<endl;
 	return 0;
}


Measured memory_bytes: 3176
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    ll n,m;
    cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;

}



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    

    solve();


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  
   ll i,j,k,n,m,p,q,t,ans=0,sum=0,ct=0,flag=0;
  cin>>n;
  std::vector<ll> v(3*n);
  for(i=0;i<3*n;i++)
  {
    cin>>v[i];
  }

  std::vector<ll> l(3*n);
  std::vector<ll> r(3*n);

  ans=-LLONG_MAX;
  ll sum1,sum2,s1,s2;

///left part
  multiset <ll> st;
  for(i=0;i<n;i++)
  {
    st.insert(v[i]);
    sum+=v[i];
    l[i]=-INT_MAX;
  }
  l[n-1]=sum;
  auto it=st.begin();
  for(i=n;i<3*n;i++)
  {
    sum+=v[i];
    st.insert(v[i]);
    it = st.begin();
    sum-=*it;
    st.erase(it);
    l[i]=sum;
  }

// right part
  st.clear();
  sum=0;
  for(i=3*n-1;i>2*n-1;i--)
  {
    st.insert(v[i]);
    sum+=v[i];
    r[i]=INT_MAX;
  }
  r[2*n]=sum;

  for(i=2*n-1;i>=0;i--)
  {
    sum+=v[i];
    st.insert(v[i]);
    it=st.end(); it--;
    sum-=*it;
    st.erase(it);
    r[i]=sum;
  }

  for(i=n-1;i<2*n;i++)
  {
    // cout<<l[i]<<" "<<r[i+1]<<endl;
    ans=max(ans,l[i]-r[i+1]);
  }


  cout<<ans;
  return 0;
}

Measured memory_bytes: 12032
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i32,
        color_vec: chars
    }

    let mut r_num = 0;
    let mut w_num = 0;
    for color in color_vec.iter() {
        if color == &'W' {
            w_num += 1;
        } else {
            r_num += 1;
        }
    }
    let mut target = String::new();
    for _ in 0..r_num {
        target.push('R');
    }
    for _ in 0..w_num {
        target.push('W');
    }

    let target_chars = target.chars().collect::<Vec<_>>();
    let mut count = 0;
    for (tc, c) in target_chars.iter().zip(color_vec.iter()) {
        if tc != c {
            count += 1;
        }
    }
    println!("{}", (count + 1) / 2);
}

// 災いを招かないパターン
// R*W*
// n=2の場合
//  WRの場合、WをRにして1回
//  それ以外は0回
// 入れ替える操作はRとWを入れ替える操作でないと意味がない
// 　左W右Rの入れ替え
// 色変えは入れ替えで代用可能な気がする
// 　赤に塗り替えるなら、一番右にある赤と入れ替えた方が同じかよりいい
// つまり、最終形が確定する
// 最終形と違う文字数を数えて２で割った結果を切り上げるのが最短回数


Measured memory_bytes: 3928
#include <stdio.h>

int main(){
  int s[4], t[4], i, sscore = 0, tscore = 0;

  for(i = 0 ; i < 4 ; i++){
    scanf("%d",&s[i]);
    sscore += s[i];
  }
  for(i = 0 ; i < 4 ; i++){
    scanf("%d",&t[i]);
    tscore += t[i];
  }
  if(sscore >= tscore)
    printf("%d\n",sscore);
  else printf("%d\n",tscore);

  return 0;

}

Measured memory_bytes: 588
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ABC152B
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var a = NN;
            var b = NN;
            var x = new string(Repeat(a + '0', b).Select(e => (char)e).ToArray());
            var y = new string(Repeat(b + '0', a).Select(e => (char)e).ToArray());
            if (x.CompareTo(y) > 0) Console.WriteLine(y);
            else Console.WriteLine(x);
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
}


Measured memory_bytes: 15328
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<time.h>
#include<vector>
using namespace std;
int main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
    int n,t2 = 0,t1 = 0;
    scanf("%d",&n);
    int a[10][10];

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

    for(int j=1; j<=2;++j)
        for(int i=0; i<n; ++i)
            scanf("%d",&a[j][i]);



    do{
        t1++;
        int flag = 0;
        for(int i=0; i<n; ++i){
            if(a[0][i]!=a[1][i]){
                flag = 1;
                break;
            }
        }
        if(!flag)
            break;
    }while(next_permutation(a[0],a[0]+n));

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

/*
    for(int i=0; i<n; ++i)
        printf("%d",a[2][i]);
    printf("\n");
*/


    do{
/*
        for(int i=0; i<n; ++i)
            printf("%d",a[0][i]);
        printf("\n");*/
        t2++;
        int flag = 0;
        for(int i=0; i<n; ++i){
            if(a[0][i]!=a[2][i]){
                flag = 1;
                break;
            }
        }
        if(!flag){
            break;
        }
    }while(next_permutation(a[0],a[0]+n));
    //printf("%d %d\n",t1,t2);
    printf("%d",abs(t1-t2));
    return 0;
}



Measured memory_bytes: 3816
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Diagnostics.Contracts;
using System.Dynamic;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Net;
using System.Numerics;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var XY = ReadInts();
            int[] listP;
            if (XY[1] == 0)
            {
                WriteLine(XY[0]);
                return;
            }
            else
            {
                listP = ReadInts();
            }

            for (int i = 0; i < 101; i++)
            {
                if (!listP.Contains(XY[0] - i))
                {
                    WriteLine(XY[0] - i);
                    return;
                }
                else if (!listP.Contains(XY[0] + i))
                {
                    WriteLine(XY[0] + i);
                    return;
                }
            }
        }


        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27936
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn=100000;

int main(){
    
    string s;
    ll mod = INF;
    ll ans = 0;
    ll powered_by_three[maxn+1];
    ll pa=0,sc=0,pc=0,sq=0,pq=0;
    
    cin >> s;
    
    rep(i,s.size()){
        if(s[i]=='?'){
            sq++;
        }else if(s[i]=='C'){
            sc++;
        }
    }
    
    powered_by_three[0]=1;
    for(int i=1;i<=sq;i++){
        powered_by_three[i]=(powered_by_three[i-1]*3)%mod;
    }
    
    rep(i,s.size()){
        if(s[i]=='B'){
            ans = (ans+pa*(sc-pc)*powered_by_three[sq])%mod;
            ans = (ans+pq*(sc-pc)*powered_by_three[sq-1])%mod;
            ans = (ans+pa*(sq-pq)*powered_by_three[sq-1])%mod;
            ans = (ans+pq*(sq-pq)*powered_by_three[sq-2])%mod;
        }else if(s[i]=='?'){
            ans = (ans+pa*(sc-pc)*powered_by_three[sq-1])%mod;
            ans = (ans+pq*(sc-pc)*powered_by_three[sq-2])%mod;
            if(sq-pq-1>=0)ans = (ans+pa*(sq-pq-1)*powered_by_three[sq-2])%mod;
            if(sq-pq-1>=0)ans = (ans+pq*(sq-pq-1)*powered_by_three[sq-3])%mod;
            pq++;
        }else if(s[i]=='A'){
            pa++;
        }else if(s[i]=='C'){
            pc++;
        }
    }
    
    cout << ans<<endl;
    
    return 0;
}


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

using namespace std;
#define NIL -1
#define ll long long
#define MAX 100
#define pb push_back

bool cmp(pair< int, int > p, pair< int, int > q)
{
	return p.first < q.first;
}

int main() {
	int n;
	cin >> n;
	vector< pair< int, int > > v;
	for(int i=1; i<=n; i++) {
		int x;
		cin >> x;
		v.pb(make_pair(x, i));
	}
	sort(v.begin(), v.end(), cmp);
	for(auto x: v) {
		cout << x.second << " ";
	}
    return 0;
}


Measured memory_bytes: 4256
# 2020/01/26
# AtCoder Beginner Contest 153 - A

# Input
h, n = map(int,input().split())
a = list(map(int,input().split()))

# Calc
sum = 0
for i in range(n):
    sum = sum + a[i]

if sum >= h:
    ans = "Yes"
else:
    ans = "No"

# Output
print(ans)


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int main() {
  string s;
  cin >> s;
  int res = 0;
  for (char c: s) {
    if (c == '+') ++res;
    else --res; 
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 2e5 + 10;
ll n, k;
ll a[maxn], f[maxn];

bool cmp(ll a, ll b) {
    return a > b;
}

bool judge(ll x) {
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] * f[i] > x) {
            ans += a[i] - x / f[i];
        }
    }
    return ans <= k;
}

int main() {
    ios::sync_with_stdio(0);
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> f[i];
    }
    sort(a, a + n);
    sort(f, f + n, cmp);
    ll l = -1, r = 1e12 + 10;
    while (abs(r - l) > 1) {
        ll mid = (l + r) / 2;
        if (judge(mid)) {
            r = mid;
        }else l = mid;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main()
{
    string s, t;
    cin >> s >> t;
    cout << t+s << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <ctype.h>
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

//char rbuf[]; int rbufl;
//#define getchar() rbuf[rbufl++]
#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }
void printint(int32_t x){ if(x<0){x=-x; putchar('-');}else if(x==0){putchar('0');} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putchar(s[i]); putchar('\n'); }
void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}

int p[200000][2];
int main(void){
	int n=nextint();
	for(int i=0; i<n; i++){
		p[i][0]=nextint();
		p[i][1]=nextint();
	}
	int a1 = p[0][0]-p[0][1];
	int a2 = p[0][0]-p[0][1];
	int b1 = p[0][0]+p[0][1];
	int b2 = p[0][0]+p[0][1];
	long ans=0;
	for(int i=1; i<n; i++){
		{ long now=p[i][0]-p[i][1]-a1; if(now<0) now=-now; if(now>ans) ans=now; }
		{ long now=p[i][0]-p[i][1]-a2; if(now<0) now=-now; if(now>ans) ans=now; }
		{ long now=p[i][0]+p[i][1]-b1; if(now<0) now=-now; if(now>ans) ans=now; }
		{ long now=p[i][0]+p[i][1]-b2; if(now<0) now=-now; if(now>ans) ans=now; }
		{ long now=p[i][0]-p[i][1]; if(now>a1) a1=now; if(now<a2) a2=now; }
		{ long now=p[i][0]+p[i][1]; if(now>b1) b1=now; if(now<b2) b2=now; }
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 3136
N, T = map(int, input().split())
c_t = [tuple(map(int, input().split())) for _ in range(N)]

c_t = filter(lambda ct: ct[1] <= T, c_t)
c_t = sorted(c_t, key=lambda ct: ct[0])
if len(c_t) > 0:
    c, t = c_t[0]
    print(c)
else:
    print('TLE')


Measured memory_bytes: 3060
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <vector>
#include <string>
#include <cstdio>
#include <chrono>
#include <random>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define fun function
#define sz(x) x.size()
#define lowbit(x) x&(-x)
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int INF = 0x3f3f3f3f;

vector<int>e[20];

int main() {
	IOS;
#ifdef xiaofan
	freopen("1.in","r",stdin);
	freopen("1.out","w",stdout);
#endif

	for(int i=1;i<=8;i++) {
		e[i].push_back(i-1);
		e[i].push_back(i);
		e[i].push_back(i+1);
	}
	e[9].push_back(8);
	e[9].push_back(9);
	e[0].push_back(0);
	e[0].push_back(1);
	int n;
	cin>>n;
	if(n<10) {
		cout<<n<<endl;
		return 0;
	}
	
	queue<ll>q;
	for(int i=1;i<=9;i++) q.push(i);
	int cnt=9;
	while(!q.empty()){
		ll x=q.front();
		q.pop();
		for(auto v:e[x%10]){
			cnt++;
			ll nx=x*10+v;
			if(cnt==n){
				cout<<nx<<endl;
				return 0;
			}
			q.push(nx);
		}
	}




	return 0;
}



Measured memory_bytes: 768
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	int n;
	cin>>n;
    vi v(n);
  	for(int i=0;i<n;i++)cin>>v[i];
  	std::sort(v.begin(),v.end());
  	cout<<v[n-1]-v[0];
  return 0;

//   TimeTaken();
}


Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define MAX_N 100000

int s[MAX_N];
int n = 0;

bool
search(int x)
{
	int l = 0, r = n - 1;
	while (l <= r)
	{
		int i = (l + r) / 2;
		if (x > s[i])
			l = i + 1;

		else if (x < s[i])
			r = i - 1;

		else
			return true;
	}

	return false;
}

int
main(int argc, char** argv)
{
	int q = 0;
	int t = 0;
	int i;

	scanf("%d", &n);
	for (i = 0; i < n; ++i)
		scanf("%d", &s[i]);

	scanf("%d", &q);
	int count = 0;
	for (i = 0; i < q; ++i)
	{
		scanf("%d", &t);
		if (search(t))
			count++;
	}

	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 984
n = int(input())
MOD = 10**9+7

memo = [{} for _ in range(n+1)]

def ok(last4):
  for i in range(4):
    temp = list(last4)
    if i >= 1:
      temp[i-1], temp[i] = temp[i], temp[i-1]
    if ''.join(temp).count('AGC') >= 1:
      return False
  return True

def dfs(cur, last3):
  if last3 in memo[cur]:
    return memo[cur][last3]
  if cur == n:
    return 1
  ret = 0
  for c in 'ACGT':
    if ok(last3+c):
      ret = (ret + dfs(cur+1, last3[1:]+c))%MOD
  memo[cur][last3] = ret
  return ret
        
print(dfs(0, 'TTT'))

Measured memory_bytes: 48220
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int Q;
	string S;
	bool fromFront = true;
	list<char> ls;

	cin >> S >> Q;
	rep(i, (int)S.length()) ls.push_back(S[i]);

	rep(loop, Q) {
		int T;

		cin >> T;
		if (T == 1) {
			fromFront = !fromFront;
		}
		else {
			int F;
			char C;

			cin >> F >> C;

			if (F == 1) {
				if (fromFront) ls.push_front(C);
				else ls.push_back(C);
			}
			else {
				if (fromFront) ls.push_back(C);
				else ls.push_front(C);
			}
		}
	}

	if (fromFront) {
		while (!ls.empty()) {
			cout << ls.front();
			ls.pop_front();
		}
		cout << endl;
	}
	else {
		while (!ls.empty()) {
			cout << ls.back();
			ls.pop_back();
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 9984
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

class Node {
public:
    int parent;
    int counter = 0;
};

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

    int root = 1;
    Node tree[N + 1];
    tree[root].parent = -1;

    int a, b;
    for(int i = 1; i <= N - 1; i++)
    {
        cin >> a >> b;
        tree[b].parent = a;
    }

    int p, x;
    for(int q = 0; q < Q; q++)
    {
        cin >> p >> x;
        tree[p].counter += x;
    }

    for(int i = 2; i <= N; i++)
        tree[i].counter += tree[tree[i].parent].counter;

    cout << tree[1].counter;
    for(int i = 2; i <= N; i++)
    {
        cout << " " << tree[i].counter;
    }
    cout << endl;
}

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

#define ll long long
#define inf 0x3f3f3f3f
#define il inline

using namespace std ;

#define N 100010

int n,m;
int cnt[N] ;
struct node {
	int year,p,id;
}a[N];

int ans[N][20] ;

bool cmp(node a,node b) {
	return a.year<b.year;
}

int main() {
	cin>>n>>m;
	for(int i=1;i<=m;i++) {
		cin>>a[i].p>>a[i].year;
		a[i].id=i;
	}
	sort(a+1,a+m+1,cmp);
	for(int i=1;i<=m;i++) {
		cnt[a[i].p]++;
		int t[10],t1[10] ;
		memset(t,0,sizeof(t));
		memset(t1,0,sizeof(t1));
		int x=a[i].p,y=cnt[a[i].p];
		int l=0,l1=0;
		while(x){
			t[++l]=x%10;
			x/=10;
		}
		while(y){
			t1[++l1]=y%10;
			y/=10;
		}
		int tot=0;
		for(int j=6;j;j--)
			ans[ a[ i ].id ][ ++ tot ] = t[ j ] ;
		for(int j=6;j;j--)
			ans[a[i].id][++tot]=t1[j];
	}
	for(int i=1;i<=m;i++){
		for(int j=1;j<=12;j++)
			printf( "%d" ,ans[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 10880
#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
using namespace std;
const int N=100007;
int n,m,s,e,hd[N],nt[N],to[N],Q[N*3],D[N*3],F[N*3],B[N][3];
int main() {
	scanf("%d%d",&n,&m);
	For(i,1,m) {
		int x,y;
		scanf("%d%d",&x,&y);
		nt[i]=hd[x],hd[x]=i,to[i]=y;
	}
	scanf("%d%d",&s,&e);
	Q[1]=s,D[1]=0;
	int h=0,t=1;
	while(h<t) {
		int u=Q[++h],d=D[h];
		for(int i=hd[u];i;i=nt[i])
		if(!B[to[i]][(d+1)%3]) {
			Q[++t]=to[i],D[t]=(d+1)%3,F[t]=F[h]+1,B[to[i]][(d+1)%3]=1;
			if(Q[t]==e&&!D[t]) {
				printf("%d\n",F[t]/3);
				return 0;
			}
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 6144
#include<stdio.h>
#include <stdlib.h>
#include<string.h>
#include<math.h>
#define loop(i, l, r) for(i=l; i<r; i++)/*Instead of function, (for).*/
#define rep(i,r) for(i=0; i<r; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long int lli;
/*Return Combination ,(nCr)*/
int combi(int n, int r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
/*Return gcd(a, b)*/
int gcd(int a, int b){
	if(b == 0) return a;
	else return gcd(b, a % b);
}
int main(void)
{
	int i=0;
	char s[101];
	scanf("%s", s);

	while(s[i] != '\0'){
		if(s[i] == 'R' || s[i] == 'U' || s[i] == 'D'){
			;
		}else{
			puts("No");
			return 0;
		}
		i++;
		if(s[i] == '\0') break;
		if(s[i] == 'L' || s[i] == 'U' || s[i] == 'D'){
			;
		}else{
			puts("No");
			return 0;
		}
		i++;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

#define MAX 500000
#define INFTY 2000000000

void Merge(int[MAX], int, int, int);
void MergeSort(int[MAX], int, int);

int count = 0;

int main(){

  int i, n;
  int A[MAX];

  scanf("%d", &n);

  for(i =0; i < n; i++){

    scanf("%d", &A[i]);

  }

  MergeSort(A, 0, n);
  
  for(i = 0; i < (n - 1); i++){
      
    printf("%d ", A[i]);

  }

  printf("%d\n", A[i]);

  printf("%d\n", count);
 
  return 0;

}

void Merge(int A[MAX], int left, int mid, int right){

  int i, j, k;

  int n1, n2;

  n1 = mid - left;
  n2 = right - mid;

  int L[MAX], R[MAX];

  for(i = 0; i < n1; i++){

    L[i] = A[left + i];

  }

  for(i = 0; i < n2; i++){

    R[i] = A[mid + i];

  }

  L[n1] = INFTY;
  R[n2] = INFTY;

  i = 0;
  j = 0;

  for(k = left; k < right; k++){

    if(L[i] <= R[j]){

      A[k] = L[i];

      i++;

    }
    else{

      A[k] = R[j];
      
      j++;

    }

    count++;

  }

}

void MergeSort(int A[MAX], int left, int right){

  int mid;

  if((left + 1) < right){

    mid = (left + right) / 2;

    MergeSort(A, left, mid);

    MergeSort(A, mid, right);

    Merge(A, left, mid, right);

  }

}

Measured memory_bytes: 5584
import sys
from heapq import heappop, heappush
def main():
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    l_camel = [[] for _ in range(n)]
    r_camel = [[] for _ in range(n)]
    ans = 0
    for _ in range(n):
        k, l, r = map(int, input().split())
        if l >= r:
            ans += r
            l_camel[k-1].append(l-r)
        else:
            ans += l
            r_camel[~(k-1)].append(r-l)
    
    cur = 0
    que = []
    for i in range(n):
        for el in l_camel[i]:
            heappush(que, el)
        while len(que) > i+1:
            heappop(que)
    ans += sum(que)

    que = []
    for i in range(n):
        for el in r_camel[i]:
            heappush(que, el)
        while len(que) > i:
            heappop(que)
    ans += sum(que)
    print(ans)


if __name__ == '__main__':
    t = int(input())
    for _ in range(t):
        main()

Measured memory_bytes: 47580
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestApp2
{
    class Program
    {
        static void Main(string[] args)
        {

            var str = Console.ReadLine()
                .Split(' ')
                .Select(x => decimal.Parse(x))
                .ToArray();
            bool iso = false;
            if (str[0] == 5 || str[0] == 7)
                if (str[1] == 5 || str[1] == 7)
                    if (str[2] == 5 || str[2] == 7)
                        if (str[0] + str[1] + str[2] == 17)
                        {
                            Console.WriteLine("YES");
                            iso = true;
                        }
            if (!iso)
                Console.WriteLine("NO");
            Console.ReadLine();
        }


    }
}



Measured memory_bytes: 11348
import numpy as np
n, m, q = map(int, input().split())
cnt = [[0]*(n+1)for _ in range(n+1)]
for _ in range(m):
    L, R = map(int, input().split())
    cnt[L][R] += 1

S = np.cumsum(cnt, axis=0).cumsum(axis=1).tolist()

for _ in range(q):
    L, R = map(int, input().split())
    ans = S[R][R]-S[R][L-1]-S[L-1][R]+S[L-1][L-1]
    print(ans)

Measured memory_bytes: 26252
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}

vector<ll> pw2(51,1);vector<ll> pw10(19,1);
ll high_order_bit(ll n){
    ll tmp=1,i=-1;
    while(tmp<=n){
        tmp*=2;
        i++;
    }
    if(n==0) return 0;
    else return i;
}
vector<ll> binary_expansion(ll n){
    vector<ll> B(high_order_bit(n)+1);
    ll tmp=n;
    for(ll i=high_order_bit(n);i>=0;i--){
        B[i]=tmp/pw2[i];
        tmp%=pw2[i];
    }
    return B;
}
vector<ll> divisor(ll x){
    vector<ll> div;
    for(int i=1;i*i<=x;i++){
        if(i*i!=x && x%i==0){
            div.pb(i);
            div.pb(x/i);
        }
        else if(x%i==0) div.pb(i);
    }
    return div;
}
vector<ll> vectorprime(ll x){
    vector<bool> is_prime(x+1);
    vector<ll> prime;
    rep(i,x+1) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<=x;i++){
        if(is_prime[i]){
            prime.pb(i);
        }
        for(int j=i*2;j<=x;j+=i) is_prime[j]=false;
    }
    return prime;
}

int main(){
    {rep1(i,50) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll K; cin>>K;
    ll ans=0;
    rep1(i,K)rep1(j,K)rep1(k,K){
        ans+=gcd(gcd(i,j),k);
    }
    cout<<ans;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

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

    int n, k;
    cin >> n >> k;
    bool flg[10];
    for( int i = 0; i < 10; ++i ) flg[i] = false;
    for( int i = 0; i < k; ++i ) {
        int d;
        cin >> d;
        flg[d] = true;

    }
    vector< int > v;
    for( int i = 0; i < 10; ++i ) {
        if( !flg[i] ) v.pb( i );

    }

    int i = n;
    for( ;; ) {
        bool fl = true;
        int tmp = i;
        while( tmp > 0 ) {
            if( flg[tmp % 10] ) fl = false;
            tmp /= 10;

        }
        if( fl ) {
            cout << i << endl;
            break;

        }
        ++i;
    }


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1010
#define INF 1e18
using namespace std;
long long n,m,ans=-INF,a[N],b[N],c[N];
void tfs(int x,int y,int z)
{
	long long i,pre;
	vector<long long> tem;
	for(i=0;i<n;i++)
	{
		pre=0;
		if(x)
		{
			pre+=a[i];
		}
		else
		{
			pre-=a[i];
		}
		if(y)
		{
			pre+=b[i];
		}
		else
		{
			pre-=b[i];
		}
		if(z)
		{
			pre+=c[i];
		}
		else
		{
			pre-=c[i];
		}
		tem.push_back(pre);
	}
	sort(tem.begin(),tem.end());
	reverse(tem.begin(),tem.end());
	pre=0;
	for(i=0;i<m;i++)
	{
		pre+=tem[i];
	}
	ans=max(ans,pre);
}
int main(){
	long long i,j,k;
	cin>>n>>m;
	for(i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	for(i=0;i<=1;i++)
	{
		for(j=0;j<=1;j++)
		{
			for(k=0;k<=1;k++)
			{
				tfs(i,j,k);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int k = sc.nextInt();
        int x1 = sc.nextInt()-1;
        int y1 = sc.nextInt()-1;
        int x2 = sc.nextInt()-1;
        int y2 = sc.nextInt()-1;
        boolean[][] g = new boolean[h][w];
        for(int i=0; i<h; i++) {
            char[] c = sc.next().toCharArray();
            for(int j=0; j<w; j++) {
                g[i][j] = c[j]=='@';
            }
        }
        long[][][] d = new long[h][w][4];
        for(int i=0; i<h; i++) {
            for(int j=0; j<w; j++) {
                Arrays.fill(d[i][j], Long.MAX_VALUE);
            }
        }
        d[x1][y1][0] = 0;
        int[] dx = {1, 0, -1, 0};
        int[] dy = {0, 1, 0, -1};
        PriorityQueue<P> q = new PriorityQueue<>();
        q.offer(new P(x1, y1, 0, 0));
        while(!q.isEmpty()) {
            P p = q.poll();
            if(p.d > d[p.x][p.y][p.dir]) continue;
            long nd = p.d + (k - p.d % k) % k;
            for(int i=0; i<4; i++) {
                if(p.dir == i) continue;
                if(d[p.x][p.y][i] > nd) {
                    d[p.x][p.y][i] = nd;
                    q.offer(new P(p.x, p.y, i, nd));
                }
            }
            int nx = p.x + dx[p.dir];
            int ny = p.y + dy[p.dir];
            if(0 <= nx && nx < h && 0 <= ny && ny < w && !g[nx][ny] && d[nx][ny][p.dir]>p.d+1) {
                d[nx][ny][p.dir] = p.d+1;
                q.offer(new P(nx, ny, p.dir, p.d+1));
            }
        }
        long min = d[x2][y2][0];
        min = Math.min(min, d[x2][y2][1]);
        min = Math.min(min, d[x2][y2][2]);
        min = Math.min(min, d[x2][y2][3]);
        if(min == Long.MAX_VALUE) {
            System.out.println(-1);
        } else {
            System.out.println((min + k - 1) / k);
        }

    }
    static class P implements Comparable<P> {
        int x;
        int y;
        int dir;
        long d;
        P(int x, int y, int dir, long d) {
            this.x = x;
            this.y = y;
            this.dir = dir;
            this.d = d;
        }

        @Override public int compareTo(P o) {
            return Long.compare(d, o.d);
        }
    }


}


Measured memory_bytes: 141024
import math

[n, k] = [int(x) for x in input().split()]

prob = 0

for i in range(n):
    
    num = math.ceil(math.log2(k/(i+ 1)))
    
    if num < 0:
        num = 0
    prob += 1 / n * ((1 / 2) ** num)
    
print(prob)

Measured memory_bytes: 3060
#include <stdio.h>

int main(){
    char op;
    int a, b;
    
    while(scanf("%d %c %d", &a, &op, &b), op != '?'){
        
        switch(op){
        case '+':
            printf("%d\n", a + b);
            break;
        
        case '-':
            printf("%d\n", a - b);
            break;
        
        case '*':
            printf("%d\n", a * b);
            break;
        
        case '/':
            printf("%d\n", a / b);
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 2052
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int ac=0,tle=0,wa=0,re=0;
    for(int i=0;i<n;i++){
      String s=sc.next();
      if(s.equals("AC"))
        ac++;
      if(s.equals("WA"))
        wa++;
      if(s.equals("TLE"))
        tle++;
      if(s.equals("RE"))
        re++;
    }
    System.out.println("AC x "+ac);
    System.out.println("WA x "+wa);
    System.out.println("TLE x "+tle);
    System.out.println("RE x "+re);
  }
}


Measured memory_bytes: 59504
#include<cstdio>
#include<vector>
#include<algorithm>

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

using namespace std;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int h,w,capa,a[20][20];
bool live[20][20];

bool check(int wall){ // 壁の高さの最小値
	bool vis[20][20]={};
	rep(i,h) rep(j,w) if(!vis[i][j] && a[i][j]<wall) {
		vis[i][j]=true;

		int sum=0;
		bool ok=true;
		int Q[20*20],head=0,tail=0;
		Q[tail++]=i*w+j;
		while(head<tail){
			int y=Q[head]/w,x=Q[head]%w; head++;

			if(live[y][x] || y==0 || y==h-1 || x==0 || x==w-1) ok=false;
			sum+=wall-a[y][x];

			rep(k,4){
				int yy=y+dy[k],xx=x+dx[k];
				if(0<=yy && yy<h && 0<=xx && xx<w && !vis[yy][xx] && a[yy][xx]<wall){
					vis[yy][xx]=true;
					Q[tail++]=yy*w+xx;
				}
			}
		}

		if(ok && sum>=capa) return true;
	}

	return false;
}

int main(){
	for(int m;scanf("%d%d%d%d",&h,&w,&capa,&m),h;){
		rep(i,h) rep(j,w) {
			scanf("%d",a[i]+j);
			live[i][j]=false;
		}
		rep(i,m){
			int y,x; scanf("%d%d",&y,&x); y--; x--;
			live[y][x]=true;
		}

		vector<int> as;
		rep(i,h) rep(j,w) {
			as.push_back(a[i][j]);
			as.push_back(a[i][j]+1);
		}
		sort(as.begin(),as.end());
		as.erase(unique(as.begin(),as.end()),as.end());

		rep(i,as.size()){
			if(check(as[i])) goto FOUND;
			rep(y,h) rep(x,w) if(!live[y][x]) {
				a[y][x]++;
				if(check(as[i])) goto FOUND;
				a[y][x]--;
			}
		}

		puts("No");
		continue;

		FOUND:
		puts("Yes");
	}

	return 0;
}

Measured memory_bytes: 1048
#include <iostream>
#include <cassert>
#include <cstring>
#include <vector>
#include <climits>
using namespace std;

vector<long long int> a;
vector<vector<long long int>> dp;
vector<long long int> sum_a;

long long int find(long long int i, long long int j){
    if(dp[i][j]!=-1) return dp[i][j];

    if(i==j){
        dp[i][j] = 0;
    }
    else{
        long long int merge_cost = sum_a[j+1] - sum_a[i];
        long long int out = LLONG_MAX;
        for(int k=i ; k<j ; k++){
            long long int temp = find(i,k) + find(k+1,j) + merge_cost;
            if(temp < out) out = temp;
        }
        dp[i][j] = out;
    }

    return dp[i][j];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    while(t--){
        long long int n;
        cin >> n;
        a = vector<long long int> (n);
        sum_a = vector<long long int> (n+1);
        dp = vector<vector<long long int>> (n,vector<long long int>(n,-1));
        sum_a[0] = 0;
        for(long long int i=0 ; i<n ; i++){
            cin >> a[i];
            sum_a[i+1] = sum_a[i] + a[i];
        }
        long long int output = find(0,n-1);
        cout << output << "\n";
    }
    return 0;
}



Measured memory_bytes: 4520