akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  ll N;
  cin>>N;
  
  vector<ll>a(N);
  vector<ll>date(N);
  ll sum=0;
  rep(i,N){
    
    cin>>a[i];
    sum+=a[i];
    date[i]=sum;
    
  }
  
  //奇数列を正にする
  ll ch=0;
  ll CH=0;
  rep(i,N){
    if(i%2==0){
      if(date[i]+ch<=0){
        
        
        CH+=abs(1-ch-date[i]);
        ch+=1-ch-date[i];
      }
    }
    else{
if(date[i]+ch>=0){
 
  CH+=abs(date[i]+ch+1);
   ch-=date[i]+ch+1;
}
    }
  }

  
    ll ch1=0;
  ll CH2=0;
  rep(i,N){
    if(i%2==0){
      if(date[i]+ch1>=0){
       
        CH2+=abs(date[i]+ch1+1);
         ch1-=date[i]+ch1+1;
      }
    }
    else{
if(date[i]+ch1<=0){
  
  CH2+=abs(1-ch1-date[i]);
  ch1+=1-ch1-date[i];
}
    }
  }
  
  
  cout<<min(CH,CH2)<<endl;
}
    
  

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

using namespace std;
#define X first
#define Y second
#define pb push_back
typedef double db;
typedef long long ll;
typedef pair<int,int> P;
const int MAXN=5e5+10;
P st[MAXN];int top;
int n,m,k,tot,cnt,id[2];P inc[MAXN];

int check(int x,int y)
{
    if(!y) return x;
    if(x==n) return n+y;
    if(y==m) return n+m+(n-x);
    if(!x) return n+m+n+(m-y);
    return -1;
}

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<=k;i++)
    {
        for(int j=0;j<2;j++)
        {
            int x,y;scanf("%d%d",&x,&y);
            id[j]=check(x,y);
        }
        if(id[0]!=-1&&id[1]!=-1)
            cnt++,inc[++tot]=P(min(id[0],id[1]),i),inc[++tot]=P(max(id[0],id[1]),i+k);
    }
    sort(inc+1,inc+tot+1);
    // for(int i=1;i<=tot;i++)
    //     cout<<inc[i].X<<" "<<inc[i].Y<<endl;
    for(int i=1;i<=tot;i++)
        if(inc[i].Y>k)
        {
            if(st[top].Y!=inc[i].Y-k) return puts("NO"),0;
            top--;
        }
        else st[++top]=inc[i];
    puts("YES");
    return 0;
}

Measured memory_bytes: 5888
k,s=map(int,input().split())

l=[]

for i in range(max(0,s-2*k),min(s,k)+1):#xはmax(0,s-2*k)からmin(s,k)までの値をとる
    l.append(min(s-i,k)+1-max(0,s-(i+k)))
    #for j in range(max(0,s-(i+k)),min(s-i,k)+1):
        
#print(l)
print(sum(l))

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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

vector<P> ans;
unsigned int n;

void pr(int a, int b) {
  cout << a << ' ' << b << '\n';
}

void solve2() {
  int k=30;
  while((n&(1<<k))==0) {
    k--;
  }
  auto s=(1<<k); // even
  auto r=(n^s^1); // odd
  pr(n, s);
  pr(n+n, r+n);
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  cin >> n;
  if (__builtin_popcount(n)==1) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;

  for(int i=2; i+1<=n; i+=2) {
    pr(i+1, i);
    pr(i, 1);
    pr(1, i+n+1);
    pr(i+n+1, i+n);
  }
  pr(n+1, 3);
  if (n%2==0) solve2();
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int h, w, d;
  cin >> h >> w >> d;
  vector<pair<int, int>> vp(h*w);
  rep(i, h)rep(j, w){
    int in;
    cin >> in;
    in--;
    vp.at(in) = {i, j};
  }
  vector<int> cost(h*w, 0);
  rep(i, d){
    for(int j = i+d; j < cost.size(); j += d){
      cost.at(j) = cost.at(j-d) + abs(vp.at(j).first - vp.at(j-d).first) + abs(vp.at(j).second - vp.at(j-d).second);
    }
  }

  int qe;
  cin >> qe;
  rep(q, qe){
    int l, r;
    cin >> l >> r;
    l--; r--;
    int ans = cost.at(r) - cost.at(l);
    cout << ans << endl;
  }
  return 0;
}

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

if a > b:
    temp = a
    a = b
    b = temp

if b > c:
    temp = b
    b = c
    c = temp

if a > b:
    temp = a
    a = b
    b = temp

print(str(a) + ' ' + str(b) + ' ' + str(c))

Measured memory_bytes: 7504
<?php
	$output = array();
	while( true ) {
		list( $n, $x ) = explode( ' ', trim( fgets( STDIN ) ) );
		if( 0 == $n && 0== $x ) { break; }
		
		$cnt = 0;
		for( $i=1; $i<$n-1; $i++ ) {
			for( $j=$i+1; $j<$n; $j++ ) {
				for( $k=$j+1; $k<=$n; $k++ ) {
					if( $x == $i+$j+$k ) { $cnt++; }
					
				}
			}
		}
		array_push( $output, $cnt );
    }
	print implode( "\n", $output );
?>

Measured memory_bytes: 6604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
 
int main() {
    string s;
    int K;
    cin >> s >> K;
    vector<string> subStrs;
    int n = s.size();
    for (int i=0; i<n; i++) {
        for (int j=1; j<=5; j++) {
            subStrs.push_back(s.substr(i, j));
        }
    }
    map<string, int> mp;
    rep(i, subStrs.size()) mp[subStrs[i]]++;
    int cnt = 1;
    for(auto p: mp) {
        if (cnt == K) {
            cout << p.first << endl;
            break;
        }
        cnt++;
    }
    return 0;
}

