akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;

int f(int x) {
    int q = x/10;
    int r = x%10;
    if (r != 0) q++;
    return q*10;
}

int main() 
{
    int a[5];
    rep(i,5) cin >> a[i];
    sort(a, a+5);

    int ans = 10000;
    do {
        int tmp = 0;
        rep(i,4) tmp += f(a[i]);
        tmp += a[4];
        ans = min(ans, tmp);
    } while (next_permutation(a,a+5));
    
    cout << ans << endl;
    return 0;
}


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

ll knapsack(ll W, ll n, ll val[], ll wt[])
{
    ll dp[W+5];
    for(ll i=0; i<W+5; i++)
        dp[i]=0;

    for (ll i=0; i<=W; i++)
    {
        for (ll j=0; j<n; j++)
        {
            if (wt[j] <= i)
            {
                //cout<<dp[i]<<"  ";
                dp[i] = max(dp[i], dp[i-wt[j]]+val[j]);
                //cout<<dp[i]<<endl;
            }
        }

    }
    return dp[W];
}

int main()
{
    ll n,W,val[105],wt[105];
    scanf("%lld %lld",&n,&W);
    for(ll i=0; i<n; i++)
    {
        scanf("%lld %lld",&val[i],&wt[i]);
    }
    printf("%lld\n", knapsack(W, n,val,wt));
    return 0;
}




Measured memory_bytes: 3304
n = int(input())
l = list(map(int,input().split()))
def fun(x):
    return x*(x-1)/2
d ={}
for i in range(n):
    if l[i] in d:
        d[l[i]] +=1
    else:
        d[l[i]] =1
total = 0
for i in d:
    total += fun(d[i])

for i in range(n):
    print(int(total-fun(d[l[i]])+fun(d[l[i]]-1)))

Measured memory_bytes: 26268
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, A[201010], B[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i] >> B[i];
	sort(A, A + N);
	sort(B, B + N);

	int ans = 0;
	if (N % 2 == 0) {
		int AX = A[N / 2] + A[N / 2 - 1];
		int BX = B[N / 2] + B[N / 2 - 1];
		ans = BX - AX + 1;
	}
	else {
		int AX = A[N / 2];
		int BX = B[N / 2];
		ans = BX - AX + 1;
	}
	cout << ans << endl;
}







Measured memory_bytes: 5128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int N,M;
vector <int > T,P,X;





int main()
{

	cin >> N;

	T.resize(N);

	REP(i,N){
		cin >> T[i];
	}

	cin >> M;
	P.resize(M);
	X.resize(M);

	REP(i,M){
		cin >> P[i];
		cin >> X[i];
	}

	REP(i,M){
		int ans = 0;
		REP(j,N){
			if(P[i] -1 == j)
				ans += X[i];
			else
				ans += T[j];

		}
		cout << ans << endl;
		ans = 0;
	}

}






Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N;
  IN(N);
  if(N%2==0) OUT(0.5);
  else{
    OUT((N/2+1.0)/N);
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef long int li;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<float, float> ff;
typedef pair<double, double> dd;
typedef unsigned int ui;
typedef vector<ii> vii;
typedef vector<ff> vff;
typedef set<int> si;
typedef set<lli> slli;
typedef vector<lli> vlli;
typedef long long ll;
typedef long long ll;
typedef vector<ll> vll;
typedef unsigned long long int ulli;
#define MOD 1000000007
#define INF (unsigned)(~0)>>1
typedef pair<int, ii> iii;
void arr_int(int* given_arr, int n){
  for(int i=0;i<n;i++)
    scanf("%d", &given_arr[i]);
}
void solve();
int main(int argc, char const *argv[]){
  solve();
  return 0;
}
void solve(){
  deque<char> s;
  string t;
  cin>>t;
  for(int i=0;i<t.size();i++)
    s.push_back(t[i]);


  int Q;
  cin>>Q;
  bool head = 0;
  for(int i=0;i<Q;i++){
    int T;
    cin>>T;
    if(T == 1){
      head = !head;
    }else{
      int F;
      char c;
      cin>>F>>c;
      if(F==1 && head == 0)
        s.push_front(c);
      else if(F == 1 && head == 1)
        s.push_back(c);
      else if ( F == 2 && head == 0)
        s.push_back(c);
      else
        s.push_front(c);
    }
  }
  if(head)
    reverse(s.begin(), s.end());
  for(char c: s)
    cout<<c;
  cout<<endl;

}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  string s;
  cin >> s;
  int n = s.size();
  if (s[0] == s[n-1]) {
    if (n % 2 == 0) cout << "First" << '\n'; else cout << "Second" << '\n';
  } else {
    if (n % 2 == 1) cout << "First" << '\n'; else cout << "Second" << '\n';
  }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std; 
int n,k,cnt;
struct edg
{
	int x,y;
}edge[10005];
int main()
{
	scanf("%d%d",&n,&k);
	int ans=(n-1)*(n-2)/2;
	if(ans<k)
	{
		printf("-1");
		return 0;
	}
	for(int i=2;i<=n;i++)
		edge[++cnt]=(edg){1,i};
	for(int i=2;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(k-ans) edge[++cnt]=(edg){i,j},k++;
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++)
		printf("%d %d\n",edge[i].x,edge[i].y);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll x, y;
    cin >> x >> y;
    ll ans;
    if(x == 0){
        ans = abs(y);
        if(y < 0){
            ans++;
        }
    }
    else if(y == 0){
        ans = abs(x);
        if(x > 0){
            ans++;
        }
    }
    else{
        ans = abs(abs(x) - abs(y));
        if((x > 0) ^ (y > 0)){
            ans++;
        }
        else{
            if( x > 0 && y < x ){
                ans += 2;
            }
            else if( x < 0 && y < x ){
                ans += 2;
            }
        }
    }

    printf("%lld\n", ans);
}

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

int main(){
	int n;
	string s;
	int coudot=0;
	int nowpo,ans;
	cin>>n>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='.'){
			coudot++;
		}
	}
	nowpo=coudot;
	ans=nowpo;
	for(int i=0;i<n;i++){
		if(s[i]=='.'){
			nowpo--;
		}else{
			nowpo++;
		}
		ans=min(ans,nowpo);
	}
	cout<<ans<<endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t; cin>>s>>t;
    int a,b; cin>>a>>b;
    string u; cin>>u;
    if (u==s) a--;
    else b--;
    cout<<a<<" "<<b<<endl;
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
/*
  l:??????
  r:??????
  h:?????¨????°´???
  w:1?§??????????????°´??????
  lkabe:???????£??????????
  rkabe:???????£??????????
*/
const double EPS = 1e-8; 
struct dat{double l,r,h,w,lkabe,rkabe;};
typedef pair<double,double> P;
typedef pair<P,int> PP;
vector<dat> A;

