akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            //cout<<x<<"/"<<y;
            cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////

ll cnt[4];

int main(){fastio
    ll n;cin>>n;
    string s[4]={ "AC", "WA", "TLE", "RE"};
    while(n--){
        string k;cin>>k;
        rep(i,0,3){
            if(k==s[i])cnt[i]++;
        }
    }
    rep(i,0,3){
        cout<<s[i]<<" x "<<cnt[i]<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>

int main(){
  int A, B;

  scanf("%d %d", &A, &B);

  int sum;

  if(A > B) sum = A + A - 1;
  else if(A < B) sum = B + B - 1;
  else sum = A + B;

  printf("%d\n", sum);

  return 0;
}


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

int main(void) {
  int t, L;
  while(cin >> t >> L, t || L) {
    string a = to_string(t);

    int pos[1000000];
    for (int i = 0; i < 1000000; i++) pos[i] = -1;

    int index = 0;
    while (pos[stoi(a)] == -1) {
      pos[stoi(a)] = index++;
      for(int i = a.size(); i < L; i++) a.push_back('0');
      sort(a.begin(), a.end());
      int mini = stoi(a);
      sort(a.begin(), a.end(), greater<int>());
      int maxi = stoi(a);
      int diff = maxi - mini;
      a = to_string(diff);
    }
    cout << pos[stoi(a)] << " " << a << " " << index - pos[stoi(a)] << endl;
  }
  return 0;
}

Measured memory_bytes: 7172
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
    
let nl = readInts()
let n = nl[0]
let l = nl[1]
var valueall=0
for i in 1...n{
  valueall+=(l+i-1)
}
var first=1
for i in 1...n{
  if abs(l+i-1)<abs(l+first-1){
    first=i
  }
}
print(valueall-l-first+1)
  

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

int main()
{
  int64_t N, a;
  cin >> N;
  vector<int64_t> A(N + 1, 0);
  for (int i = 0; i < N - 1; i++)
  {
    cin >> a;
    A.at(a)++;
  }
  for (int i = 1; i <= N; i++)
  {
    cout << A.at(i) << endl;
  }
}

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

#define speed ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define test ll t; cin>>t; while(t--)
#define ll long long
#define endl "\n"
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define PI 3.1415926535897932384626
#define inf 1e18
#define vll vector<ll>
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define flr(i,a,b) for(ll i=a;i>b;i--)
#define print(v) for(auto i=v.begin();i!=v.end();i++){cout<<*i<<" ";}cout<<"\n";
#define MOD 1000000007

int main()
{
    speed;
 	ll n; cin>> n;
 	vll a(n+1),dp1(n+1,-1),dp2(n+1,-1);
 	map<ll,ll> mp;
 	fl(i,1,n+1) {
 		cin>>a[i]; ++mp[a[i]];
 	}
 	ll sum = 0;
 	for(auto x:mp){
 		--x.ss;
		dp1[x.ff]= (x.ss)*(x.ss-1)/2;
		++x.ss;
		dp2[x.ff]= (x.ss)*(x.ss-1)/2;
		sum+=dp2[x.ff];
	}
 	fl(i,1,n+1){
 		cout<< dp1[a[i]] + sum - dp2[a[i]]<<endl;
 		
 	}
    return 0;
}


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

int main(){
  int n,t,ans=1e9,cost,time,f=0;cin>>n>>t;
  REP(i,n){
    cin>>cost>>time;
    if(time<=t){
      ans=min(ans,cost); 
      f=1;
    }
  }    
  if(f) cout<<ans;
  else cout<<"TLE";
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define testP	 cout << "------------------ test ------------------" << endl;	// 動作確認テスト
#define testX(x) cout << "testout : " << x << endl;	// テストアウト
typedef long long ll;
using namespace std;
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)

// ------------------ ベクター表示 ------------------ //
void printVec(vector<int>& vec) {
	cout << "";
	for (auto it = vec.begin(); it != vec.end(); it++) cout << *it << " ";
	cout << endl;
}

// ------------------ ベクター合計 ------------------ //
int sumVec(vector<int> v) {
	int sum = 0;
	for (size_t i = 0; i < v.size(); i++) sum += v[i];
	return sum;
}

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	int N;
	cin >> N;
	if (N%10 == 3) cout << "bon" << endl;
	else if (N%10 == 0 || N%10 == 1 || N%10 == 6 || N%10 == 8) cout << "pon" << endl;
	else cout << "hon" << endl;

	return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, x, t;
	cin >>n >>x >>t;
	int ans = (n +x-1)/x  *t;
	cout << ans <<"\n";
	return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define MSIZE 52
int h,w;
char inp[MSIZE][MSIZE];
void out(char inp[][MSIZE])
{
    for (int i=1;i<=h;i++)
    {
        for (int j=1;j<=w;j++)
            putchar(inp[i][j]);
        putchar('\n');
    }
}
int judge(char inp[][MSIZE],int posx,int posy)
{
    int ans=0;
    for (int i=posx-1;i<=posx+1;i++)
        for (int j=posy-1;j<=posy+1;j++)
            if (inp[i][j]=='#') ans++;
    return ans;
}
void solve()
{
    getchar();
    int i,j,dat[MSIZE][MSIZE];
    for (i=0;i<=h+1;i++)
        for (j=0;j<=w+1;j++)
        {
            inp[i][j]='.';
            dat[i][j]=0;
        }
    for (i=1;i<=h;i++)
    {
        for (j=1;j<=w;j++)
            inp[i][j]=getchar();
        getchar();
    }
    for (i=1;i<=h;i++)
        for (j=1;j<=w;j++)
            dat[i][j]=judge(inp,i,j);
    for (i=1;i<=h;i++)
        for (j=1;j<=w;j++)
            if (inp[i][j]=='.') inp[i][j]='0'+dat[i][j];
    out(inp);
}
int main()
{
    while(~scanf("%d%d",&h,&w))
        solve();
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[]) {
    double x1, x2, y1, y2;
    double a, b, sq;
    
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    a = x2 - x1;
    b = y2 - y1;
    sq = sqrt(a*a + b*b);
    printf("%.8lf\n", sq);
    
    return 0;
}

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

#define pb push_back
#define ppp pop_back
#define fi first
#define se second
#define pii pair<int,int>

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
   freopen("input.txt", "r", stdin);
#endif
    int n, m, d;
    cin >> n >> m >> d;
    double ans = 0;
    if (d == 0) {
        ans = double(m-1) / double(n);
    }
    else {
        ans = 2.0 * double (n-d) * double (m-1) / double (n) / double (n);
    }
    cout << fixed << setprecision(15);
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-5;
const ll MOD=1e9+7;
template <typename T>
struct Segtree{
    using F=function<T(T,T)>;
    int n;
    vector<T> node;
    const F f;
    const T t;
    Segtree(int n_,const T& t,const F f):t(t),f(f){
        n=1;
        while(n<n_)n<<=1;
        node.assign(2*n,t);
    }
    void update(int k,const T& x){
        k+=n;
        node[k]=x;
        for(k>>=1;k>0;k>>=1){
            node[k]=f(node[k<<1],node[k<<1|1]);
        }
    }  
    T query(int a,int b){//[a,b]->[a,b)
        T vl=t,vr=t;
        int l=a+n,r=b+n+1;
        for(;l<r;l>>=1,r>>=1){
            if(l&1)vl=f(vl,node[l++]);
            if(r&1)vr=f(node[--r],vr);
        }
        return f(vl,vr);
    }
};
int main(){
    int n;cin>>n;
    vector<ll> a(n+10);
    vector<P> h(n);
    for(int i=0;i<n;i++){
        cin>>h[i].first;
        h[i].second=i;
    }
    sort(all(h));
    for(int i=0;i<n;i++)cin>>a[i];
    auto f=[](ll p,ll q){return max(p,q);};
    Segtree<ll> tree(n+10,0,f);
    for(int i=0;i<n;i++){
        int id=h[i].second;
        tree.update(id,tree.query(0,id)+a[id]);
    }
    cout<<tree.query(0,n+1)<<endl;
}   


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

//region Template
#include "ext/pb_ds/assoc_container.hpp"

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int MOD = 1000000007;
using namespace std;
#define finish(x) cout << x; exit(0);
#define fastIO cin.tie(0); cin.sync_with_stdio(false);

void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }

//const string USCAO_TAG = "mountains";
void usaco(const string& USACO_TAG) { setIn(USACO_TAG + ".in"); setOut(USACO_TAG + ".out"); }
/*
template<typename... Args>
void print(Args... args) {
	#ifdef LOCAL
	((std::cout << args << " "), ...);
	cout << endl;
	#endif
}
 */
//endregion

/* Notes:
 * Farah </3
 */

const int MAXN = 1e5 + 5;
const int INF = 2e9;

ll fact[MAXN];

long long modPow(ll p, long long pow){
    long long ans = 1;
    //long long p = 2;
    while(pow){
        if(pow & 1)
            ans = (ans * p) % 1000000007;
        p = (p * p) % 1000000007;
        pow >>= 1;
    }
    return ans;
}
void prec(){
    fact[0] = 1;
    fact[1] = 1;
    for(int i = 2; i < MAXN; i++){
        fact[i] = (fact[i - 1] * i) % MOD;
    }
}

ll nCr(int n, int r){

    if(n < r) return 0;

    ll den = (fact[r] * fact[n - r]) % MOD;

    return (fact[n] * modPow(den, MOD - 2)) % MOD;
}

int main() {
    //usaco("milkvisits");

#ifdef LOCAL
    setIn("in.txt");
    setOut("out.txt");
#endif

    ll n, k;
    cin >> n >> k;

    prec();

    ll a[n];
    ll ans = 0;
    for(int i = 0 ; i < n; i++){
        cin >> a[i];
    }
    sort(a, a + n);
    for(int i = 0 ; i < n; i++){
        ans = (ans + (a[i] * (nCr(i, k - 1)  - nCr(n - i - 1, k - 1) ))) % MOD;
    }
    cout << ans;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
using namespace std;

typedef long long LL;
const LL INF = (LL)1e16;
const int maxn = 100000 + 10;
struct Edge {
    int u,v;
    LL w;
    Edge(int a,int b,LL c):u(a),v(b),w(c) {}
    Edge() {}
};
vector<Edge> G[maxn],P[maxn],graph[maxn],Es;
set<tuple<int,int,int> > s;
map<tuple<int,int,int>,int> cnt;
LL d1[maxn],d2[maxn];
bool visit[maxn];
int n,m;

void dij(int st,vector<Edge>* gra,LL* d) {
    for(int i = 0; i < maxn; i++) d[i] = INF;
    priority_queue<pair<LL,int>,vector<pair<LL,int> >,greater<pair<LL,int> > > q;
    q.push(pair<LL,int>(0,st));
    d[st] = 0;
    while(!q.empty()) {
        pair<LL,int> t = q.top();
        q.pop();
        int u = t.second;
        if(d[u] < t.first) continue;
        for(int i = 0; i < gra[u].size(); i++) {
            Edge& es = gra[u][i];
            if(d[es.v] > d[u] + es.w) {
                d[es.v] = d[u] + es.w;
                q.push(pair<LL,int>(d[es.v],es.v));
            }
        }
    }
}

void dfs(int u,int fa) {
    if(visit[u]) return;
    visit[u] = 1;
    for(int i = 0; i < P[u].size(); i++) {
        Edge& es = P[u][i];
        if(es.v != fa && d1[u] == d1[es.v] + es.w) {
            graph[es.v].push_back(Edge(es.v,u,es.w));
            graph[u].push_back(Edge(u,es.v,es.w));
            dfs(es.v,u);
        }
    }
}

int pre[maxn];
int iscut[maxn];
int low[maxn];
int dfs_clock;

int  tarjan(int u,int fa) {
    int lowu = pre[u] = ++dfs_clock;
    int child = 0;
    for(int i = 0; i < graph[u].size(); i++) {
        int v = graph[u][i].v;
        if(!pre[v]) {
            child++;
            int lowv = tarjan(v,u);
            lowu = min(lowu,lowv);
            if(lowv > pre[u]) {
                s.insert(make_tuple(u,v,graph[u][i].w));
            }
        } else if(pre[v] < pre[u] && v != fa) {
            lowu = min(lowu,pre[v]);
        }
    }
    low[u] = lowu;
    return lowu;
}

int main() {
    scanf("%d %d",&n,&m);
    for(int i = 0; i < m; i++) {
        int u,v;
        LL w;
        scanf("%d %d %lld",&u,&v,&w);
        Es.push_back(Edge(u,v,w));
        cnt[make_tuple(u,v,w)]++;
        G[u].push_back(Edge(u,v,w));
        P[v].push_back(Edge(v,u,w));
    }
    dij(1,G,d1);
    dij(2,P,d2);
    memset(visit,0,sizeof(visit));
    dfs(2,-1);
    tarjan(1,-1);
    for(int i = 0; i < m; i++) {
        int u = Es[i].u,v = Es[i].v;
        LL w = Es[i].w;
        if(d1[v] + d2[u] + w < d1[2]) {
            printf("HAPPY\n");
        } else {
            if(s.count(make_tuple(u,v,w)) && cnt[make_tuple(u,v,w)] == 1) {
                printf("SAD\n");
            } else {
                printf("SOSO\n");
            }
        }
    }
    return 0;
}



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

int main() {
	int n,h;
	cin>>n>>h;
	int arr [n+1];
	arr[0]=0;
	for(int i=1;i<=n;i++){
		int a;
		cin>>a;
		arr[i]=arr[i-1]+a;
	}
	int cou=0;
	for(int i=0;i<=n;i++){
		
		if(arr[i]<=h) cou++;
	}
	cout<<cou<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    int N;
    cin >> N;
    vector<deque<int>> A(N + 1);
    rep(i, N) {
        rep(j, N - 1) {
            int a;
            cin >> a;
            A[i + 1].push_back(a);
        }
    }
    vector<pair<int, int>> vs_pairs;
    ll ans = 0;
    vector<bool> is_pushed(N + 1, false);
    REP(i, 1, N + 1) {
        if (is_pushed[i] == true) continue;
        int v = A[i].front();
        if(A[v].front() == i){
            vs_pairs.push_back(make_pair(i, v));
            is_pushed[i] = true;
            is_pushed[v] = true;
        }
    }

    ll rest = N * (N - 1) / 2;
    rep(k, N * N) {
        ans++;
        ll vs_count = 0;
        ll now_size = 0;
        vector<pair<int, int>> new_vs_pairs;
        vector<bool> is_pushed2(N + 1, false);
        for (auto& vs_pair : vs_pairs){
            rest--;
            A[vs_pair.first].pop_front();
            A[vs_pair.second].pop_front();

            if (A[vs_pair.first].size() > 0) {
                int v = A[vs_pair.first].front();
                if (A[v].front() == vs_pair.first && is_pushed2[v] == false) {
                    new_vs_pairs.push_back(make_pair(vs_pair.first, v));
                    is_pushed2[v] = true;
                    is_pushed2[vs_pair.first] = true;
                }
            }
            if (A[vs_pair.second].size() > 0) {
                int v = A[vs_pair.second].front();
                if (A[v].front() == vs_pair.second && is_pushed2[v] == false) {
                    new_vs_pairs.push_back(make_pair(vs_pair.second, v));
                    is_pushed2[v] = true;
                    is_pushed2[vs_pair.second] = true;
                }
            }
        }
        vs_pairs = new_vs_pairs;
        if (rest == 0) { 
            cout << ans << endl; 
            return 0;
        }
    }
    cout << -1 << endl;
    //cout << ans << endl;
    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int x,n;
    cin>>x>>n;

    if(n==0){
        cout<<x<<"\n";
        return 0;
    }

    vi p(n);
    rep(i,n)cin>>p[i];

    sort(all(p));

    int ans=x,abso=105,idx=0;
    rep(i,102){
        if(p[idx]==i){
            idx++;
            continue;
        }
        if(abs(x-i)<abso){
            abso=abs(x-i);
            ans=i;
        }
    }

    cout<<ans<<"\n";

    return 0;

}

Measured memory_bytes: 3600
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);

	int[][] field = new int[10][10];

	while(sc.hasNext()){

	    String[] line = sc.next().split(",");
	    int x = Integer.parseInt(line[0]);
	    int y = Integer.parseInt(line[1]);
	    int size = Integer.parseInt(line[2]);

	    //·×ÄÌH
	    field[y][x]++;
	    if(x-1>=0){field[y][x-1]++;}
	    if(x+1<10){field[y][x+1]++;}
	    if(y-1>=0){field[y-1][x]++;}
	    if(y+2<10){field[y+1][x]++;}

	    //ÈãÌH
	    if(size>=2){
		if(x-1>=0 && y-1>=0){field[y-1][x-1]++;}
		if(x-1>=0 && y+1<10){field[y+1][x-1]++;}
		if(x+1<10 && y-1>=0){field[y-1][x+1]++;}
		if(x+1<10 && y+1<10){field[y+1][x+1]++;}
	    }

	    //åÌH
	    if(size==3){
		if(x-2>=0){field[y][x-2]++;}
		if(x+2<10){field[y][x+2]++;}
		if(y-2>=0){field[y-2][x]++;}
		if(y+2<10){field[y+2][x]++;}
	    }
	}
	
	int count = 0;//FÌÂ¢Ä¢È¢ªÌ}XÚ
	int max = 0;//1ÔZ¢}XÚÌZ³
	for(int i=0; i<10; i++){
	    for(int j=0; j<10; j++){
		if(field[i][j]==0){count++;}
		if(field[i][j]>max){max = field[i][j];}
	    }
	}
	System.out.println(count);
	System.out.println(max);
    }
}