Measured memory_bytes: 2556
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;

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

  long long A[N] = {};
  long long S[N] = {};
  cin >> A[0];
  S[0] = A[0];
  //cout << S[0] << endl;
  for(int i=1;i<N;i++){
    cin >> A[i];
    S[i] = S[i-1] + A[i];
    //cout << S[i] << endl;
  }


  long long P[4] = {};
  int Q[4] = {0,1,2,N-1};

  //cout << Q[0] << " " << Q[1] << " " << Q[2] << " " << Q[3] <<endl;

  long long result = pow(10,15);

  for(int i=1;i<N-2;i++){ //中央の区切り
    Q[1] = i;

    long long left_S = S[Q[1]];
    long long tmp_left = abs( 2 * S[Q[0]] - left_S );
    for(int j=Q[0] + 1; j<i; j++){ //左の区間の区切り
      long long tmp = abs( 2 * S[j] - left_S );
      if(tmp < tmp_left){
        tmp_left = tmp;
        Q[0] = j;
      }else{ // 左の区間の差が開いたらやめる
        break;
      }
    }

    //cout << Q[0] << " " << Q[1] << " " << Q[2] << " " << Q[3] <<endl;

    long long right_S = S[Q[3]] - S[Q[1]];
    long long tmp_right = abs( 2 * ( S[Q[2]] - S[Q[1]] ) - right_S );
    for(int j=Q[2] + 1; j < N-1; j++){ //右の区間の区切り
      long long tmp = abs( 2 * (S[j] - S[Q[1]]) - right_S );
      if(tmp < tmp_right){
        tmp_right = tmp;
        Q[2] = j;
      }else{ // 左の区間の差が開いたらやめる
        break;
      }
    }

    //cout << Q[0] << " " << Q[1] << " " << Q[2] << " " << Q[3] <<endl;

    P[0] = S[Q[0]];
    P[1] = S[Q[1]] - S[Q[0]];
    P[2] = S[Q[2]] - S[Q[1]];
    P[3] = S[Q[3]] - S[Q[2]];
    long long R[6] = {};
    int count = 0;
    for(int i=0;i<4;i++){
      for(int j=i+1;j<4;j++){
        R[count] = abs(P[i] - P[j]);
        count++;
      }
    }

    long long tmp_result = max(R[0],max(R[1],max(R[2],max(R[3],max(R[4],R[5])))));
    if(tmp_result < result) result = tmp_result;

    //cout << Q[0] << " " << Q[1] << " " << Q[2] << " " << Q[3] <<endl;
  }

  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3328
cnt' n ('O':'I':xs) = cnt' (n+1) xs
cnt' n x = n

cnt [] = []
cnt ('I':xs) = 
  let n = cnt' 0 xs
      r = drop (2*n) xs
  in
    n:(cnt r)

cnt ('O':xs) = cnt xs

ans ("0":_) = []
ans (n:_:s:xs) =
  let n' = read n :: Int
      r  = cnt s
      a  = sum $ map (\x -> if x >= n' then (x-n'+1) else 0) r
  in
    a:(ans xs)

main = do
  c <- getContents
  let i = lines c
      o = ans i
  mapM_ print o

Measured memory_bytes: 5824
def minimumMove(n):
    divisors = []
    for i in range(1,int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)

    result_list = [int(x + n/x -2) for x in divisors]
    
    return min(result_list)

input_data = int(input())

print(minimumMove(input_data))

Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    ll h, w, n;
    cin >> h >> w >> n;
    ll a[n], b[n];
    rep(i, n) { cin >> a[i] >> b[i]; }

    map<pair<int, int>, int> m;
    int move[3] = {-1, 0, 1};
    rep(l0, n) {
        rep(l1, 3) {
            rep(l2, 3) {
                if (m[make_pair(a[l0] + move[l1], b[l0] + move[l2])] == 0) {
                    m[make_pair(a[l0] + move[l1], b[l0] + move[l2])] = 1;
                } else {
                    m[make_pair(a[l0] + move[l1], b[l0] + move[l2])]++;
                }
            }
        }
    }

    ll ans[10] = {};
    ll count = (h - 2) * (w - 2);
    for (auto iter = m.begin(); iter != m.end(); iter++) {
        int x = iter->first.first;
        int y = iter->first.second;
        int v = iter->second;

        if (2 <= x && x < h && 2 <= y && y < w) {
            ans[v]++;
            count--;
        }
    }

    ans[0] = count;

    rep(i, 10) { cout << ans[i] << endl; }
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


Measured memory_bytes: 58112
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

int main(){
  int n;
  cin>>n;
  vector<int> vec(n+1);
  rep(i,n){
    int d;
    scanf("%d", &d);
    vec[d]=i;
  }
  set<int> s;
  s.insert(-1);
  s.insert(n);

  long res=0;
  repl(i,1,n+1){
    // 数字iはvec[i]: 0-indexedの場所にある!
    auto low = s.lower_bound(vec[i]); low--;
    auto up  = s.upper_bound(vec[i]);
    res += (long)i*(vec[i] - *low) * (*up - vec[i]);
    s.insert(vec[i]);
  }

  cout<<res<<endl;

  return 0;
}


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

using namespace std;