void Debug2(){cout<<"l r h w lkabe rkabe"<<endl;}
void Debug(dat a){cout<<a.l<<" "<<a.r<<" "<<a.h<<"  "<<a.w<<" "<<a.lkabe<<" "<<a.rkabe<<endl;}
void Debug(){for(int i=0;i<(int)A.size();i++)Debug(A[i]);  }

double getMinTime(){
  double res = 1e9;
  for(dat a:A){
    if(a.w==0)continue;
    double t = ((min(a.lkabe,a.rkabe) - a.h)*(a.r-a.l)*30)/a.w;
    res = min(res,t);
  }
  return res;
}

dat Merge(dat l,dat r){
  //assert(l.h == r.h);
  dat res;
  res.l = l.l;
  res.r = r.r;
  res.h = min(r.h,l.h);
  res.w = l.w + r.w;
  res.lkabe = l.lkabe;
  res.rkabe = r.rkabe;
  return res;
}

bool replace(int idx,int flg){
  A[idx+flg].w += A[idx].w;
  A[idx].w = 0;
  if(abs(A[idx+flg].h-A[idx].h)>EPS) return 0 ;
  if(flg == 1) A[idx] = Merge(A[idx],A[idx+1]);
  if(flg == -1)A[idx] = Merge(A[idx-1],A[idx]);
  A.erase(A.begin()+idx+flg);
  return 1;
}

void adTime(double sec){
  for(int i=0;i<(int)A.size();i++){
    if(A[i].w==0)continue;
    A[i].h += (sec*A[i].w)/(30*(A[i].r-A[i].l));
  }

  int update = 1,cnt=0;  
  while(update){
    update = 0;
    for(int i=0;i<(int)A.size();i++){
      if(A[i].w==0)continue;
      
      if(A[i].lkabe<=A[i].h+EPS){ update=1,replace(i,-1);break;}
      else if(A[i].rkabe<=A[i].h+EPS) { update=1,replace(i,1);break;}
    } 
  }
}

void sim(double t){
  while(t){
    double sec = min(t,getMinTime());
    assert(sec>=0);
    adTime(sec);
    t -=sec;
  }
}


double getH(int x){
  for(int i=0;i<(int)A.size();i++) if(A[i].l<x && x<A[i].r) return A[i].h;
  return -1;
}

