akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define pb push_back
#define mp make_pair
#define Chkmax(a,b) a=a>b?a:b
#define Chkmin(a,b) a=a<b?a:b
#define mx(a,b) (a>b?a:b)
#define mn(a,b) (a<b?a:b)
typedef unsigned long long uint64;
typedef unsigned int uint32;
typedef long long ll;
using namespace std;

namespace IO
{
    const uint32 Buffsize=1<<15,Output=1<<23;
    static char Ch[Buffsize],*S=Ch,*T=Ch;
    inline char getc()
	{
		return((S==T)&&(T=(S=Ch)+fread(Ch,1,Buffsize,stdin),S==T)?0:*S++);
	}
    static char Out[Output],*nowps=Out;
    
    inline void flush(){fwrite(Out,1,nowps-Out,stdout);nowps=Out;}

    template<typename T>inline void read(T&x)
	{
		x=0;static char ch;T f=1;
		for(ch=getc();!isdigit(ch);ch=getc())if(ch=='-')f=-1;
		for(;isdigit(ch);ch=getc())x=x*10+(ch^48);
		x*=f;
	}

	template<typename T>inline void write(T x,char ch='\n')
	{
		if(!x)*nowps++='0';
		if(x<0)*nowps++='-',x=-x;
		static uint32 sta[111],tp;
		for(tp=0;x;x/=10)sta[++tp]=x%10;
		for(;tp;*nowps++=sta[tp--]^48);
		*nowps++=ch;
	}
}
using namespace IO;

inline void file()
{
#ifndef ONLINE_JUDGE
	freopen("l.in","r",stdin);
	freopen("l.out","w",stdout);
#endif
}

const int MAXN=1e5+7;

static int n,m;
static long long b[MAXN];

inline void init()
{
	read(n);read(m);++m;
	b[1]=n;
	Rep(i,2,m)
	{
		read(b[i]);
		while(i&&b[i]<=b[i-1])b[i-1]=b[i],--i,--m;
	}
}

static long long cnt[MAXN],f[MAXN];

inline void solve()
{
	static long long res;
	static int ps;
	cnt[m]=1;
	Repe(i,m,2)
	{
		cnt[i-1]+=(b[i]/b[i-1])*cnt[i];
		res=b[i]%b[i-1];
		while(res)
		{
			ps=upper_bound(b+1,b+m+1,res)-b-1;
			if(!ps){f[res]+=cnt[i];break;}
			cnt[ps]+=res/b[ps]*cnt[i];
			res%=b[ps];
		}
	}
	f[b[1]]=cnt[1];
	Repe(i,b[1],2)f[i-1]+=f[i];
	Rep(i,1,n)write(f[i]);
	flush();
}

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


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

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//----------------------------------------------------------------------

ll a[200000], b[200000];

int main(void) {
  ll cnta = 0;
  ll cntb = 0;
  cin >> n;

  FOR(i, 0, n) {
	cin >> temp;
	a[i] = temp;
  }

  FOR(i, 0, n) {
	cin >> temp;
	b[i] = temp;
  }

  FOR(i, 0, n) {
	if (b[i] > a[i]) {
	  temp = b[i] - a[i];
	  if (temp % 2 == 0) {
		cnta += temp / 2;
	  }
	  else {
		cnta += temp / 2;
		cnta++;
		cntb++;
	  }
	}
	else {
	  cntb += a[i] - b[i];
	}
  }

  if (cnta >= cntb) {
	cout << "Yes" << endl;
  }
  else {
	cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void){
    int n;
    int i,x,flag;

    scanf("%d",&n);

    for(i=1;i<=n;i++){
        flag=0;
        x=i;
        if(x%3==0){
            printf(" %d",i);
            flag=1;
            continue;
        }
        do{
        if(x%10==3){
            printf(" %d",i);
            flag=1;
        }
        x=x/10;
            if(x==0)
            flag=1;
        }while(flag==0);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    vector<ll>l(n);
    rep(0,i,n)cin>>l[i];
    sort(l.begin(),l.end());
    ll ans=0;
    rep(0,i,n){
        rep(i+1,j,n)ans+=lower_bound(l.begin(),l.end(),l[i]+l[j])-(l.begin()+j+1);
    }
    cout<<ans;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;

bool compare_by_b(pair<int,string> a, pair<int,string> b) {
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second < b.second;
	}
}

int main()
{
	int A,B,C,D;
	string s="Yes";
	cin >> A >> B >> C >> D;
	for(;;){
		C=C-B;
		if(C<=0){
			break;
		}
		A=A-D;
		if(A<=0){
			s="No";
			break;
		}
	}
	cout << s << endl;
}

Measured memory_bytes: 3096
import java.util.*;

class Main {
	static int[] l;
	static int N,A,B,C;
	static int min=2000000000;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
		l = new int[N];
		for (int i=0;i<N;i++) {
			l[i]=sc.nextInt();
		}
		sc.close();
		f(0,0,0,0,0);
		System.out.println(min);
	}
	static void f(int n,int a,int b,int c,int cost) {
		if (n==N) {
			if (a==0 || b==0 || c==0) {
				return;
			}else {
				cost += Math.abs(A-a)+Math.abs(B-b)+Math.abs(C-c)-30;
				min = Math.min(min,cost);
				return;
			}
		}

		f(n+1,a,b,c,cost);
		f(n+1,a+l[n],b,c,cost+10);
		f(n+1,a,b+l[n],c,cost+10);
		f(n+1,a,b,c+l[n],cost+10);
	}
}

Measured memory_bytes: 23508
import numpy as np
def is_prime(n):
    if n == 1: return True

    for k in range(2, int(np.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()                                                                                  
    return divisors

l = map(int, raw_input().split())
A = l[0]
B = l[1]

d_a = make_divisors(A)
d_b = make_divisors(B)

cd = set(d_a) & set(d_b)

#print cd                                                                                              

sum = 0
for item in cd:
    if is_prime(item) == True:
        sum = sum + 1

print sum



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

using namespace std;

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> v(n, 0);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    v[a-1]++;
    v[b-1]++;
  }
  for (int i = 0; i < n; i++) {
    if (v[i] % 2) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
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; }
// const ll INF = 1LL <<60;
const int INF = 10000;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始
int n;

typedef vector<vector<pair<int,int> > > Graph; 
Graph g;

vector<int> res;

void dfs(int i, int p, int c){
  // cout<<"searched:"<<i+1<<endl;
  res[i]=c;
  for(auto a: g[i]){
    if(a.first == p) continue;
    if(a.second%2==0) dfs(a.first,i,c);
    else dfs(a.first,i,1-c); 
  }
  
}

int main(){
  cin>>n;
  g.assign(n,vector<pair<int,int> >());
  for(int i = 0; i < n-1; i++){
    int u,v,w;
    cin>>u>>v>>w;
    u--;
    v--;
    g[u].push_back(make_pair(v,w));
    g[v].push_back(make_pair(u,w));
  }

  res.assign(n,0);
  dfs(0,-1,1);

  for(int i = 0; i < n; i++) cout<<res[i]<<endl;

  return 0;
}


Measured memory_bytes: 8960
def xor_world(A, B):
    if A == 0:
        m  = (B+1) // 2
        pre = 0 if m % 2 == 0 else 1
        if B % 2 == 1: 
            return pre 
        else:
            return pre ^ B
            
    else:   
        return xor_world(0, A-1) ^ xor_world(0, B)
        
        
if __name__ == "__main__":
    A, B = map(int, input().split())
    print(xor_world(A, B))

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

char s[605][605];
int n;

bool check(int x, int y){
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			if (s[i + x][j + y] != s[j + x][i + y]) return false;
		}
	}
	return true;
}