Measured memory_bytes: 12000
# ARC078C - Splitting Pile (ABC067C)
from itertools import accumulate


def main():
    n = int(input())
    lst = tuple(accumulate(map(int, input().rstrip().split())))
    ans = min(abs(lst[-1] - i * 2) for i in lst[:-1])
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 26088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 string S; cin >> S;
  bool flag = true;
  for(int i = 0; i < (int) S.size(); i++){
    char b = S[i];
    if( i % 2 == 0){
      if( b == 'L'){ flag = false;}}
    else{
      if( b == 'R'){ flag = false;}}
  }
  
  if(flag){ cout << "Yes" << endl;} else{ cout << "No" << endl;}
    return 0;}

Measured memory_bytes: 256
a,b=map(int, input().split())

if a==1 or b==1:
    print(1)
    exit()

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

a_prime=prime_factorize(a)
b_prime=prime_factorize(b)

a_prime=set(a_prime)
b_prime=set(b_prime)

ans=0
for i in a_prime:
    if i in b_prime:
        ans+=1

print(ans+1)

Measured memory_bytes: 62768
from scipy.sparse.csgraph import floyd_warshall
h,w = map(int,input().split())
cost = []
for i in range(10):
  sub = list(map(int,input().split()))
  cost.append(sub)
d = [[float("inf")]*10 for i in range(10)]
L = []
for i in range(10):
    d[i][i] = 0