int main(){
  int q;
  cin>>q;
  while(q--){
    int n;
    cin>>n;
    A.resize(n+1);
    double l=0,r,lkabe=1e15,rkabe;
    for(int i=0;i<n; i++,l=r,lkabe = rkabe){
      cin>>r>>rkabe;
      A[i] = (dat){l,r,0,0,lkabe,rkabe};
      if(i==n-1) A[n] = (dat){r,100,0,0,rkabe,1e15};
    }
    
    int m;
    cin>>m;
    for(int i=0,x,w;i<m;i++){
      cin>>x>>w;
      for(dat &a:A) if(a.l<x&&x<a.r)a.w+=w;
    }
    int L;
    cin>>L;
    vector<PP> que(L);
    for(int i=0;i<L;i++)cin>>que[i].first.second>>que[i].first.first,que[i].second = i;
    sort(que.begin(),que.end());
    
    vector<double>ans(L);
    int sec=0;
    for(int i=0;i<L;i++){
      double x =que[i].first.second,t = que[i].first.first;
      int idx = que[i].second;
      sim(t-sec);
      ans[idx] = min(50.0,getH(x));
      sec = t;
    }

    for(int i=0;i<L;i++)printf("%.8f\n",ans[i]);
  }
  return 0;
}

Measured memory_bytes: 3348
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int first[1001],second[1001];

int main()
{
	string s;
	while(1){
		getline(cin,s);
		if(s.size() == 0) break;
		stringstream ss(s);
		int number;
		ss >> number;
		++first[number];
	}

	while(cin >> s){
		stringstream ss(s);
		int number;
		ss >> number;
		++second[number];
	}
	for(int i = 0; i < 1001; ++i){
		if(first[i] != 0 && second[i] != 0){
			cout << i << ' ' << first[i] + second[i] << endl;
		}
	}	
}

Measured memory_bytes: 1224
#include<stdio.h>
int main(void){
	int a,b,c,d,x=0;
	scanf("%d %d %d",&a,&b,&c);
	for(x=a;x<=b;x++){
		if(c%x==0){
			d++;
		}
	}
	printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 2752
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)
pp = p[:x]
qq = q[:y]
pq = pp+qq
heapq.heapify(pq)
for rr in r:
    mn = heapq.heappop(pq)
    heapq.heappush(pq, max(mn, rr))
print(sum(pq))

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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for (int a = 0; a <= A; ++a) {
	for (int b = 0; b <= B; ++b) {
	  for (int c = 0; c <= C; ++c) {
		int total = 500*a + 100*b + 50*c; // 合計金額
		if (total == X) ++res; // 合計金額が X に一致したら答えをインクリメント
	  }
	}
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define inf 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back

using namespace std;
typedef pair<int,int> Pair;
typedef long double ld;
typedef long long ll;

const int mod = 998244353, MAX = 1e5, N = 50005;
//template{{{
const long double Pi = 3.14159265358979323846l;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; };
inline void inc(int &x, int y) { x += y; x -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = mul(ans, x);
		x = mul(x, x), y >>= 1;
	} return ans;
}

/*char buf[1<<23],obuf[1<<23],*p1=buf,*p2=buf, *O = obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
void print(int x) {
    if(x > 9) print(x / 10);
    *O++=x%10+'0';
} */