int main(){
	ios::sync_with_stdio(false);
	int ans;
	cin >> n;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++){
			cin >> s[i][j];
			s[i + n][j] = s[i][j + n] = s[i + n][j + n] = s[i][j];
		}
	}
	ans = 0;
	if (check(1, 1)) ans += n;
	for (int p = 2; p <= n; p++){
		if (check(p, 1)) ans += n - p + 1;
		if (check(1, p)) ans += n - p + 1;
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;

int main(){
	int n,m,i,j;
	string a,b;
	scanf("%d %d",&n,&m);
	cin>>a>>b;
	ll gcd = __gcd(n,m);
	ll lcm = ((ll)n*(ll)m) / gcd;	

	ll selisih1 = lcm/n;
	ll selisih2 = lcm/m;
	vi list1,list2;
	for(j=0;j<n;j++){
		list1.pb((ll)j*selisih1);
		// printf("%lld ",j*selisih1);
	}
	// printf("\n");
	for(j=0;j<m;j++){
		list2.pb((ll)j*selisih2);
		// printf("%lld ",j*selisih2);
	}
	// printf("\n");
	vii idxSama;
	for(j=0;j<n;j++){
		int idx = lower_bound(list2.begin(),list2.end(), list1[j]) - list2.begin();
		if(list2[idx] == list1[j]){
			idxSama.pb(ii(j,idx));
			// printf("sama: %lld dan ditemukan di idx: %d %d\n",b[idx], j, idx);
		}
	}
	for(i=0;i<idxSama.size();i++){
		int idx1 = idxSama[i].first, idx2 = idxSama[i].second;
		// printf("idx1: %d idx2: %d\n",idx1,idx2);
		if(a[idx1] != b[idx2]){
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld\n",lcm);
	
	return 0;
};

Measured memory_bytes: 2744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100005];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int len=1,ans=1;
    for(int i=2;i<=n;i++){
        if(a[i]<=a[i-1]) len++;
        else{
            ans=max(ans,len);
            len=1;
        }
    }
    ans=max(ans,len);
    cout<<ans-1<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#ifdef CHECK_

std::vector<int> graph[2048];
int n, k;

void load() {
  n = get<int>();
  k = get<int>();
  for(int i = 1; i < n; ++i) {
    auto s = get<int>();
    auto t = get<int>();
    graph[s].push_back(t);
    graph[t].push_back(s);
  }
}

class countTreeNodes_ {
public:
  std::vector<int> *graph;
  countTreeNodes_(std::vector<int> *graph_) : graph(graph_) {}
  int operator () (int prev, int id, int rem) {
    return dfs(prev, id, rem);
  }
  int dfs(int prev, int id, int rem) {
    if( rem < 0 ) return 0;
    if( rem == 0 ) return 1;
    int res = 1;
    for(int next : graph[id]) {
      if( next == prev ) continue;
      res += dfs(id, next, rem - 1);
    }
    return res;
  }
};
countTreeNodes_ countTreeNodes(graph);

// int dfs(int prev, int id, int rem) {
//   if( rem < 0 ) return 0;
//   if( rem == 0 ) return 1;
//   int res = 1;
//   for(int next : graph[id]) {
//     if( next == prev ) continue;
//     res += dfs(id, next, rem - 1);
//   }
//   return res;
// }

int main() {
  load();
  int res = (1 << 28);
  if( k % 2 == 0 ) {
    for(int i = 1; i <= n; ++i) {
      int m = (int)graph[i].size();
      if( m < 2 ) continue;
      int temp = 1;
      for(int j = 0; j < m; ++j) {
        auto x = countTreeNodes(i, graph[i][j] , k / 2 - 1);
        temp += x;
      }
      res = std::min(res, n - temp);
    }
  }
  else {
    for(int i = 1; i <= n; ++i) {
      for(int j : graph[i]) {
        if( i < j ) continue;
        int temp = 2;
        for(int next : graph[i]) {
          if( next == j ) continue;
          temp += countTreeNodes(i, next, k / 2 - 1);
        }
        for(int next : graph[j]) {
          if( next == i ) continue;
          temp += countTreeNodes(j, next, k / 2 - 1);
        }
        res = std::min(res, n - temp);
      }
    }
  }
  put(res);
  
  return 0;
}

#else

template<typename T>
T get() { return 0; }
template<>
int get() { int x; scanf("%d", &x); return x; }
template<>
long get() { long x; scanf("%ld", &x); return x; }

template<typename T>
void put(T x) {}
template<>
void put(int x) { printf("%d\n", x); }
template<>
void put(long x) { printf("%ld\n", x); }


#define CHECK_
#include __FILE__
#endif



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":"\n");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        //#define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

void solve(int N, int M) {
    vector<vector<int>> gl(N, vector<int>(N, INF));
    vector<vector<int>> gs(N, vector<int>(N, INF));
    REP(i, M) {
        int x, y, t;
        char ls;
        cin >> x >> y >> t >> ls;
        x--, y--;
        if (ls == 'L') {
            gl[x][y] = gl[y][x] = t;
        } else {
            gs[x][y] = gs[y][x] = t;
        }
    }

    REP(i, N) gl[i][i] = gs[i][i] = 0;
    REP(i, N) REP(j, N) REP(k, N) chmin(gl[j][k], gl[j][i] + gl[i][k]);
    REP(i, N) REP(j, N) REP(k, N) chmin(gs[j][k], gs[j][i] + gs[i][k]);

    int R;
    cin >> R;
    vector<int> z(R);
    REP(i, R) {
        cin >> z[i];
        z[i]--;
    }

    vector<vector<int>> dp(R, vector<int>(N, INF));
    function<int(int,int)> rec = [&](int i, int s) {
        auto& DP = dp[i][s];
        if (DP != INF) return DP;
        if (i == R - 1) return DP = 0LL;
        
        int ret = INF;
        int land = gl[z[i]][z[i + 1]] + rec(i + 1, s);
        chmin(ret, land);
        REP(v, N) {
            int sea = gl[z[i]][s] + gs[s][v] + gl[v][z[i + 1]];
            if (sea >= INF) continue;
            sea += rec(i + 1, v);
            chmin(ret, sea);
        }
        return DP = ret;
    };
    cout << rec(0, z[0]) << endl;
}
signed main() {
    while (1) {
        int N, M;
        cin >> N >> M;
        if (N == 0 && M == 0) break;
        solve(N, M);
    }
    return 0;
}




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

const int INF = 2e9;

int main(){
    ll x;
    cin >> x;
    ll ans = x/11;
    x %= 11;
    if(x == 0)cout << ans * 2 << endl;
    else if(x <= 6)cout << ans * 2 + 1 << endl;
    else cout << ans * 2 + 2 << endl;
}


Measured memory_bytes: 256
function main(input) {
  var lines = splitLine(input)
  const N = Number(lines.shift())
  lines[0] = lines[0].split(' ').map(e => Number(e))
  const D = lines[0][0]
  const X = lines.shift()[1]
  lines = lines.map(e => Number(e))
  var eat = lines.map(e => Math.ceil(D / e)).reduce((p, c) => p + c)
  console.log(eat + X)
}

function splitLine(input) {
  var lines = input.split('\n')
  lines.pop()
  return lines
}

(() => {
  process.stdin.resume();
  process.stdin.setEncoding('utf8');
  var input_string = '';
  process.stdin.on('data', chunk => input_string += chunk);
  process.stdin.on('end', () => main(input_string));
})()


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

template <typename T1, typename T2>
bool chmin(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T1, typename T2>
bool chmax(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(const Args&... args) const { print(args...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(const T& head, const Tail&... tail) const { std::cout << head, print_rest(tail...); }
        template <class T, class... Tail>
        void print_rest(const T& head, const Tail&... tail) const { std::cout << sep << head, print_rest(tail...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

ll dp[4][3010][3010];
ll cell[3010][3010];

void solve() {
    ll R, C, K;
    cin >> R >> C >> K;
    for (ll i = 0; i < K; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        cell[a][b] = c;
    }

    for (ll k = 0; k <= 3; k++) {
        for (ll i = 0; i <= R; i++) {
            for (ll j = 0; j <= C; j++) {
                dp[k][i][j] = -L_INF;
            }
        }
    }
    dp[0][0][1] = dp[0][1][0] = 0;

    for (ll i = 1; i <= R; i++) {
        for (ll j = 1; j <= C; j++) {
            for (ll k = 0; k <= 3; k++) {
                if (k > 0) {
                    dp[k][i][j] = max(dp[k][i][j], dp[k - 1][i][j]);
                }
                dp[k][i][j] = max(dp[k][i][j], dp[k][i][j - 1]);
                if (k > 0) {
                    dp[k][i][j] = max(dp[k][i][j], dp[k - 1][i][j - 1] + cell[i - 1][j - 1]);
                }
                if (k == 1) {
                    dp[1][i][j] = max(dp[1][i][j], dp[3][i - 1][j] + cell[i - 1][j - 1]);
                }
            }
        }
    }

    prints()(dp[3][R][C]);
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 356408
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            int[] ab = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int lowA = 0;
            int AandB = 0;
            int highB = 0;

            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            for (int i = 0; i < n; i++)
            {
                if (s[i] <= ab[0])
                {
                    lowA++;
                }
                else if (s[i] > ab[1])
                {
                    highB++;
                }
                else AandB++;
            }
            WriteLine(Min(lowA,Min(AandB,highB)));
        }
    }
}


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

#include <cstdio>

using namespace std;
#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 swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int A[100000];
pair<int, int> CB[100000];

int main()
{
	int N, M, B, C;
	int Ai = 0, Bi = 0, Bcnt = 0;
	ll sum = 0;

	cin >> N >> M;
	rep(i, N) cin >> A[i];
	rep(i, M) {
		cin >> B >> C;
		CB[i] = make_pair(C, B);
	}

	sort(A, A + N);
	sort(CB, CB + M);

	Bi = M - 1;

	while (Ai < N && Bi >= 0 && Bcnt < N) {
		rep(j, CB[Bi].second) {
			if (A[Ai] < CB[Bi].first) {
				A[Ai] = CB[Bi].first;
				Ai++;
			}
			Bcnt++;
		}
		Bi--;
	}

	rep(i, N) sum += A[i];

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	ll r,d,x;
	cin>>r>>d>>x;
	rep(i,10){
		x=r*x-d;
		cout<<x<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import heapq
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p=p[:x]
q=q[:y]
heapq.heapify(p)
heapq.heapify(q)
for i in range(c):
  pp=heapq.heappop(p)
  pq=heapq.heappop(q)
  if pp<r[i] and pq>=r[i]:
    heapq.heappush(p,r[i])
    heapq.heappush(q,pq)
  elif pp>=r[i] and pq<r[i]:
    heapq.heappush(q,r[i])
    heapq.heappush(p,pp)
  elif pp<r[i] and pq<r[i]:
    if r[i]-pp>=r[i]-pq:
      heapq.heappush(p,r[i])
      heapq.heappush(q,pq)
    else:
      heapq.heappush(q,r[i])
      heapq.heappush(p,pp)
  else:
    heapq.heappush(q,pq)
    heapq.heappush(p,pp)
print(sum(p)+sum(q))

Measured memory_bytes: 23528
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<algorithm>
#define f first
#define s second
#define pb push_back
using namespace std;
typedef long long ll;
int main(){	
	string s;
	cin>>s;
	bool flag=1;
	if(s.length()&1) flag=0;
	for(int i=0;i<s.length();i+=2) if(s[i]!='h'||s[i+1]!='i') flag=0;
	printf("%s",flag?"Yes":"No");
}


Measured memory_bytes: 256
import sys
n=int(input())
if n==2:
  print(-1)
  sys.exit()
if n==3:
  print('aa.')
  print('..a')
  print('..a')
  sys.exit()

x=(n//4)-1
y=(n%4)+4

l=[[['a','a','b','c'],['d','d','b','c'],['b','c','a','a'],['b','c','d','d']],[['a','a','b','b','a'],['b','c','c','.','a'],['b','.','.','c','b'],['a','.','.','c','b'],['a','b','b','a','a']],[['a','a','b','c','.','.'],['d','d','b','c','.','.'],['.','.','a','a','b','c'],['.','.','d','d','b','c'],['b','c','.','.','a','a'],['b','c','.','.','d','d']],[['a','a','b','b','c','c','.'],['d','d','.','d','d','.','a'],['.','.','d','.','.','d','a'],['.','.','d','.','.','d','b'],['d','d','.','d','d','.','b'],['.','.','d','.','.','d','c'],['.','.','d','.','.','d','c']]]

if n<8:
  for i in range(n):
    print(''.join(l[n-4][i]))
  sys.exit()

ans=[]
for i in range(n):
  ans1=['.']*n
  ans.append(ans1)

for i in range(x):
  for j in range(4):
    for k in range(4):
      ans[i*4+j][i*4+k]=l[0][j][k]

for j in range(y):
  for k in range(y):
    ans[x*4+j][x*4+k]=l[y-4][j][k]

for i in range(n):
  print(''.join(ans[i]))

Measured memory_bytes: 12020
#include "stdio.h"

int main(void) {
  int x;
  int A;
  int B;
  int nokori;
  int cnt;
  
  scanf("%d", &x);
  scanf("%d", &A);
  scanf("%d", &B);

  nokori = x - A;
  cnt = 0;
  
  do{
      cnt++;
  }while ((B*cnt) <= nokori);
  
  cnt = cnt - 1;
  
  nokori = x - A - (B*cnt);
  printf("%d\n", nokori);
  
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main() {
	long long int a, b, c, d, Cmax, Cmin, Dmax, Dmin;
	long long int ans;
	long long int Emax, Emin;
	cin >> a >> b >> c >> d;
	Cmax = b / c;
	Cmin = a / c;
	if (a % c == 0) {
		Cmin--;
	}
	Dmax = b / d;
	Dmin = a / d;
	if (a % d == 0) {
		Dmin--;
	}
	//公約数 E
	long long int L=0,g=c,m,n;
	if (c > d) {
		m = c;
		n = d;
	}
	else {
		m = d;
		n = c;
	}

	while (m % n != 0) {
		g = m % n;
		m = n;
		n = g;
	}

	L = c * d / g;
	Emax = b / L;
	Emin = a / L;
	if (a % L == 0) {
		Emin--;
	}
	ans = (b - a + 1) - (Cmax - Cmin) - (Dmax - Dmin) + (Emax - Emin);

	cout << ans << endl;
	return 0;
	
}

Measured memory_bytes: 256
X, Y = map(int, input().split())
Mod = 10 ** 9 + 7

def modpow(a, r, mod):
  k = 1
  for i in bin(r)[2:]:
    k = k ** 2 * a ** int(i)
    k %= mod
  return k

def fac(x, mod):
  k = 1
  for i in range(x):
    k *= i + 1
    k %= mod
  return k

def invfac(x, mod):
  k = modpow(fac(x, mod), mod-2, mod)
  return k  
  
def combi(n, r, mod):
  k = invfac(r, mod) * invfac(n-r, mod) * fac(n, mod)
  k %= mod
  return k
  
  
p = (2 * X - Y) // 3
q = (2 * Y - X) // 3
if (X + Y) % 3 != 0 or p < 0 or q < 0:
  print(0)
else:
  print(combi(p+q, p, Mod))
  


Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
	int A,B,T,ans=0,i=1;
	scanf("%d %d %d",&A,&B,&T);
	for(;A*i<=T+0.5;i++){
		ans=ans+B;
	}
	printf("%d",ans);
	return 0;
}
	

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


int main() {
 int n;
 cin>>n;
 
  
  if(n % 2==0){
  cout <<"0.500000000000"<<endl;
  }
  if(n % 2!=0){
  double i=(n+1)/2;
    cout << fixed << setprecision(10);
    cout << i / n <<endl;
  
  }

}

Measured memory_bytes: 3776
#include <iostream>

using namespace std;

unsigned long long q,h,s,d;
unsigned long long n;

int main()
{
    cin>>q>>h>>s>>d>>n;
    if(2*q<h)
        h=2*q;
    if(2*h<s)
        s=2*h;
    if(2*s<d)
        d=2*s;
    cout<<(n/2)*d+(n%2)*s;
    return 0;
}


Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def No(): print('No')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime


def prime_factorize(n):
    res = []
    for i in range(2, int(n**0.5)+1):
        if n % i != 0: continue
        ex = 0

        while (n % i == 0):
            ex += 1
            n //= i
        res.append((i, ex))
    if n != 1: res.append((n, 1))
    return res

N = iin()
ex = [0 for _ in range(N+1)]
for i in range(2, N+1):
    pf = prime_factorize(i)
    for p in pf:
        ex[p[0]] += p[1]
ans = 1
for i in range(2, N+1):
    ans *= ex[i]+1
    ans %= MOD
print(ans)

Measured memory_bytes: 6056
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int a[20][20];
int c[20];

int main(){
  int n, m, x;
  cin >> n >> m >> x;
  for(int i = 0; i < n; ++i){
  	cin >> c[i];
  	for(int j = 0; j < m; ++j){
  		cin >> a[i][j];
  	}
  }

  int ans = INF;
  for(int b = 0; b < (1 << n); ++b){
  	vector<int> comprehension(m, 0);
  	int cost = 0;
  	for(int i = 0; i < n; ++i){
  		if((b >> i) & 1){
  			cost += c[i];
  			for(int j = 0; j < m; ++j){
  				comprehension[j] += a[i][j];
  			}
  		}
  	}
  	sort(comprehension.begin(), comprehension.end());
  	if(comprehension[0] >= x)ans = min(ans, cost);
  }

  if(ans == INF)cout << -1 <<  endl;
  else cout << ans << endl;
  return 0;
}


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

using namespace std;

long long n, ans;

int main()
{
  cin >> n;
  if (n % 2 == 1)
    cout << 0;
  else {
    long long p = 5;
    while (n / p > 0) {
      ans += n / (2 * p);
      p *= 5;
    }
    cout << ans;
  }
  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[] A = new int[3];
        for (int i=0; i<3; i++) {
            A[i] = sc.nextInt();
        }
        Arrays.sort(A);
        for (int i=0; i<3; i++) {
            System.out.print(A[i]);
            if (i == 0 || i == 1)
                System.out.print(" ");
        }
        System.out.println();
    }
}


Measured memory_bytes: 26328
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define MAX 200

void initialize(void);
int isEmpty(void);
int isFull(void);
void push(int);
int pop();

int top;
int S[MAX];

int main(){
  int x, a, b;
  char s[MAX];

  initialize();
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a = pop();
      b = pop();
      push(a+b);
    }
    else if ( s[0] == '-' ){
      a = pop();
      b = pop();
      push(b-a);
    }
    else if ( s[0] == '*' ){
      a = pop();
      b = pop();
      push(a*b);
    }
    else {
      x = atoi(s);
      push(x);
    }
  }

  printf("%d\n", S[1]);

  return 0;
}

void initialize() {
  top = 0;
}

int isEmpty() {
  return top == 0;
}

int isFull () {
  return top >= MAX-1;
}

void push(int x) {
  if(isFull()) {
    printf("error\n");
  }
  top++;
  S[top] = x;
}

int pop(void) {
  if(isEmpty()) {
    printf("error\n");
  }
  top--;
  return S[top+1];
}

Measured memory_bytes: 548
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

using namespace std;

int main()
{
    const char *YES = "YES";
    const char *NO = "NO";

    int a, b, c;
    if (scanf("%d%d%d", &a, &b, &c) < 3) return 0;

    printf("%s\n", ((b - a) == (c - b)) ? YES : NO);
    return 0;
}


Measured memory_bytes: 128
program all_you_can_eat
  implicit none
  integer :: n, t, x(3000,2) = 0, dp(0:6000) = 0, i, j
  read(*,*) n, t
  do i = 1, n
    read(*,*) x(i,:)
  end do
  call merge_sort(x(1:n,:))
  do i = 1, n
    do j = 6000, x(i,1), -1
      if (j-x(i,1) < t) dp(j) = max(dp(j),dp(j-x(i,1))+x(i,2))
    end do
  end do
  write(*,'(i0)') maxval(dp)
contains
  subroutine merge_sort(a)
    integer, intent(inout) :: a(:,:)
    integer :: n, m, l, i, u
    n = size(a,1)
    m = n
    l = 1
    do while (m > 1)
      do i = 1, m/2
        u = min(2*i*l,n)
        call merger(a(2*(i-1)*l+1:(2*i-1)*l,:),a((2*i-1)*l+1:u,:))
      end do
      l = 2*l
      m = (m+1)/2
    end do
  end
  subroutine merger(a1,a2)
    integer, intent(inout) :: a1(:,:), a2(:,:)
    integer :: a(size(a1,1)+size(a2,1),size(a1,2))
    integer :: i1, i2, n1, n2
    i1 = 1
    i2 = 1
    n1 = size(a1,1)
    n2 = size(a2,1)
    do while (i1 <= n1 .and. i2 <= n2)
      if (a1(i1,1) < a2(i2,1) .or. &
      & (a1(i1,1) == a2(i2,1) .and. a1(i1,2) <= a2(i2,2))) then
        a(i1+i2-1,:) = a1(i1,:)
        i1 = i1+1
      else
        a(i1+i2-1,:) = a2(i2,:)
        i2 = i2+1
       end if
    end do
    if (i1 <= n1) then
      a(i1+i2-1:n1+n2,:) = a1(i1:n1,:)
    else
      a(i1+i2-1:n1+n2,:) = a2(i2:n2,:)
    end if
    a1 = a(1:n1,:)
    a2 = a(n1+1:n1+n2,:)
  end
end program all_you_can_eat

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func init() {
	sc = bufio.NewScanner(os.Stdin)
	buffsize := 1000000
	buff := make([]byte, buffsize)
	sc.Buffer(buff, buffsize)
	sc.Split(bufio.ScanWords)
}

func loadint() (result int) {
	sc.Scan()
	result, _ = strconv.Atoi(sc.Text())
	return
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func check(N, x, y int, xs, ys, hs []int) int {
	result := -1
	for i := 0; i < N; i++ {
		if hs[i] > 0 {
			d := abs(x-xs[i]) + abs(y-ys[i])
			if result > 0 && result != d+hs[i] {
				return 0
			}
			result = d + hs[i]
		}
	}
	for i := 0; i < N; i++ {
		if hs[i] == 0 {
			d := abs(x-xs[i]) + abs(y-ys[i])
			if result > 0 && result > d+hs[i] {
				return 0
			}
		}
	}
	return result
}

func main() {
	N := loadint()
	xs := make([]int, N)
	ys := make([]int, N)
	hs := make([]int, N)
	for i := 0; i < N; i++ {
		xs[i] = loadint()
		ys[i] = loadint()
		hs[i] = loadint()
	}
	cx, cy, ch := 0, 0, 0
LOOP:
	for x := 0; x <= 100; x++ {
		for y := 0; y <= 100; y++ {
			h := check(N, x, y, xs, ys, hs)
			if h > 0 {
				cx, cy, ch = x, y, h
				break LOOP
			}
		}
	}
	fmt.Println(cx, cy, ch)
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <climits>
#include <queue>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
template<typename T1, typename T2>
inline void chmin(T1& a, T2 b){if (a > b) a = b;}
template<typename T1, typename T2>
inline void chmax(T1& a, T2 b){if (a < b) a = b;}
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

//(1個の皿の枚数, 2個の皿の枚数, 3個の皿の枚数)の状態から(0,0,0)になるまでの操作の回数の期待値
double dp[310][310][310];
int N;

//漸化式が複雑なのでメモ化再帰(貰うDP)で
//(0,0,0)から初期状態に進む方向だと末端がわかりにくい(到達不可能な状態に行ってしまう)ので
//初期状態から(0,0,0)に進む方向で

//貰うDP
double rec(int i, int j, int k) {
	//到達済みなら飛ばす(doubleなので不等式条件にする)
	if (dp[i][j][k] >= 0.0) return dp[i][j][k];

	
	double ex = 0.0;
	double a;
	a = (double)i + (double)k + (double)j;
	//貰う(i,j,kから遷移できる状態へ向かう)
	if (i > 0)
		ex += (  rec(i-1, j, k) + ((double)N/a)  ) * (double)i / a; //(行き先の期待値+どこかに遷移するまでの期待値)について、重み付き平均をとる
	if (j > 0)
		ex += ( rec(i+1, j-1, k) + ((double)N / a) ) * (double)j / a;
	if (k > 0)
		ex += ( rec(i, j+1, k-1) + ((double)N / a) ) * (double)k / a;

	dp[i][j][k] = ex;
	return ex;
	
}

int main()
{
	cin >> N;
	vector<int> a(N);
	vector<int> init(4, 0); //i個の皿の枚数
	rep(i, N) {
		cin >> a[i];
		init[a[i]]++;
	}

	//未到達(-1)で初期化
	rep(i, N+1) {
		rep(j, N+1) {
			rep(k, N + 1)
				dp[i][j][k] = -1.0;
		}
	}

	double ans;
	ans = rec(init[1], init[2], init[3]);
	printf("%.10lf\n", ans);

	/*rep(i, N + 1) {
		rep(j, N + 1) {
			rep(k, N + 1)
				if(dp[i][j][k] >= 0.0)printf("%d %d %d %d:%lf\n", N-i-j-k, i, j, k, dp[i][j][k]);
		}
	}*/
}

Measured memory_bytes: 227584
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
vint adj[1001];
bool seen[1001],finished[1001];
bool exist[1001][1001];
int pos=-1;
vint hist;
int dfs(int v,int p){
	seen[v]=1;
	hist.push_back(v);
	int flag=0;
	rep(i,(int)hist.size()-2){
		if(exist[hist[i]][hist.back()]){
			flag=1;
			break;
		}
	}
	for(int i=1;i<(int)hist.size()-1;i++){
		if(exist[hist.back()][hist[i]]){
			flag=1;
			break;
		}
	}
	/*printf("flag:%d  ",flag);
	rep(i,hist.size()){
		printf("%d ",hist[i]+1);
	}
	kaigyo;*/
	if(flag){
		hist.pop_back();
		finished[v]=1;
		return 0;
	}
	if(exist[hist.back()][hist[0]]){
		pos=hist[0];
		return 1;
	}
	for(auto nv:adj[v]){
		if(nv==p) continue;
		if(finished[nv]) continue;
		if(seen[nv]&& !finished[nv]){
			pos=nv;
			return 1;
		}
		dfs(nv,v);
		if(pos!=-1) return 1;
	}
	hist.pop_back();
	finished[v]=1;
	return 0;
}
int main(){
	int N,M,A[2002],B[2002];
	scan(N>>M);
	rep(i,M){
		scan(A[i]>>B[i]);
		A[i]--; B[i]--;
		adj[A[i]].push_back(B[i]);
		exist[A[i]][B[i]]=1;
	}
	rep(i,N){
		fill(seen,seen+N,0);
		fill(finished,finished+N,0);
		pos=-1;
		if(dfs(i,-1)==1){
			prin(hist.size());
			rep(j,hist.size()){
				prin(hist[j]+1);
			}
			return 0;
		}
	}
	prin(-1);
	return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main(){
	char kigou[5];
	int num=0;
	scanf("%s",kigou);
	for(int i=0;i<4;i++){
		if(kigou[i]=='+'){
			num++;
		}
		else{
			num--;
		}
	}
	printf("%d\n",num);
	return 0;
}

Measured memory_bytes: 128
N,Q=map(int,input().split())
S=input()
t=[0]*(N+1)
for i in range(N):
    t[i+1]=t[i]+(1 if S[i:i+2]=='AC' else 0)
for i in range(Q):
    l,r=map(int,input().split())
    print(t[r-1]-t[l-1])

Measured memory_bytes: 7748
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int R;
    cin >> R;
    cout << ( R < 1200 ? "ABC" : R < 2800 ? "ARC" : "AGC" ) << endl;
    return 0;
}

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

typedef struct{
  char mark;
  int num;
}card;
void Bubblesort(card*);
void Selectionsort(card*);
void isStable(card*);

int n;
card C[36];

int main(){
  card B[36],S[36];
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c%d",&C[i].mark,&C[i].num);
  }
  for(i=0;i<n;i++){
    strncpy(&B[i].mark,&C[i].mark,1);
    strncpy(&S[i].mark,&C[i].mark,1);
    B[i].num=C[i].num;
    S[i].num=C[i].num;
  }

  Bubblesort(B);
  Selectionsort(S);

  return 0;
}

void Bubblesort(card *C){
  int i,j,num;
  char mark;
  card chg;
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(C[j].num<C[j-1].num){
        chg = C[j];
      C[j] = C[j-1];
      C[j-1] = chg;
      }
    }
  }
  for(i=0;i<n;i++){
    if(i!=0)printf(" ");
    printf("%c%d",C[i].mark,C[i].num);
  }
  printf("\n");
  isStable(C);
}

void Selectionsort(card *C){
  int i,j,minj;
  card chg;
  for(i=0;i<n-1;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(C[j].num<C[minj].num){
        minj=j;
      }}
      chg = C[i];
    C[i] = C[minj];
    C[minj] = chg;
    }
    for(i=0;i<n;i++){
      if(i!=0)printf(" ");
      printf("%c%d",C[i].mark,C[i].num);
    }
    printf("\n");
    isStable(C);
  }


  void isStable(card out[]){
    int i,j,a,b,flag=0;
    for(i=0;i<n;i++){
      for(j=i+1;j<n;j++){
        for(a=0;a<n;a++){
          for(b=a+1;b<n;b++){
            if(C[i].num==C[j].num&&C[i].mark==out[b].mark&&C[i].num==out[b].num&&C[j].num==out[a].num&&C[j].mark==out[a].mark){
              flag=1;
            }
          }
        }
      }
    }
    if(flag==0){
      printf("Stable\n");
    }else{
        printf("Not stable\n");
    }
  }



Measured memory_bytes: 2052
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	N := nextInt()
	ss := make([]int, N)
	var total int
	for i := 0; i < N; i++ {
		ss[i] = nextInt()
		total += ss[i]
	}

	if total%10 != 0 {
		fmt.Println(total)
		return
	}

	minS := 101
	for _, s := range ss {
		if s%10 != 0 {
			minS = min(minS, s)
		}
	}

	if minS == 101 {
		fmt.Println(0)
		return
	}
	fmt.Println(total - minS)
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <queue>
#include <tuple>
#include <stack>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF INT_MAX>>1 
#define SIZE 100001;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

typedef long long ll;

using namespace std;

int main(void){
	int n, d; cin >> n >> d;
	if(n%(d*2+1) == 0) cout << n / (d*2+1) << endl;
	else cout << n / (d*2+1) + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import sys
 
def extractMax(A):
    x = A[0]
    A[0] = A[-1]
    A.pop()
    H = len(A)
    i = 0
    while i < H: # ???????????????
        v = A[i]
        rv = 0
        lv = 0
        r = (i+1) * 2
        l = r - 1
        if l < H:
            lv = A[l]
            if r < H:
                rv = A[r]
 
        if v < lv and lv > rv:
            A[l] = v
            A[i] = lv
            i = l
        elif v < rv:
            A[r] = v
            A[i] = rv
            i = r
        else:
            break
    return x
 
def insert(A, n):
    i = len(A)
    A.append(n)
    while i > 0: # ???????????????
        p = int((i + 1) / 2) - 1
        v = A[i]
        pv = A[p]
        if pv < v: # ???????????§??????
            A[p] = v
            A[i] = pv
            i = p
        else:
            break
 
def main():
    """ ????????? """
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
 
    end = False
    S = []
    for cmd in cmds: # input()
#        print("cmd:{} S:{}".format(cmd,S))
        if cmd[0] == "i":
            insert(S,int(cmd[7:]))
 
        elif cmd == "extract":
            a = extractMax(S)
            print(a)
 
        elif cmd == "end":
            end = True
            break
 
 
if __name__ == '__main__':
    main()


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	int n;
	cin >> n;
	cout << 180*(n-2) << endl;

	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  string S;
  cin >> S;
  int res = 0;
  int left = 0, right = N - 1;
  while (left < right) {
    while (left < N && S[left] == 'R') {
      left++;
    }
    while (right > -1 && S[right] == 'W') {
      right--;
    }
    if (left >= right) break;
    left++, right--;
    res++;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
int fw[200005];
int n;
int sum(int x){
    int ans =1000000;
    while (x){
        ans = min(ans,fw[x]);
        x -= (x)&(-x);
    }
    return ans;
}
void up(int x,int v){
    while (x <= 2*n+3){
        fw[x] = min(v,fw[x]);
        x += (x)&(-x);
    }
}
int main(){
    string s;
    cin >> s;
    n = s.size();
    int a[n];
    for (int i = 0; i < n; i++) a[i] = s[i]-'a';
    for (int k = 0; k < 26; k++){
        for (int i = 0; i < 200005; i++){
            fw[i] = 1000000;
        }
        int cur = n+1;
        up(cur,-1);
        int last;
        for (int i = 0; i < n; i++){
            last = cur;
            if (a[i] == k) cur++;
            else cur--;
            int p = sum(cur-1);
            if (i-p >= 2){
                printf("%d %d\n",p+2,i+1);
                return 0;
            }
            if (i) up(last,i-1);
        }
    }
    printf("-1 -1\n");
}


Measured memory_bytes: 1792
/*input
4 3 3
2 3 1 1
*/

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

#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
#define      rep(i, n)         for(int i = 0; i < (n); ++i)
#define      FOR(i, a, n)     for(int i = a; i < (n); ++i)
#define      repD(i, a, n)     for(int i = a; i >= (n); --i)

int main(void)
{
  int n; cin>>n;
  cout<<48-n;
  return 0;
}


Measured memory_bytes: 256
s = input()

count1 = s.count(s[0])
count2 = s.count(s[1])
count3 = s.count(s[2])
count4 = s.count(s[3])

if count1 == 2 and count2 == 2 and count3 == 2 and count4 == 2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N,r=0;
	vector<int> p;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int t;
		cin>>t;
		if(t!=i+1)r++;
	}
	cout<<(r>2?"NO":"YES")<<endl;
}

Measured memory_bytes: 256