for i in range(10):
    for j in range(10):
        d[i][j] = cost[i][j]
        d[j][i] = cost[j][i]
d = floyd_warshall(d)
wall = []
for i in range(h):
    cur = list(map(int,input().split()))
    wall.append(cur)
ans = 0
for i in range(h):
    for j in range(w):
        if wall[i][j] != -1:
            ans += d[wall[i][j],1]
print(int(ans))

Measured memory_bytes: 14432
S = input()
T = input()
same = 0
lt = len(T)
ls = len(S)
for i in range(ls-lt+1):
    tot = 0
    for j in range(lt):
        if T[j] == S[i+j]:
            tot += 1
    same = max(same, tot)
print(lt-same)


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

vi g[100005];
bool vis[100005];
int n,m;

 
void dfs (int u){
    if (vis[u]) return ;
    vis[u] = true;
    for (auto &it: g[u]) 
        if (!vis[it]) dfs(it) ; 
}


signed main()
{
    fast ; 
    cin >> n >> m;
    for (int i=0;i<m;i++){
        int a,b; cin>>a>>b;
        g[a].pb(b) ; 
        g[b].pb(a) ; 
    } 
    int ans = 0 ; 
    for (int i=1;i<=n;i++){
        if (!vis[i]){
          ans++;
          dfs(i) ; 
        }
    }
    co ( ans - 1 ) ; 
    return 0;
}