template <class T> inline T	input() {
	T x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

template <class T> inline bool chkmin(T &x, T y) { x = x < y ? x : y; return x == y; }
template <class T> inline bool chkmax(T &x, T y) { x = x > y ? x : y; return x == y; }
template <class T> inline T gcd(T x, T y) { return !y ? x : gcd(y, x % y); }
template <class T> inline T sqrm(T x) { return (ll) x * x % mod; }
template <class T> inline T sqr(T x) { return x * x; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read; //}}}

int n, m;

int main() {
#ifdef local
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	freopen("log", "w", stderr);
#endif

	ios::sync_with_stdio(false);
	cin >> n >> m;
	if (m == 1) cout << 1 << ' ' << 2 << endl;
	else if (n & 1) {
		for (int i = 1; i <= m; ++i)
			cout << i << ' ' << n - i << endl;
	} else {
		int i = 1;
		for (i = 1; i < m; ++i) {
			if (i * 2 - 1 >= n - i + 1 - i) break;
			cout << i << ' ' << n - i + 1 << endl;
		}
		for (; i <= m; ++i)
			cout << i << ' ' << n - i << endl;
	}
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl; 
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a,LL b){LL s=1;while(b>0){if(b&1)s=s*a%mod;a=a*a%mod;b>>=1;}return s;}
LL gcd(LL a,LL b) {return b?gcd(b,a%b):a;}
int dr[2][4] = {1,-1,0,0,0,0,-1,1};
typedef pair<int,int> P;
const int maxn = 200;
int x[maxn],y[maxn];
LL h[maxn];
int main(void)
{
   int n;    
   cin>>n;
   rep(i,0,n)
      cin>>x[i]>>y[i]>>h[i];
   rep(i,0,100+1){
   	rep(j,0,100+1){
   		bool yes = true;
   		LL H = 0;
            rep(k,0,n){
               if(h[k] != 0){
               	H = abs(i-x[k])+abs(j-y[k])+h[k];
               	break;
               }
            }
            rep(k,0,n){
            	
            		if(h[k] != max(H-abs(i-x[k])-abs(j-y[k]),0LL))
            			 yes = false;
           

            }
          if(yes){
          	cout<<i<<" "<<j<<" "<<H<<endl;
          	return 0;
          }
   	  }
   }
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int wa(int n){
    int sum=0;
    while (n>0)
    {
        sum+=n%10;
        n /=10;
    }
    return sum;
}
int main(){
    int A,B,C;
    cin >> A>>B>>C;
    if ((A==7&&B==5&&C==5)||(A==5&&B==7&&C==5)||(A==5&&B==5&&C==7))
    {
        cout << "YES"<<endl;
    }
    else
    {
        cout <<"NO"<<endl;
    }
    
}

Measured memory_bytes: 256
import collections
from statistics import median

n = int(input())
array = list(map(int, input().split()))

for i in range(0, n):
    array[i] = array[i] - (i + 1)
c = collections.Counter(array)
elem = int(c.most_common()[0][0])

# print(c.most_common()[0][0])
# print(array)
# print(elem)
# if c.most_common()[0][1] != 1:
#     # print("test")
#     for j in range(0, n):
#         array[j] = abs(array[j] - elem)
# else:
#     for j in range(0, n):
#         array[j] = abs(array[j])
b = int(median(array))
for j in range(0, n):
    array[j] = int(abs(array[j] - b))

print(sum(array))

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

int main() {
    string str;
    getline(cin, str);
    REP(i, str.size()){
        if (islower(str[i])) cout << (char)toupper(str[i]);
        else if (isupper(str[i])) cout << (char)tolower(str[i]);
        else cout << (char)str[i];}
    cout << endl;
}

Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0){ break; }
		int cards[201] = { 0 };
		for(int i = 0; i < n; i++){
			int idx;
			cin >> idx;
			cards[idx] = 1;
		}
		int r[2] = { n, n }, turn = 1;
		while(r[0] != 0 && r[1] != 0){
			for(int i = 1; i <= 2 * n; i++){
				if(cards[i] == turn){
					cards[i] = -1;
					if(--r[turn] == 0){ break; }
					turn = 1 - turn;
				}
			}
			turn = 1 - turn;
		}
		cout << r[0] << endl << r[1] << endl;
	}
	return 0;
}

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

int main() {
  ll n,x;cin>>n>>x;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  int cnt=0;
  rep(i,n){
    x-=a[i];
    if(x<0)break;
    cnt++;
    if(i==n-1&&x>0)cnt--;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    string ans ="No";
    if(abs(a-b)<=d&&abs(b-c)<=d || abs(a-c)<=d)ans="Yes";
    cout<<ans<<endl;
    
    return 0;
}

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

int main(){
    vector<int> ans(6);
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;

    ans[0] = abs(a1 - a3) + abs(a2 - a3);
    ans[1] = abs(a1 - a2) + abs(a2 - a3);
    ans[2] = abs(a2 - a1) + abs(a1 - a3);
    ans[3] = abs(a2 - a3) + abs(a3 - a1);
    ans[4] = abs(a3 - a1) + abs(a1 - a2);
    ans[5] = abs(a3 - a2) + abs(a2 - a1);

    sort(ans.begin(), ans.end());
    cout << ans[0] << endl;

    return 0;
}

Measured memory_bytes: 256
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var M = one[1];
  var list = new Array(N);
  var keepList = new Array(N);
  var max = 1000000007;
  for(var i = 0; i < N; i++){
    list[i] = new Array(N).fill(max);
    list[i][i] = 0;
    keepList[i] = new Array(N).fill(max);
    keepList[i][i] = 0;
  }
  for(var i = 0; i < M; i++){
    var tmp = nextIntArray();
    list[tmp[0] - 1][tmp[1] - 1] = tmp[2];
    list[tmp[1] - 1][tmp[0] - 1] = tmp[2];
    keepList[tmp[0] - 1][tmp[1] - 1] = tmp[2];
    keepList[tmp[1] - 1][tmp[0] - 1] = tmp[2];
  }
  
  for(var k = 0; k < N; k++){
    for(var i = 0; i < N; i++){
      for(var j = 0; j < N; j++){
        if(list[i][j] > list[i][k] + list[k][j]){
          list[i][j] = list[i][k] + list[k][j];
        }
      }
    }
  }
  
  var output = 0;
  for(var i = 0; i < N; i++){
    for(var j = 0; j < N; j++){
      if(keepList[i][j] != max && keepList[i][j] != list[i][j]){
        output++;
      }
    }
  }
  myout(output / 2);
}