int main()
{
    int n,c=0;
    string s;

    cin>>n>>s;

    for(int i=0;i<n;i++)
    {
        if(s[i]==s[i+1]){}

        else
        {
            c++;
        }
    }

    cout<<c<<endl;

    return 0;
}


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

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

	vector<int> a(n);

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

	int q;
	cin >> q;

	while (q--)
	{
		int b, e, t;
		cin >> b >> e >> t;

		for (int i = 0; i < e - b; i++) {
			swap(a[b + i], a[t + i]);
		}

	}

	for (int i = 0; i < a.size(); i++) {
		if (i > 0) {
			cout << " ";
		}

		cout << a[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3112
# AtCoder Grand Contest 019
# A - Ice Tea Store

def f(Q,H,S,D,N,M):
    QQ=Q
    QH=H/2
    QS=S/4
    QD=D/8

    if N==0:
        return M

    if N==1:
        if QQ==min(QQ,QH,QS):
            return M+(4*Q)

        if QH==min(QQ,QH,QS):
            return M+(2*H)
        
        if QS==min(QQ,QH,QS):
            return M+(S)
    else:
        if QQ==min(QQ,QH,QS,QD):
            return M+4*Q*N
            
        if QH==min(QQ,QH,QS,QD):
            return M+2*H*N
        
        if QS==min(QQ,QH,QS,QD):
            return M+S*N
        
        if QD==min(QQ,QH,QS,QD):
            if N%2==0:
                return M+(N//2)*D
            else:
                return f(Q,H,S,D,1,M+(N//2)*D)




Q,H,S,D=map(int,input().split())
N=int(input())

print(f(Q,H,S,D,N,0))

Measured memory_bytes: 9296
#include<cstdio>
#define maxn 200005
#define LL long long
int n,a[maxn],l[maxn],r[maxn],st[maxn],tp;
LL ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		while(tp&&a[st[tp]]>=a[i]) tp--;
		l[i]=st[tp]; st[++tp]=i;
	}
	tp=0; st[0]=n+1;
	for(int i=n;i;i--)
	{
		while(tp&&a[st[tp]]>a[i]) tp--;
		r[i]=st[tp]; st[++tp]=i;
	}
	for(int i=1;i<=n;i++) ans+=1ll*a[i]*(i-l[i])*(r[i]-i);
	printf("%lld\n",ans);
}


Measured memory_bytes: 3328
#include<stdio.h>
int main(void){
  int A;
  int B;
  scanf("%d",&A);
  scanf("%d",&B);
  if(A>B){
    printf("%d",A+(A-1));
  }
  if(A==B){
    printf("%d",A+B);
  }
  if(A<B){
    printf("%d",B+(B-1));
  }
}

Measured memory_bytes: 128
def solve():
	import sys
	while 1:
		n = int(raw_input())
		if n==0:
			break
		score_a=0
		score_b=0
		while n>0:
			(a,b)=map(int, raw_input().split())
			if a>b:
				score_a = score_a + a + b
			elif a<b:
				score_b = score_b + a + b
			else:
				score_a = score_a + a
				score_b = score_b + b
			n = n-1
		print score_a, score_b

if __name__ == '__main__':
	solve()

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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = 1000000000 + 7;

long double cal(long double x, long double y) {
	long double sum = ((x * x) * 1ll) + ((y * y) * 1ll);
	return sqrt(sum * 1.0);
}
void solve() {
	long double n, d;
	cin >> n >> d;
	int c = 0;
	for (int i = 0; i < n; i++) {
		long double x, y;
		cin >> x >> y;
		long double res = cal(x, y);
		if (res <= d) c++;
	}
	cout << c << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

ll gcd(ll x, ll y) {
    if (x < y) swap(x, y);
    while(y > 0) {
        ll tmp = x % y;
        x = y;
        y = tmp;
    }
    return x;
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

int main() {
    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

#define in2(N,s,t) rep(i,N){in(s[i] , t[i]);}
#define in3(N,s,t,u) rep(i,N){in(s[i] , t[i] , u[i]);}
using vd = V<double>; using vs = V<string>; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;

using P = pair<int,int>; using vp = V<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
//////////////////

void solve(){
  ins(S);
  int dp[2] , ndp[2];
  dp[0] = 0 , dp[1] = -inf;
  while(S.size()){
    trc(dp[0] , dp[1]);
    ndp[0] = ndp[1] = -inf;
    int cur = S.back() - '0';
    rep(i , 10) rep(f , 2){
      int nf = (cur < i) ? 1 : (cur > i) ? 0 : f;
      //trc(i , f , nf);
      amax(ndp[nf] , dp[f] + i);
    }
    S.pop_back();
    swap(dp , ndp);
  }
  out(dp[0]);
}

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

using namespace std;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T N){cout << N << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
    cout << '[';
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len-1) s << ", ";
	}
    cout << ']';
	return s;
}

int N, M, R;
bool used[10];
vector<int> r(10);
int d[210][210];


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

	cin >> N >> M >> R;

	r.resize(R);
	rep(i, R) cin >> r[i];
	sort(r.begin(), r.end());
	fill_n(*d, 210*210, 1<<29);


	rep(i, M){
	    int a, b, c;
		cin >> a >> b >> c;
		if(d[a][b] > c) d[a][b] = d[b][a] = c;
	}

	for(int k = 1; k <= N; ++k){
	    for(int i = 1; i <= N; ++i){
	        for(int j = 1; j <= N; ++j){
	            if(d[i][j] > d[i][k]+d[k][j]){
					d[i][j] = d[i][k] + d[k][j];
				}
	        }
	    }
	}


	ll res = 1<<29;
	do{
		ll tmp = 0LL;
		for(int i = 0; i < R-1; ++i){
			tmp += d[r[i]][r[i+1]];
		}
		res = min(res, tmp);

	}while(next_permutation(r.begin(), r.end()));
	ppp(res);

    return 0;
}


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

int main() {
    int a, b; cin >> a >> b;
    cout << (max(0, a-(2 * b)));
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main 
{
	static class C implements Comparator<Enemy>
	{

		@Override
		public int compare(Enemy o1, Enemy o2) 
		{
			if(o1.x<o2.x)return -1;
			if(o1.x>o2.x)return 1;
			
			//dummies later
			if(!o1.dummy && o2.dummy)
				return -1;
			if(!o2.dummy && o1.dummy)
				return 1;
			
			return 0;
		}
		
	}
	
	static class Enemy
	{
		long hp;
		long x;
		boolean dummy = false;
		
		public Enemy(long h, long x0, boolean dum)
		{
			hp = h;
			x = x0;
			dummy = dum;
		}
	}

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		long d = sc.nextLong();
		long dmg = sc.nextLong(); //damage
		
		C c = new C();
		PriorityQueue<Enemy> pq = new PriorityQueue<Enemy>(c);
		
		long sustain = 0;
		for(int i = 0; i < n; i++)
		{
			long x = sc.nextLong();
			long h = sc.nextLong();
			pq.add(new Enemy(h, x, false));
		}
		
		long bomb = 0;
		while(!pq.isEmpty())
		{
			Enemy en = pq.poll();
			
			if(!en.dummy)
			{
				//sustain damage!
				long curhp = en.hp - sustain;
				
				//already dead
				if(curhp <= 0)continue;
				
				long use = curhp/dmg;
				if(curhp%dmg!=0)use++;
				bomb+=use;
				long damage = use*dmg;
				//
				
				sustain += damage;
				pq.add(new Enemy(damage, en.x + (d*2), true));
				
			}
			else
			{
				sustain -= en.hp;
			}
		}

		System.out.println(bomb);
	}

}


Measured memory_bytes: 114324
def f(n):
  res = 0
  s = 0
  for i in range(1, n + 1):
    s += i
    if s <= n:
      res = i
    else:
      break
  return res
n = int(input())
p = 2
ans = 0
while p * p <= n:
  e = 0
  while n % p == 0:
    e += 1
    n //= p
  ans += f(e)
  p += 1
if n > 1:
  ans += 1
print(ans)


Measured memory_bytes: 9192
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<set>
#include<ctime>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
inline void write(long long a){
	if(a>=10)write(a/10);
	putchar('0'+a%10);
}
inline void writeln(long long a){
	write(a); puts("");
}
inline long long read()//不管是正负数，都可以 
{
	long long x = 0; char ch = getchar(); bool positive = 1;
	for (; !isdigit(ch); ch = getchar())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = getchar())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
long long n,p,c[55][55],tong[3],ans;
int main(){
	n=read(); p=read(); c[0][0]=1;
	for(long long i=1;i<=n;i++){c[i][0]=1; for(long long j=1;j<=i;j++)c[i][j]=c[i-1][j-1]+c[i-1][j];}
	for(long long i=1;i<=n;i++)tong[read()%2]++;
	for(long long i=p;i<=tong[1];i+=2){
		for(long long j=0;j<=tong[0];j++){
			ans+=c[tong[1]][i]*c[tong[0]][j];
		}
	}
	write(ans);
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char c;
	while(scanf("%c",&c)!=EOF) {
		if ('A'<=c&&c<='Z') printf("%c",c-'A'+'a');
		else if ('a'<=c&&c<='z') printf("%c",c-'a'+'A');
		else printf("%c", c);
	}
	return 0;
}

Measured memory_bytes: 524
#include <cstdio>
#include <unordered_map>

typedef long long LL;
const int Mod[2] = {999988679, 999988609};
const int B[2] = {370728, 370732};
const int iB[2] = {396903752, 462741403};
const int MN = 250005;

inline void Add(int &x, int y, int i) { x -= (x += y) >= Mod[i] ? Mod[i] : 0; }

int N;
char S[MN];
int A[2][MN], D[2][MN];
std::unordered_map<LL, int> Buk;
LL Ans;

int main() {
	scanf("%d%s", &N, S + 1);
	for (int j = 0; j < 2; ++j) A[j][0] = 0, D[j][0] = 1;
	for (int i = 1, V[2] = {1, 1}; i <= N; ++i) {
		for (int j = 0; j < 2; ++j) {
			A[j][i] = A[j][i - 1];
			if (S[i] == '+') Add(A[j][i], V[j], j);
			if (S[i] == '-') Add(A[j][i], Mod[j] - V[j], j);
			if (S[i] == '>') V[j] = (LL)V[j] * B[j] % Mod[j];
			if (S[i] == '<') V[j] = (LL)V[j] * iB[j] % Mod[j];
			D[j][i] = V[j];
		}
	}
	for (int i = N; i >= 0; --i) {
		Ans += Buk[
			(A[0][i] + (LL)A[0][N] * D[0][i]) % Mod[0] +
			(A[1][i] + (LL)A[1][N] * D[1][i]) % Mod[1] * Mod[0]
		];
		++Buk[A[0][i] + (LL)A[1][i] * Mod[0]];
	}
	printf("%lld\n", Ans);
	return 0;
}

Measured memory_bytes: 24052
#include <bits/stdc++.h>
using namespace std;
 
int main() {
//　宣言
  double a = 0,b = 0,c = 0;
  

//入力    
   cin >> a >> b;
    
//処理
   c = b * 2 - a;
  
//出力
  cout << c << endl;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const long long mod = 1e9+7;
long long power(long long a, long long b, long long m = mod) {
    long long x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
const int N = 100+9;
int a[N][N];
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    
    int n, m; cin >> n >> m;
    vector<vector<int>> f(n+2, vector<int>(m+2, mod));
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            char foo; cin >> foo;
            if(foo == '#') a[i][j] = 1;
            if(i == 1 && j == 1) {
                f[i][j] = a[i][j];
            }
            if(i > 1) {
                if(a[i][j] == a[i-1][j]) {
                    f[i][j] = min(f[i][j], f[i-1][j]);
                } else {
                    f[i][j] = (f[i][j], f[i-1][j] + a[i][j]);
                }
                
            }
            if(j > 1) {
                if(a[i][j-1] == a[i][j]) {
                    f[i][j] = min(f[i][j], f[i][j-1]);
                } else {
                    f[i][j] = min(f[i][j], f[i][j-1] + a[i][j]);
                }
                
            }
        }
    }
    cout << f[n][m] << "\n";




    return 0;
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main() {
    cin>>N;
    vec painted(N, -1);
    painted[0] = 0;
    painted[N-1] = 1;
    mat G(N,vec(0));
    rep(i,N-1){
        cin>>A>>B;
        --A; --B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    queue<P> que;
    que.emplace(0,0);
    que.emplace(N-1,1);
    while(!que.empty()){
        P p = que.front();
        que.pop();
        for(ll to : G[p.fi]){
            if(painted[to] == -1){
                painted[to] = p.se;
                que.emplace(to, p.se);
            }
        }
    }
    ll b,w;
    b = w = 0;
    rep(i,N){
        painted[i] == 1 ? ++w : ++b;
    }
    cout<<(b > w ? "Fennec" : "Snuke")<<endl;
}

Measured memory_bytes: 7296
import java.util.*;
import java.io.*;

public class Main {

	static int vertex;
	static int edges;
	static boolean[] visited;
	static int[] cost;
	static int[] parent;
	static ArrayList<Edge>[] graph;
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static final int INFINITY = Integer.MAX_VALUE;
	static Main obj = new Main();
	static int start;

	class Edge implements Comparable<Edge> {

		int from;
		int to;
		int weight;

		public Edge(int from, int to, int weight) {
			this.from = from;
			this.to = to;
			this.weight = weight;
		}

		@Override
		public int compareTo(Edge other) {
			int diff = weight - other.weight;
			return diff;
		}

	}

	public static void main(String[] args) throws IOException {

		input();
		prim(start);

	}

	@SuppressWarnings("unchecked")
	public static void input() throws IOException {
		StringTokenizer st = new StringTokenizer(br.readLine());
		vertex = Integer.parseInt(st.nextToken());
		edges = Integer.parseInt(st.nextToken());
		start = Integer.parseInt(st.nextToken());
		visited = new boolean[vertex];
		cost = new int[vertex];
		parent = new int[vertex];
		graph = new ArrayList[vertex];
		for (int i = 0; i < graph.length; i++) {
			graph[i] = new ArrayList<Edge>();
		}
		for (int i = 0; i < edges; i++) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				break;
			}
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			int c = Integer.parseInt(st.nextToken());

			graph[a].add(obj.new Edge(a, b, c));

		}
		for (int i = 0; i < cost.length; i++) {
			cost[i] = INFINITY;
		}

	}

	public static void prim(int a) {

		int added = 1;
		visited[a] = true;
		cost[a] = 0;
		PriorityQueue<Edge> pq = new PriorityQueue<Edge>();
		for (Edge e : graph[a]) {
			pq.offer(e);
			cost[e.to] = e.weight;
		}
		while (!pq.isEmpty()) {
			Edge e = pq.poll();
			if (visited[e.to]) {
				continue;
			}
			for (Edge f : graph[e.to]) {
				if (cost[f.to] > f.weight + e.weight) {
					cost[f.to] = f.weight + e.weight;
					parent[f.to] = e.to;
					pq.offer(obj.new Edge(e.to,f.to,cost[f.to]));
				}
			}
			visited[e.to] = true;
			added++;
			if (added == vertex) {
				break;
			}

		}
		for (int i = 0; i < vertex; i++) {
			if (cost[i] == Integer.MAX_VALUE) {
				System.out.println("INF");
			} else {
				System.out.println(cost[i]);
			}
		}

	}

}
/*
 * Edge e = pq.poll(); // if (visited[e.to]) { // continue; // }
 * 
 * if (cost[e.to] >= e.weight + cost[e.from]) { cost[e.to] = e.weight +
 * cost[e.from]; parent[e.to] = e.from; visited[e.to] = true; sum += e.weight;
 * added++; } else { continue; } if (added == vertex) { break; } for (Edge q :
 * graph[e.to]) { if (visited[q.to]) { continue; } else { pq.offer(q); } }
 */

Measured memory_bytes: 125088
// Problem : K - Stones
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_k?lang=en
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define Ma7moud_7amdy                                                                                                  \
    ios_base::sync_with_stdio(false);                                                                                  \
    cin.tie(NULL);                                                                                                     \
    cout.tie(NULL)
#define Open_Sesame Open()
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define watch(x) cout << #x << " = " << x << endl;
#define RT(x) return cout << (x), 0;
#define Accepted 0
typedef long long ll;
typedef vector<int> vi;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
void Open() {
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
const int mod = ll(1e9 + 7), N = 2000 + 5;
//“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent
int n, a[101], k;
int dp[(int) 1e5 + 1][2]; /*
 int mem[(int)1e5 + 1][2];

 bool stones(int rem = k, bool state = 0)
 {

 if (rem == 0)
 return state;

 int &ret = mem[rem][state];
 if (~ret)
 return ret;
 ret = state;

 for (int i = 0; i < n && a[i] <= rem; i++)
 {
 if (state)
 ret &= stones(rem - a[i], !state);
 else
 ret |= stones(rem - a[i], !state);
 }
 return ret;
 }*/
int main() {
	Ma7moud_7amdy
	;
	// Open_Sesame;
	//  clr(mem, -1);
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);

	// cout << (stones() ? "First\n" : "Second\n");

	for (int rem = 0; rem <= k; rem++) {
		int &ret1 = dp[rem][0];
		ret1 = 0;
		int &ret2 = dp[rem][1];
		ret2 = 1;

		for (int i = 0; i < n && a[i] <= rem; i++) {
			ret1 |= dp[rem - a[i]][1];
			ret2 &= dp[rem - a[i]][0];
		}
	}

	cout << (dp[k][0] ? "First\n" : "Second\n");
}


Measured memory_bytes: 4420
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

int n_correct[51] = {};
int pena[51] = {};


bool comp(const int l, const int r);
bool comp(const int l, const int r) {
	if (n_correct[l] > n_correct[r])
		return true;
	else if (n_correct[l] < n_correct[r])
		return false;
	else {
		if (pena[l] < pena[r])
			return true;
		else if (pena[l] > pena[r])
			return false;
		else {

			return l < r;
		}
	}
	
}



int main() {

	while (true) {
		int T, P, R;
		int n_wrong[51][11];
		for (int i = 0; i < 51; i++) {
			for (int j = 0; j < 11; j++) {
				n_wrong[i][j] = 0;
			}
			n_correct[i] = 0;
			pena[i] = 0;
		}
		scanf("%d", &T);
		scanf("%d", &P);
		scanf("%d", &R);
		if (T == 0 && P == 0 && R == 0)
			break;
		for (int i = 0; i < R; i++) {
			int tID, pID, time;
			char msg[20];
			scanf(" %d %d %d %s",&tID,&pID,&time,msg);

			if (msg[0] == 'C') {
				n_correct[tID]++;
				pena[tID] += 1200 * n_wrong[tID][pID] + time;

			}
			else {
				n_wrong[tID][pID]++;

			}
		}

		vector<int> rank;
		for (int t = 1; t <= T; t++) {
			rank.push_back(t);
		}
		sort(rank.begin(), rank.end(), comp);

		for (int i = 0; i < T; i++) {
			printf("%d %d %d\n", rank[i], n_correct[rank[i]], pena[rank[i]]);
		}

	}
}

Measured memory_bytes: 1060
#include<iostream>
#define INF 9999999
using namespace std;
char ch;
int MAP[21][21],mn,MN,a,b,c,d,n,m,w,x,y,z,v[21],u[21];
int compute(int start,int goal){
  for(int i=1;i<=n;i++)v[i]=u[i]=INF;
  v[start]=0;
  while(1){
    mn=INF;
    for(int i=1;i<=n;i++){
      if(v[i]<mn&&u[i]==INF){
	mn=v[i];
	MN=i;
      }
    }
    if(mn==INF)break;
    u[MN]=0;
    for(int i=1;i<=n;i++)if(MAP[MN][i]+v[MN]<v[i])v[i]=v[MN]+MAP[MN][i];
  }
  return v[goal]; 
}
int main(){
  cin>>n>>m;
  
  for(int i=1;i<=20;i++)for(int j=1;j<=20;j++)MAP[i][j]=INF;
  for(int i=1;i<=m;i++){
    cin>>a>>ch>>b>>ch>>c>>ch>>d;
    MAP[a][b]=c;
    MAP[b][a]=d;
  }
  cin>>w>>ch>>x>>ch>>y>>ch>>z;
  cout<<y-z-compute(w,x)-compute(x,w)<<endl;
  return 0;
}

Measured memory_bytes: 1160
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        double d = s.nextInt();
        double t = s.nextInt();
        double sp = s.nextInt();
        double tt = d/sp;
        if(tt<=t)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


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

using namespace std;
typedef long long ll;

int idx[200001];

int main(void) {
    int n, p, ans;
    cin >> n;
    for(int i=0; i<n; i++) {
        scanf("%d", &p);
        idx[p] = i;
    }

    int cnt = 0;
    ans = n - 1;
    for(int i=2; i<=n; i++) {
        if(idx[i-1] < idx[i]) cnt++;
        else {
            ans = min(ans, n - 1 - cnt);
            cnt = 0;
        }
    }
    ans = min(ans, n - 1 - cnt);
    
    return !printf("%d\n", ans);
}

Measured memory_bytes: 1024
import numpy as np

N, L = map(int, input().split())

taste = []
for i in range(N):
  taste.append(L+i)

taste = np.array(taste)

if 0 in taste:
  print(taste.sum())
else:
  if sum(taste) >= 0:
    print(sum(taste) - np.abs(taste).min())
  else:
    print(sum(taste) + np.abs(taste).min())

Measured memory_bytes: 12488
#include<stdio.h>
int main(void){
    int i,Q,c[1000],a[1000],n[1000],count[100]={0};
    scanf("%d",&Q);
    for(i=0;i<Q;i++){
        scanf("%d %d %d",&c[i],&a[i],&n[i]);
    }
    for(i=0;i<Q;i++){
        while(c[i]>0&&a[i]>0&&n[i]>0){
            c[i]=c[i]-1;a[i]=a[i]-1;n[i]=n[i]-1;
            count[i]++;
        }
        while(c[i]>1&&a[i]>0){
            c[i]=c[i]-2;a[i]=a[i]-1;
            count[i]++;
        }
        while(c[i]>2){
            c[i]=c[i]-3;
            count[i]++;
        }
    }
    for(i=0;i<Q;i++){
        printf("%d\n",count[i]);
    }
return 0;
}

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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

const int N = 5,M = 9;
int edge [25] [25];
const int dx [] = {0,1,0,-1};
const int dy [] = {-1,0,1,0};
string d = "URDL";

bool in_range(int y,int x)
{
	return y >= 0 && y < N && x >= 0 && x < N;
}

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

	FOR(i,0,M){
		string s;
		cin >> s;
		FOR(j,0,s.size()) if(s [j] == '1'){
			if(i % 2 == 0){
				edge [(i / 2) * N + j] [(i / 2) * N + j + 1] = true;
				edge [(i / 2) * N + j + 1] [(i / 2) * N + j] = true;
			}
			else{
				edge [(i / 2) * N + j] [(i / 2 + 1) * N + j] = true;
				edge [(i / 2 + 1) * N + j] [(i / 2) * N + j] = true;
			}
		}
	}

	string ans(1,'R');
	int y = 0,x = 1,dir = 1;
	while(y || x){
		for(int i = 3;i <= 6;i++){
			int ny = y + dy [(dir + i) % 4],nx = x + dx [(dir + i) % 4];
			if(in_range(ny,nx) == false || edge [y * N + x] [ny * N + nx] == false) continue;
			y = ny;
			x = nx;
			ans += d [(dir + i) % 4];
			(dir += i) %= 4;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;
#define int long long
const int MOD = 1000000007;

int solve(int a, int b, vector<int> &res) {
	if (a > b) swap(a, b);
	for (int i = 1; i <= a + b - 1; i++) {
		res[i] += min(a, min(i, a + b - i));
	}
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, X, Y;
	cin >> N >> X >> Y;
	int A = X - 1;
	int B = N - Y;
	int C = N - A - B;
	vector<int> res(N, 0);
	int x = (C + 1) / 2;
	int y = C + 1 - x;
	solve(A, x, res);
	solve(A, y, res);
	for (int i = 1; i <= A; i++) {
		res[i]--;
	}
	solve(B, x, res);
	solve(B, y, res);
	for (int i = 1; i <= B; i++) {
		res[i]--;
	}

	solve(A + 1, B + 1, res);
	for (int i = 1; i <= A + 1; i++) {
		res[i]--;
	}
	for (int i = 1; i <= B + 1; i++) {
		res[i]--;
	}

	res[1]++;

	for (int i = 1; i <= C / 2; i++) {
		if (i * 2 < C) {
			res[i] += C;
		} else {
			res[i] += C / 2;
		}
	}

	for (int i = 1; i < A; i++) {
		res[i] += A - i;
	}
	for (int i = 1; i < B; i++) {
		res[i] += B - i;
	}
	for (int i = 1; i < N; i++) {
		cout << res[i] << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  int n;
  cin>>n;
  ll a[n+1];
  map<ll,int>mp;
  a[0]=0;
  mp[0]=1;
  ll ans=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    a[i]+=a[i-1];
    if(mp.find(a[i])!=mp.end()){
      ans+=mp[a[i]];
    }
    mp[a[i]]+=1;
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 14336
#include <stdio.h>

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

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

int n, a[100000];

int gcd(int a, int b) {
    return (a ? gcd(b % a, a) : b);
}

int main() {
    cin >> n;
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    int g = a[0];
    for(int i = 1; i < n; ++i)
        g = gcd(g, a[i]);
    cout << g << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int n, a[N];
int dp[N][2];
int dfs(int pos, int val){
    if(pos == n - 1){
        if(val == 0){
            return a[pos];
        }else{
            return -a[pos];
        }
    }
    int &res = dp[pos][val];
    if(res != -INF){
        return res;
    }
    if(val == 1){
        return res = max(dfs(pos + 1, 1) + a[pos], dfs(pos + 1, 0) - a[pos]);
    }else{
        return res = max(dfs(pos + 1, 0) + a[pos], dfs(pos + 1, 1) - a[pos]);
    }
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        cin >> n;
        for(int i = 0; i < n; i++){
            cin >> a[i];
        }
        for(int i = 0; i < n; i++){
            for(int j = 0; j < 2; j++){
                dp[i][j] = -INF;
            }
        }
        cout << dfs(0, 0) << '\n';
    }
}

Measured memory_bytes: 42752
n, m = map(int, input().split())

r = [False] * n
r[0] = True
l = [1] * n

for _ in range(m):
    x, y = map(int, input().split())
    l[x - 1] -= 1
    l[y - 1] += 1
    if r[x - 1]:
        r[y - 1] = True
    if l[x - 1] == 0:
        r[x - 1] = False

c = 0
for i in range(n):
    if r[i] == True and l[i] > 0:
        c += 1

print(c)


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

int main(){
    int d,t,s;
    cin >> d >> t >> s;
    if(d <= t*s) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 105;
vector<vector<ll>>dp(M);
long long getMax(const vector<vector<int>>&p, int rem, int n){
  if(rem == 0 || n==0){
    if(rem >= p[0][0]) // if rem can hold weight of the last element
      return p[1][0];
    else return 0;
  }
  ll m1 = 0;
  ll m2 = 0;
  if(dp[n][rem] != 0)
    return dp[n][rem];
  if(rem>=p[0][n]){
    m1 = getMax(p, rem-p[0][n], n-1)+p[1][n];
  }
  m2 = getMax(p, rem, n-1);
  dp[n][rem]=max(m1, m2);
  return dp[n][rem];
}

int main(){
  #ifdef LOCAL
	freopen("input.txt","r",stdin);
 // freopen("out.txt","w",stdout);
	#endif
  int n, w;
  cin >> n >> w;
  vector<vector<int>>itms(2, vector<int>(n));
  for(int i=0;i<n;i++){
    cin >> itms[0][i] >> itms[1][i];
    dp[i] = vector<ll>(w+1,0);
  }
  ll ans = getMax(itms, w, n-1);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 81388
#include <iostream>
using namespace std;
int x[100005],y[100005],a[100005],ans;
int main(void){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int num;
        cin>>num;
        a[i]=(i+num)%n;
    }
    for(int i=0;i<n;y[i]=-1,i++)x[i]=-1;
    for(int i=0;i<n;i++){
        int p=i,c=0;
        while(x[p]==-1){
            x[p]=c++;
            y[p]=i;
           p=a[p];
            
        }
        if(y[p]==i)ans+=c-x[p];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4264
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>
#define PI acos(-1)
typedef long long ll;
const long long mod = 1e9 + 7;
const long long maxn = 1e5 + 5; 
using namespace std;

int main()
{
	double R;
	scanf("%lf", &R);
	double ans;
	ans = 2 * PI * R;
	printf("%lf\n", ans);
}

Measured memory_bytes: 3836
PROGRAM ATCODER

implicit none
integer(16) :: n,i,a_sum,t_sum,j,s,s_a,s_t
integer(16),allocatable :: a(:),t(:)

read(*,*) n    !ここが入力欄
allocate(a(n), t(n))

do i = 1, n
  read(*,*) t(i), a(i)
end do

t_sum = 1
a_sum = 1
s = 0

do i = 1,n
  s_a = a_sum/a(i)
  s_t = t_sum/t(i)
  if(mod(a_sum,a(i)) /= 0)then
    s_a = s_a + 1  
  end if
  if(mod(t_sum,t(i)) /= 0)then
    s_t = s_t + 1  
  end if
  s = max(s_a,s_t)
  a_sum = a(i)*s
  t_sum = t(i)*s
end do

! ここに出力結果
write(*,'(i0)') t_sum+a_sum

contains
!!!!!! サブルーチンは↓

!!!!!!

END PROGRAM ATCODER


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

long long n;
vector<long long> a;

int main() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  long long res = a[0];
  for (int i = 1; i < n; ++i) {
    long long tmp = res, cnt = 0;
    res *= a[i];
    if (res > (long long)1e18 || res < a[i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << res << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

const int M = 1e9 + 7, N = 100'010;
ll a[N];

ll binpow(ll x, ll p) {
    ll res = 1;
    while (p) {
        if (p & 1) res = res * x % M;
        p >>= 1;
        x = x * x % M;
    }
    return res;
}

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    ll ans = 0;
    for (int i = k; i >= 1; i--) {
        a[i] = binpow(k / i, n);
        for (int j = 2 * i; j <= k; j += i) a[i] = (a[i] - a[j] + M) % M;
        ans = (ans + a[i] * i) % M;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 4608
#include<cstdio>
#include<cstring>
#include<functional>
#include<algorithm>
using namespace std;
long long int sum[100][21],cnt;
int main(void)
{
	int n,i,j;
	int suu[100];
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&suu[i]);
	for(i=0;i<=n;i++){
		for(j=0;j<21;j++) {
			sum[i][j]=0;
		}
	}
	sum[0][suu[0]]=1;
	for(i=1;i<n-1;i++) {
		for(j=0;j<21;j++) {
			if(j-suu[i]>=0) sum[i][j-suu[i]]+=sum[i-1][j];
			if(j+suu[i]<=20) sum[i][j+suu[i]]+=sum[i-1][j];	
		}
//		printf("\n");
	}
/*	for(i=0;i<21;i++) printf("%d ",i);
	printf("\n");
	for(i=0;i<n;i++) {
		for(j=0;j<21;j++) {
			if(j<=10) printf("%2lld ",sum[i][j]);
			else printf("%2lld ",sum[i][j]);
		}
		printf("\n");
	}*/
	printf("%lld\n",sum[n-2][suu[n-1]]);
	return 0;
}	

Measured memory_bytes: 1044
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define LIM 100005
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define vi vector <int>
#define pb push_back
#define sz(x) x.size()
#define all(x) x.begin(), x.end()


int32_t main()
{
  IOS;
  int t,x,y,k,n,i,j;
  cin>>n;
  int a[n];
  int sum=0;
  for(i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  sum+=a[n-1];
  x=n-2;
  for(i=n-2;i>=0;i--)
  {
      if(x)
      {
          sum+=a[i];
          x--;
      }
      if(x)
      {
          sum+=a[i];
          x--;
      }
      if(x==0)break;
  }
  cout<<sum;
}


Measured memory_bytes: 5216
#include <iostream>
#include <vector>

using namespace std;

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

    for (int i { 0 }; i < 10000; ++i) {
        int num = A * i - (i-1);
        if (num >= B) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 888
n = int(input())
a = list(map(int,input().split()))
flag = 0
for i in range(n):
  if a[i] % 2 == 0:
    if a[i] % 3 != 0 and a[i] % 5 != 0:
      flag = 1
print("APPROVED") if flag == 0 else print("DENIED")

Measured memory_bytes: 38256