Measured memory_bytes: 10424
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

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

using Facts = map<ll, int>; 
void factrize(ll n, Facts& mp) {
  if(n < 2) return;
  ll m = sqrt(n);
  REP(i, 2, m+1) {
    int cnt = 0;
    while(n%i == 0) {
      n /= i;
      ++cnt;
    }
    if(cnt != 0) mp[i] += cnt;
  }
  if(n != 1) mp[n]++;
}


int main(){
    int n;
    cin >> n;
    Facts f;
    factrize(n, f);
    cout << n << ":";
    for(auto&& p: f) {
        rep(j, p.se) cout << " " << p.fi;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
int main() {
  int X, N; cin >> X >> N;
  if (N==0){
    cout << X << endl;
    return 0;
  }
  
  vi p(N);
  rep(i,N) cin >> p[i]; 
  sort(all(p), greater<int>());

  int ans = 0;
  int aabs = 110;
  
  
  rep2(i, -1, 102){
    if (i==p[(int)p.size()-1]){
      p.pop_back();
      continue;
    }
    int tabs = abs(X-i);
    if( tabs < aabs){
      aabs = tabs;
      ans = i;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  int num[n];
  for( int i=0 ; i<n ; i++ ){
    scanf("%d",&num[i]);
  }
  int ans[n];
  for( int i=n-1 ; i>=0 ; i-- ){
    if( i < n-1 )printf(" ");
    printf("%d",num[i]);
  }
  printf("\n");

}


Measured memory_bytes: 2040
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #
    A,B,C = map(int, input().split())
    K = int(input())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    cnt=0
    while B<=A:
        cnt+=1
        B*=2
    while C<=B:
        cnt+=1
        C*=2
    if cnt<=K:
        print('Yes')
    else:print('No')



if __name__ == "__main__":
    main()

Measured memory_bytes: 72704
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A,*B,k=0;
  int C[VMAX+1];
  int n,i,j;

  scanf("%d",&n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */

  for(i=0;i<=VMAX;i++){
    C[i]=0;
  }

  for(j=0;j<n;j++){
    scanf("%u",&A[j+1]);
    C[A[j+1]]++;
  }

  for(i=1;i<=VMAX;i++){
    C[i]=C[i]+C[i-1];
  }

  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    printf("%u",B[i]);

    if(i<n){
      printf(" ");
    }
  }
  printf("\n");

  return 0;
}


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

int main()
{
	int n;
	cin >> n;
	vector<int> h(n);
	int ans = 1;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int max = h[0];
	for (int i = 1; i <= n - 1; i++) {
		if (max <= h[i] && h[i - 1] <= h[i]) {
			max = h[i];
			ans++;
		}

	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int A,B;
	cin >>A >> B;

	if (A % 2 == 0 || B % 2 == 0) {
	cout << "No" << endl;
	}
	else cout << "Yes" << endl;
}

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

int main()
{
	string s;
	cin >> s;
	int left = 0, right = s.size() - 1,cou=0;
	for(; left < right; left++,right--){
		if(s[left]!=s[right])cou++;
	}	
	cout << cou <<endl;
	return 0;
}	


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, X, T int
	fmt.Scanf("%d %d %d", &N, &X, &T)

	switch {
	case N%X > 0:
		fmt.Println(N/X*T + T)
	default:
		fmt.Println(N / X * T)
	}
}


Measured memory_bytes: 1836
#include <stdio.h>
#include <stdlib.h>
#define NMAX 100
int compare(const void *a, const void *b);
int main(void)
{
  int i, n, a, b, c, d[NMAX];
  double ab, res, ans;
  scanf("%d", &n);
  scanf("%d %d", &a, &b);
  scanf("%d", &c);
  for (i = 0; i < n; i++) scanf("%d", &d[i]);
  qsort(d, n, sizeof(int), compare);
  ab = a;
  ans = c / ab;
  for (i = 0; i < n; i++) {
    res = (c + d[i]) / (ab + b);
    if (res > ans) {
      ans = res;
      c += d[i];
      ab += b;
    } else break;
  }
  printf("%d\n", (int)ans);
}

int compare(const void *a, const void *b)
{
  int ta = *(int*)a, tb = *(int*)b;
  return tb - ta;
}


Measured memory_bytes: 2004
def factorial(x, mod):
    ret = 1
    while x > 0:
        ret = (ret * x) % mod
        x -= 1
    return ret


MOD = 10**9 + 7
N, M = map(int, input().split())

if N == M:
    print((2 * factorial(N, MOD) * factorial(M, MOD)) % MOD)
elif abs(N - M) == 1:
    print((factorial(N, MOD) * factorial(M, MOD)) % MOD)
else:
    print(0)


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

int main()
{
    std::ios_base::sync_with_stdio (false);
    int n;
    cin>>n;
    vector<ll>v(n);
    vector<ll>dp(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    dp[1]=abs(v[1]-v[0]);
    for(int i=2;i<n;i++){
        dp[i]= min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1792
n = int(input())
RC = [list(map(int, input().split())) for _ in range(n)]
R = [RC[i][0] for i in range(n)]
C = [RC[i][1] for i in range(n)]

#n = 6
#R = [30, 35, 15, 5, 10, 20]
#C = [35, 15, 5, 10, 20, 25]

m = [[10**18]*(n+1) for _ in range(n+1)]
for i in range(n+1):
    m[i][i] = 0
    
for l in range(1, n):
    for i in range(1, n+1-l):
        m[i][i+l] = min([m[i][j] + m[j+1][i+l] + R[i-1]*C[j-1]*C[i+l-1] for j in range(i, i+l)])
        #print(i, i+l)
print(m[1][n])


Measured memory_bytes: 5724
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		int[] h=sc.Ia;
		int p=0;
		for(int i = 1;i<n-1;i++) {
			if(h[i-1]<h[i]&&h[i]<h[i+1]){p++;}
			else if(h[i-1]>h[i]&&h[i]>h[i+1]){p++;}
		}
		Console.WriteLine("{0}",p);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int A, B, K;
    cin >> A >> B >> K;

    vector<int> C(2 * K);

    for (int i = 0; i < K; i++){
        if (A + i > B){
            break;
        }
        C[i] = A + i;
    }

    for (int i = K; i < 2 * K; i++){
        if (B - K + 1 + (i - K) < A){
            break;
        }
        C[i] = B - K + 1 + (i - K);
    }

    sort(C.begin(), C.end());
    C.erase(unique(C.begin(), C.end()), C.end());

    int n = C.size();

    for (int i = 0; i < n; i++){
        if (C[i] != 0){
            cout << C[i] << endl;
        }
    }
}

Measured memory_bytes: 256
from sys import stdin

n = int(stdin.readline().rstrip())
char = stdin.readline().rstrip()


al = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
s = ""

for c in char:
    arr_num = int(al.index(c.lower()))

    if  arr_num + n > 25:
        s += al[arr_num + n - 26]
    else:
        s += al[arr_num + n]

print(s.upper())




Measured memory_bytes: 3064
import bisect
S = input()
T = input()
OUT = 10**5

N = len(S)
M = len(T)
indice = [0]*M
# 素直にやるとO(NM)かかるので工夫が必要
A = [[] for _ in range(26)]
for i in range(N):
    A[ord(S[i]) - ord('a')].append(i + 1)

res = 0
b = 0
for j in range(M):
    tj = ord(T[j]) - ord('a')
    if len(A[tj]) == 0:
        print(-1)
        exit()
    r = bisect.bisect_right(A[tj], b)
    if len(A[tj]) > r:
        res += A[tj][r] - b
        b = A[tj][r]
    else:
        res += N - b + A[tj][0]
        b = A[tj][0]

print(res)

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

using namespace std;

typedef long long LL;

int main()
{
	int N;
	LL ans1 = 1,ans2 = 1;
	scanf("%d",&N);
	while(N--)
	{
		int tmp;
		scanf("%d",&tmp);
		ans1 *= 3LL;
		if (tmp%2 == 0)
			ans2 *= 2LL;
	}
	printf("%lld\n",ans1 - ans2);
}

Measured memory_bytes: 256
import kotlin.math.*
import java.util.*

fun main(args: Array<String>) {
  val k = readLine()!!.toInt()
  val (a, b) = readLine()!!.split(' ').map(String::toInt)
  for (i in a / k..b / k) {
    val ki = k * i
    if (a <= ki && ki <= b) {
      println("OK")
      return
    }
  }
  println("NG")
}


Measured memory_bytes: 36312
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		String line = null;
		try(Scanner sc=  new Scanner(System.in)){
			line = sc.nextLine();
		}catch (Exception e) {
			e.printStackTrace();
		}
		String[] tmpArray = line.split(" ");
		int numA = Integer.parseInt(tmpArray[0]);
		int numB = Integer.parseInt(tmpArray[1]);
		int result = 0;
		if(numB % numA == 0){
			result = numA + numB;
		}else{
			result = numB - numA;
		}
		
		System.out.println(result);
	}
}

Measured memory_bytes: 22868
#include <iostream>
#define maxn 10004
using namespace std;
int pos[maxn], posa[maxn], posb[maxn];
string s, ans, f[maxn];
int main(){
	int n;
	cin >> n;
	cin >> s;
	int cnta = 0, cntb = 0;
	for (int i = 0; i < 2 * n; ++ i){
		if (s[i] == 'a'){
			pos[i] = ++ cnta;
			posa[cnta] = i;
		}
		else{
			pos[i] = ++ cntb;
			posb[cntb] = i;
		}
	}
	for (int i = n; i; -- i){
		if (posa[i] < posb[i]){
			int k = i;
			for (int j = posa[i] + 1; j < posb[i]; ++ j)
				k = max(k, pos[j]);
			f[i] = "ab" + f[k + 1];
		}
		else{
			int k = i;
			while (k < n && posb[k + 1] < posa[k])
				++ k;
			for (int j = posb[i]; j < 2 * n; ++ j)
				if (pos[j] >= i && pos[j] <= k)
					f[i] += s[j];
			f[i] += f[k + 1];
		}
		f[i] = max(f[i], f[i + 1]);
		ans = max(ans, f[i]);
	}
	cout << ans << endl;
}


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

using namespace std;

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

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

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

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

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

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

int main() {

	int n, m; cin >> n >> m;

	m += n * 3;

	cout << m / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

/*
int fact(int n)
{

}
*/


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

	ll A, B;
	
	cin >> A >> B ;

	if (abs(A-B) > 1)
	{
		cout << 0 << endl;
	}
	else
	{
		
		ll all = 1;
		for (ll i=2; i <= A; i++)
		{
			all = (all * i) % MOD;
		}

		for (ll i=2; i <= B; i++)
		{
			all = (all * i) % MOD;
		}

		if (A == B)
		{
			all = (all * 2) % MOD;
		}
		cout << all << endl;
	}

	
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n,i;
    cin >> n;
    string taro,hanako;
    int taro_p=0;
    int hanako_p =0;
    for(int i=0;i<n;i++){
        cin >> taro >> hanako;
        if(taro.compare(hanako) ==0){
            taro_p++;
            hanako_p++; 
        }else if(taro.compare(hanako) >0) taro_p +=3;
        else hanako_p +=3;
    }  
    printf("%d %d\n",taro_p,hanako_p);
    return 0;
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define invrep(i, n) for(int i = (n)-1; i >= 0; i--)        // n-1, n-2, ..., 0
#define invREP(i, x, n) for(int i = (n)-1; i >= (x; i--)    // n-1, n-2, ..., x
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define PB push_back

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

int G[10][10] = {{0}};

int main(){
    int N, M; cin >> N >> M;
    rep(i, M){
        int a, b; cin >> a >> b;
        a--; b--;
        G[a][b]= G[b][a] = 1;
    }

    vi v;
    rep(i, N) v.push_back(i);

    int ans = 0;
    do{
        if(v[0] != 0) continue; // 頂点１以外は枝切り
        bool f = true;
        REP(i, 1, N){
            if(!G[v[i]][v[i - 1]]) f = false; // 経路が存在しなければ出る
        }
        if(f) ans++;
    } while(next_permutation(ALL(v)));

    COUT(ans);
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use std::cmp::{max, min};
use rand::random;

#[fastout]
fn main() {
    input! {
    n: usize,
    k: usize,
    v: [i64; n],
    }
    let mut ans = 0;
    for i in 0..=min(n, k) {
        for j in 0..=i {
            let mut l = Vec::new();
            l.extend(v[..j].iter());
            l.extend(v[n - (i - j)..].iter());
            l.sort();
            let mut c = 0;
            for t in 0..min(k - i, l.len()){
                if l[t] >= 0 {break}
                c += 1;
            }
            let tmp = l[c..].iter().sum::<i64>();
            ans = max(ans, tmp)
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2232
/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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")
    };
}

use std::cmp;

fn main() {
    input!(abcd: chars);
    let a = abcd[0] as i64 - '0' as i64;
    let b = abcd[1] as i64 - '0' as i64;
    let c = abcd[2] as i64 - '0' as i64;
    let d = abcd[3] as i64 - '0' as i64;

    let t = vec![(-1, '-'), (1, '+')];
    for &(i, io) in t.iter() {
        for &(j, jo) in t.iter() {
            for &(k, ko) in t.iter() {
                if a + i * b + j * c + k * d == 7 {
                    println!("{}{}{}{}{}{}{}=7", a, io, b, jo, c, ko, d);
                    return;
                }
            }
        }
    }
    unreachable!();
}


Measured memory_bytes: 4352
N, Q = map(int, input().split())
S = input()
LR = [list(map(int, input().split())) for _ in range(Q)]

acc = [0] * N
for i in range(1, N):
    if S[i - 1: i + 1] == 'AC':
        acc[i] = acc[i - 1] + 1
    else:
        acc[i] = acc[i - 1]

res = []
for lr in LR:
    l, r = lr
    res.append(acc[r - 1] - acc[l - 1])

print(*res, sep='\n')

Measured memory_bytes: 73048
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def main():
    X = int(input())
    for k in range(1, 361):
        d, m = divmod(X*k, 360)
        # print(d, m)
        if m == 0:
            print(k)
            return

    return


if __name__ == '__main__':
    main()


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

int main() {
    string S;
    cin >> S;
    if (S == "AAA" || S == "BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256