Measured memory_bytes: 21192
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
#define abs(x,y) max(x,y)-min(x,y)
using namespace std;
long long i[10000000];
long long u[11111110];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=140,h=170,now=1;
  double o,p;
  cin >>o>>p;
  cout <<SYOU(5)<<o/p<<'\n';
  return (0);
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main() {
  int n ;
  cin >> n ;
  ll a[n];
  rep(i,n) cin>>a[i];
  
  vector<ll> s(n+1);
  s[0]=0;
  rep(i,n) s[i+1]=s[i]+a[i];
  sort(s.begin(),s.end());
  
  ll sum=1;
  ll ans=0;
  rep(i,n){
    if(s[i]==s[i+1]) sum++;
    else{
      ans+=sum*(sum-1)/2;
      sum=1;
    }
    if(i==n-1) ans+=sum*(sum-1)/2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>

int main (void)
{
  int a,b,c,d,e,temp;
  int time = 0;

  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &d);
  scanf("%d", &e);

  if(e % 10 == 0){
    temp = e;
    e = d;
    d = temp;
  }
  if(d % 10 == 0){
    temp = d;
    d = c;
    c = temp;
  }
  if(c % 10 == 0){
    temp = c;
    c = b;
    b = temp;
  }
  if(b % 10 == 0){
    temp = b;
    b = a;
    a = temp;
  }

  if(a % 10 != 0){
    if(a % 10 < b % 10){
      temp = a;
      a = b;
      b = temp;
    }
  }
  if(b % 10 != 0){
    if(b % 10 < c % 10){
      temp = b;
      b = c;
      c = temp;
    }
  }
  if(c % 10 != 0){
    if(c % 10 < d % 10){
      temp = c;
      c = d;
      d = temp;
    }
  }
  if(d % 10 != 0){
    if(d % 10 < e % 10){
      temp = d;
      d = e;
      e = temp;
    }
  }

   time += a;
   if (a % 10 != 0)
   time += 10 - (a % 10);
   time += b;
   if (b % 10 != 0)
   time += 10 - (b % 10);
   time += c;
   if (c % 10 != 0)
   time += 10 - (c % 10);
   time += d;
   if (d % 10 != 0)
   time += 10 - (d % 10);
   time += e;

   printf("%d", time);
}

Measured memory_bytes: 128
N,M,C=map(int,input().split())
B=[int(i) for i in input().split()]
ans=0
for t in range(N):
    A=[int(i) for i in input().split()]
    ANS=0
    for s in range(M):
        ANS+=A[s]*B[s]
    if ANS+C>0:
        ans+=1
print(ans)

Measured memory_bytes: 3060
def main():
    STR = input()
    Q = int(input())
    ORDER = tuple(tuple(input().split()) for _ in range(Q))

    str_ = list(STR)
    for order in ORDER:
        s = int(order[1])
        e = int(order[2]) + 1
        a = str_[s:e]
        if order[0] == 'print':
            print(''.join(a))
        elif order[0] == 'reverse':
            a = a[::-1]
            j = s
            for i in range(s, e):
                str_[i] = a[i-j]
        elif order[0] == 'replace':
            j = s
            for i in range(s, e):
                str_[i] = order[3][i-j]

main()

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

int A[20], n;
bool exhaustive(int key, int sum, int x, bool isUse){
  if(x == n) return (sum == key ? true : false);
  sum += isUse ? A[x] : 0;
  return exhaustive(key, sum, x+1, true) || exhaustive(key, sum, x+1, false);
}

int main(){
  int q, m;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> A[i];
  cin >> q;
  for(int i = 0; i < q; i++){
    cin >> m;
    cout << (exhaustive(m, 0, 0, true) || exhaustive(m, 0, 0, false) ? "yes" : "no") << endl;
  }
  return 0;
}



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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int

using namespace __gnu_pbds;

typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;


#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\



This functio helps to accesss map<pair<ll,ll>,ll ,hash_pair>myMap

struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;


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

 ll x;
 cin>>x;
cout<<(x/500)*1000+((x%500)/5)*5<<endl;

return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
using namespace std;
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int A, B, C, X, ans, sum;
	cin >> A >> B >> C >>X;
	ans = 0;

	rep(i, A + 1)
	{
		rep(j, B + 1)
		{
			rep(k, C + 1)
			{
				if (500 * i + 100 * j + 50 * k == X)
				{
					ans++;
				}
			}
		}
	}
	cout << ans << '\n';
	return 0;
}


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

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef pair<int, int> pii;
typedef long double LD;
const int INF = 0x3f3f3f3f;

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
		if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	int sum = a + b;
	for(int i = 0; i < n; i ++) {
		if(sum == 0) puts("No");
		else if(s[i] == 'c') puts("No");
		else if(s[i] == 'a') puts("Yes"), sum --;
		else if(b) puts("Yes"), b --, sum --;
		else puts("No");
	}
}


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

int main() {
	int D, N;
	cin >> D >> N;
	if(D == 0)
	cout << (N+(N/100)) << endl;
	if(D == 1)
	cout << 100 * (N+(N/100)) << endl;
	if(D == 2)
	cout << 10000 * (N+(N/100)) << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  map<string,ll> m;
  for (int i = 0; i < n; i++){
    string s;
    cin >> s;
    
    m[s]++;
  }

  cout << "AC x " << m["AC"] << endl;
  cout << "WA x " << m["WA"] << endl;
  cout << "TLE x " << m["TLE"] << endl;
  cout << "RE x " << m["RE"] << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;
#define INF (1LL << 60)
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,k,n) for(int i=(k);(i)<(n);(i)++)
#define REP(i,n) for(int i = 0;(i)<(n);(i)++)
#define REPR(i,n) for(inti = n; i >= 0; i--)

int n;
vector<int> b(100);
vector<int> method(100);
bool ok = false;

void f(int i, vector<int> v) {
	if (i == 0) {
		ok = true;
		return;
	}

	REP(j, i) {
		if (v[j] > j + 1)	return;
	}

	REP(j, i) {
		if (v[j] == j + 1) {
			vector<int> tmp(v);
			tmp.erase(tmp.begin() + j);
			f(i - 1, tmp);
			if (ok == true) {
				method[i - 1] = j + 1;
				return;
			}
		}
	}
}

int main() {
	cin >> n;
	REP(i, n) cin >> b[i];
	f(n, b);
	if (ok) {
		REP(i, n) {
			cout << method[i] << endl;
		}
	}
	else {
		cout << -1 << endl;
	}
}



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

int getDist(int w, int p1, int p2){
  int i1 = p1/w;
  int i2 = p2/w;
  int j1 = p1%w;
  int j2 = p2%w;
  return abs(i1-i2) + abs(j1-j2);
}

main(){
  int n;
  int B[4];
  cin >> n;
  for ( int i = 0; i < 4; i++ ) { cin >> B[i]; B[i]--;}
  int mind = (1<<29);
  for ( int w = 1; w <= n; w++ ){
    mind = min(mind, getDist(w, B[0], B[1]) + getDist(w, B[2], B[3]));
  }
  cout << mind << endl;
}

Measured memory_bytes: 1164
#include<iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;

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

    int cot = 1; 
    int ans;

    for(int i=0;i<N;i++){
        if(a[i]==cot){
            cot++;
        }
    }

    ans = N - (cot-1);
    if(ans==N) ans = -1;
    cout << ans << endl;

    return 0;

}

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

using Int = long long;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

using Mint = Modint<long long, 1000000007>;

Mint fact[212345] = {1};

struct edge{
	int from, to;
	int count;
	edge *rev;
	edge(int from, int to) : from(from), to(to), count(0) {}
};

int n;
std::vector<std::vector<edge>> e;
std::vector<Mint> ans;

void count(edge &i){
	for(edge &j : e[i.to]){
		if(j.to == i.from){
			i.rev = &j;
		}else{
			count(j);
			i.count += j.count;
		}
	}
	++i.count;
	i.rev->count = n - i.count;
}

void down(int from, int prev){
	int sum = 0;
	for(edge &i : e[from]) if(i.to != prev){
		down(i.to, from);
		ans[from] *= ans[i.to] / fact[i.count];
		sum += i.count;
	}
	ans[from] *= fact[sum];
}

void up(edge &i){
	ans[i.to] = ans[i.from] * fact[i.count] * fact[n - i.count - 1] / (fact[i.count - 1] * fact[n - i.count]);
	for(edge &j : e[i.to]) if(j.to != i.from){
		up(j);
	}
}

int main(){
	cin >> n;
	e.resize(n);
	ans.resize(n, 1);
	ARC(i, 1, n){
		fact[i] = fact[i - 1] * Mint(i);
	}
	RC(i, n - 1){
		int ai, bi;
		cin >> ai >> bi;
		--ai;
		--bi;
		e[ai].push_back(edge(ai, bi));
		e[bi].push_back(edge(bi, ai));
	}
	for(edge &i : e[0]) count(i);
	down(0, -1);
	for(edge &i : e[0]) up(i);

	/*
	RC(i, n){
		for(edge &j : e[i]){
			cout << j.from << "->" << j.to << ": " << j.count << endl;
		}
	}
	*/

	RC(i, n){
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 23936
#include<bits/stdc++.h>
using namespace std;
#define  ll long long int
#define mx 1005
ll b[mx],c[mx];
ll dp[mx][mx];
ll dp1[mx][mx];
ll a[mx][mx];
ll n;

int main()
{
    ll n,m;
    cin>>n>>m;
    char a[n+6][m+6];
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++) cin>>a[i][j];
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i][j]=='#'){
                dp[i][j]=0;
                continue;
            }
            if(i==1 && j==1) dp[i][j]=1;
            else if(i==1 || j==1){
                if(i==1){
                    dp[i][j]=dp[i][j-1];
                }
                else{
                    dp[i][j]=dp[i-1][j];
                }
            }
            else dp[i][j]=dp[i-1][j]+dp[i][j-1];

            dp[i][j]%=1000000007;
        }
    }
    cout<<dp[n][m]<<endl;
}


Measured memory_bytes: 12452
/**
 * Created by hiramekun at 02:26 on 2020-06-21.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll m, ll n) {
    if ((0 == m) || (0 == n)) return 0;
    return ((m / gcd(m, n)) * n);
}

// 素因数分解
map<ll, ll> prime_factor(ll n) {
    map<ll, ll> mp;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }
    if (n != 1) mp[n]++;
    return mp;
}

// 素数判定
bool is_prime(ll n) {
    for (int i = 2; i * i <= n; i++) if (n % i == 0) return false;
    return n != 1;
}

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i != n / i) res.emplace_back(n / i);
        }
    }
    return res;
}

void solve() {
    ll n, m;
    cin >> n >> m;
    vl a(n);
    cin >> a;
    rep(i, n) a[i] /= 2;
    ll g = a[0];
    for (ll i = 1; i < n; ++i) {
        g = lcm(g, a[i]);
    }
    ll comp = -1;
    rep(i, n) {
        ll tmp = 0;
        while (a[i] % 2 == 0) a[i] /= 2, tmp++;
        if (i==0) comp = tmp;
        else if (comp != tmp) {
            cout << 0 << '\n';
            return;
        }
    }

    if (g > m) {
        cout << 0 << '\n';
        return;
    }
    ll cnt = m / g;
    cnt = (cnt + 2 - 1) / 2;
    cout << cnt << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 4008
#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 = 1e9 + 1;

int main() {
	
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N)
		cin >> A[i];

	int ans = 0;
	int cnt = 1;
	bool flag = false;
	rep(i, N) {
		if (cnt == A[i]) {
			cnt++;
			flag = true;
		}
		else
			ans++;
	}

	if (flag)
		cout << ans << endl;
	else
		cout << -1 << endl;



	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include <cstdio>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

////Nayeem Shahriar Joy,Applied Physics &Electronic Engineering,University of Rajshahi.

int main()

{
    int count=0,n;
    while(cin>>n){
    for(int a=0;a<=9;a++)
    {
        for(int b=0;b<=9;b++)
        {
            for(int c=0;c<=9;c++)
            {
                for(int d=0;d<=9;d++)
                {
                    if(a+b+c+d==n)
                    {
                        count++;
                    }
                }
            }
        }
    }
    cout<<count<<endl;
    count=0;
    }
}

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

int main() {
    int N;
    cin >> N;
    vector<vector<int>> A(N,vector<int>(2));
    for ( int i = 0; i < N; ++i){
        cin >> A.at(i).at(0);
        A.at(i).at(1) = i + 1;
    }
    sort(A.begin(),A.end());
    for ( int i = 0; i < N; ++i){
        cout << A.at(i).at(1) << " " ;
    }
    cout << endl;
    return 0;
}

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

int main() {
    string S; cin >> S;
    int ans = 0;
    int temp = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'A' || S[i] == 'T' || S[i] == 'G' || S[i] == 'C') {
            temp++;
        } else {
            ans = max(ans, temp);
            temp = 0;
        }
    }
    ans = max(ans, temp);
    cout << ans << endl;
}


Measured memory_bytes: 3588
#include<iostream>

using namespace std;
int main(){
  int n,m,p;
 
  while(cin>>n>>m>>p,n!=0){
    int a[2000];
    int sum=0;
    for(int i=0;i<n;i++){
      int x;
      cin>>x;
      a[i]=x;
      sum+=x;
    }
    int g=(sum*100)*(100-p)/100;
    if(a[m-1]==0)cout<<0<<endl;
    else  cout<<g/a[m-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3000
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  auto s = readln.chomp.array;
  
  foreach (ref e; s) {
    auto d = (e - 'A' + n) % 26;
    e = 'A' + d;
  }
  s.writeln;
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;
int main() {
 string S;
 cin>>S;
 bool ok =true;
 if(S[0]!='A'){ok=false;}
 int count1=0;
for(int i=2;i<S.size()-1;i++){
  if(S[i]=='C'){count1++;}
}
 if(count1!=1){ok=false;}
 int count2=0;
 for(int i=0;i<S.size();i++){
    if(S[i]>='A'&&S[i]<='Z'){count2++;}
 }
 if(count2!=2){ok=false;}

 if(ok){cout<<"AC"<<endl;}
 else{cout<<"WA"<<endl;}

 return 0;}

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

#define ll long long

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

  int n, m;
  cin >> n >> m;
  cout << (n * (n - 1) / 2 + m * (m - 1) / 2) << endl;
  
  return 0;
}


Measured memory_bytes: 3512
#include<bits/stdc++.h>
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int mo=1000000007;
const int N=605;
int a[N],vis[N],n;
int f[N][N],g[N][N];
int main(){
	scanf("%d",&n);
	For(i,1,n*2) scanf("%d",&a[i]);
	For(i,1,n*2) if (a[i]!=-1) vis[--a[i]]=1;
	For(i,1,n)
		if (a[2*i]!=-1&&a[2*i-1]!=-1) 
			vis[a[2*i]]=vis[a[2*i-1]]=-1;
	f[0][0]=1;
	For(i,0,2*n-1) if (vis[i]!=-1){
		CLR(g,0);
		if (!vis[i])
			For(j,0,n*2) For(k,0,n*2) if (f[j][k]){
				g[j][k+1]=(g[j][k+1]+f[j][k])%mo;
				g[j+1][k]=(g[j+1][k]+f[j][k])%mo;
				if (k) g[j][k-1]=(g[j][k-1]+f[j][k])%mo;
			}
		if (vis[i])
			For(j,0,n*2) For(k,0,n*2) if (f[j][k]){
				if (j) g[j-1][k]=(g[j-1][k]+1ll*f[j][k]*j)%mo;
				g[j][k+1]=(g[j][k+1]+f[j][k])%mo;
			}
		CPY(f,g);
	}
	int ans=f[0][0],cnt=0;
	For(i,1,n) if (a[i*2]==-1&&a[i*2-1]==-1)
		ans=1ll*ans*(++cnt)%mo;
	printf("%d",ans);
}
//考虑了前i个数字,出现了j个和被钦定位置匹配的数,k个和未确定位置匹配的数字的方案数。 

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
int main()
{
    ll n;
    cin>>n;
    vector<ll> calc(n+2,0);
    calc[0]=1;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<i-2;j++)
        {
            calc[i]+=calc[j];
            calc[i]%=mod;
        }
    }
    cout<<calc[n]<<endl;
    return 0;
}


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

#define INF 100100100
#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long ;

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0);
   ll x,y;
   cin>>x>>y;
   if(y==0){
      if(x<=0)cout<<abs(x);
      else cout<<1+x;
   }
   else if(y>0){
      if(x<-y)cout<<-y-x+1;
      else if(x<0)cout<<1+y-(-x);
      else if(x == 0)cout<<y;
      else if(0<x&&x<=y)cout<<y-x;
      else if(y<x)cout<<1+(-y)-(-x)+1;
   }
   else{
      if(x<y)cout<<y-x;
      else if(x<0)cout<<1+(-y)-(-x)+1;
      else if(x==0)cout<<abs(y)+1;
      else if(0<x&&x<=-y)cout<<-y-x+1;
      else if(-y<x)cout<<1+y-(-x);
   }
   return 0;
}


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

int main(){

    int N;
    cin>>N;
    vector<int> A(N),B(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    for(int i=0;i<N;i++){
        cin>>B.at(i);
    }
    int ans=0;
    for(int i=0;i<N;i++){
        int sum=0;
        for(int j=0;j<=i;j++){
            sum+=A.at(j);
        }
        for(int j=i;j<N;j++){
            sum+=B.at(j);
        }
        ans=max(ans,sum);
    }
    cout<<ans<<endl;
    }


Measured memory_bytes: 256