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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long lint;

int N;
lint D, X[30], Y[30];

struct Diff {
	lint x, y;
	bool operator < (const Diff& o) const { return x < o.x; }
};

void dfs(int i, int n, lint dx, lint dy, vector< Diff >& res) {
	if (i == n) {
		res.push_back(Diff{dx, dy});
		return;
	}
	dfs(i+1, n, dx, dy, res);
	dfs(i+1, n, dx + X[i], dy - Y[i], res);
	dfs(i+1, n, dx - X[i], dy + Y[i], res);
}

int main() {
	cin >> N >> D;
	for_(i,0,N) cin >> X[i] >> Y[i];
	
	if (N == 1) {
		cout << (X[0] <= D ? Y[0] : 0) << endl;
		return 0;
	}
	
	vector< Diff > va, vb;
	dfs(0, N/2, 0, 0, va);
	dfs(N/2, N, 0, 0, vb);
	
	sort(va.begin(), va.end());
	reverse(va.begin(), va.end());
	sort(vb.begin(), vb.end());
	
	deque< int > deq;
	int ma = va.size(), mb = vb.size(), L = 0, R = 0;
	lint ans = -(1LL << 60);
	for_(i,0,ma) {
		lint UB = D - va[i].x, LB = -(D + va[i].x);
		
		while (R < mb && vb[R].x <= UB) {
			while (!deq.empty() && vb[deq.back()].y < vb[R].y) deq.pop_back();
			deq.push_back(R);
			++R;
		}
		
		while (L < R && vb[L].x < LB) {
			while (!deq.empty() && deq.front() <= L) deq.pop_front();
			++L;
		}
		
		if (!deq.empty()) ans = max(ans, va[i].y + vb[deq.front()].y);
	}
	cout << ans << endl;
}

Measured memory_bytes: 489264
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		string s = Console.ReadLine();
    string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long x = long.Parse(input[0]);
		long y = long.Parse(input[1]);
    long[,] dpx = new long[2,16001];//可能な到達地点+8000。0を保存、1で更新する
    long[,] dpy = new long[2,16001];
    bool answer = false;
    long memoForward = 0;
    long turnCount = 0;

    for(long i = 0; i < s.Length; i++)
    {
      if(s[(int)i] == 'F') memoForward++;
      if(s[(int)i] == 'T' || i == s.Length-1)
      {
        if(turnCount == 0)
        {
          dpx[0,memoForward+8000] = 1;
        }else if(turnCount == 1)
        {
          dpy[0,memoForward+8000] = 1;
          dpy[0,-memoForward+8000] = 1;
        }else if(turnCount % 2 == 0)
        {
          for(long j = 0; j < 16001; j++)
          {
            if(dpx[0,j] == 1)
            {
              dpx[1,j-memoForward] = 1;
              dpx[1,j+memoForward] = 1;
            }
          }
          for(long j = 0; j < 16001; j++)
          {
            dpx[0,j] = dpx[1,j];
            dpx[1,j] = 0;
          }
        }else if(turnCount % 2 == 1)
        {
          for(long j = 0; j < 16001; j++)
          {
            if(dpy[0,j] == 1)
            {
              dpy[1,j-memoForward] = 1;
              dpy[1,j+memoForward] = 1;
            }
          }
          for(long j = 0; j < 16001; j++)
          {
            dpy[0,j] = dpy[1,j];
            dpy[1,j] = 0;
          }
        }
        turnCount++;
        memoForward = 0;
      }
    }
    
    if(turnCount >= 2) Console.WriteLine((dpx[0,x+8000] == 1 && dpy[0,y+8000] == 1) ? "Yes" : "No");
    else if(turnCount == 1 && s[s.Length-1] == 'F')Console.WriteLine((s.Length == x && y == 0) ? "Yes" : "No");
    else if(turnCount == 1 && s[s.Length-1] == 'T')Console.WriteLine((s.Length == x+1 && y == 0) ? "Yes" : "No");
	}
}


Measured memory_bytes: 13112
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



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

	m = n * 360 / __gcd(360, n);
	cout << m / n;

	return Accepted;
}

// B...a

Measured memory_bytes: 17728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int n;
int a[132];
int ans;

void Init() {
	scanf("%d", &n);
	for(int i = 2; i <= n; i++) scanf("%d", &a[i]);
	a[1] = a[2];
}

void solve() {
	for(int i = 1; i < n; i++) ans += min(a[i], a[i + 1]);
	ans += a[n];
	printf("%d\n", ans);
}

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

Measured memory_bytes: 256
#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 each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define fs first
#define sc second
#define pb push_back
#define sz size() 
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1e8;
const D EPS = 1e-8;

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

  vi cnt(n,0);
  int max_d = 0;
  rep(i,n){
    int a; cin >> a; cnt[a]++;
    chmax(max_d, a);
  }

  int c = (max_d+1)/2;
  for(int i=max_d;i>=c;i--){
    if(max_d%2 == 0 && i==c) cnt[i] -= 1;
    else cnt[i] -= 2;
    if(cnt[i] < 0){
      cout << "Impossible" << endl;
      return 0;
    }
  }


  rep(i,c+1){
    if(cnt[i]){
      cout << "Impossible" << endl;
      return 0;
    }
  }

  cout << "Possible" << endl;
}


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

struct P{
  int f[9];
  int t;
  int st;
  bool operator < (const P &p) const{
    for(int i=0;i<9;i++){
      if(f[i]==p.f[i])continue;
      return f[i]>p.f[i];
    }
    return false;
  }
};

int main(){
  P in;
  map<P,bool> V;
  queue<P> Q;
  for(int i=0;i<9;i++){
    cin>>in.f[i];
    if(in.f[i]==0)in.st=i;
  }
  in.t=0;
  Q.push(in);
  while(!Q.empty()){
    P top=Q.front();
    Q.pop();
    if(!V[top]){
      V[top]=true;
      int flag=0;
      for(int i=0;i<9;i++)if((i+1)%9!=top.f[i])flag=1;
      if(!flag){
	cout<<top.t<<endl;
	break;
      }
      int st=top.st;
      top.t++;
      P tmp;
      if(st-3>=0){
	tmp=top;
	swap(tmp.f[st],tmp.f[st-3]);
	tmp.st-=3;
	Q.push(tmp);
      }
      if(st+3<9){
	tmp=top;
	swap(tmp.f[st],tmp.f[st+3]);
	tmp.st+=3;
	Q.push(tmp);
      }
      if(st%3!=2){
	tmp=top;
	swap(tmp.f[st],tmp.f[st+1]);
	tmp.st++;
	Q.push(tmp);
      }
      if(st%3!=0){
	tmp=top;
	swap(tmp.f[st],tmp.f[st-1]);
	tmp.st--;
	Q.push(tmp);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 21084
#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()
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	vector<int> vec(n);
	int c = 0;
	for(int i = 0 ;i<n;i++)
	{
		if(s[i]=='L')
		{
			vec[i] = c;
			c = 0;
		}
		else
		{
			c++;
		}
	}
	for(int i = n-1;i>=0;i--)
	{
		if(s[i]=='R')
		{
			vec[i] = c;
			c = 0;
		}
		else
		{
			c++;
		}
	}
	//rep(i,n)cout<<vec[i]<<endl;
	vector<int> ans (n);
	rep(i,n-1)
	{
		if(s[i]=='R'&&s[i+1]=='L')
		{
			int sum = vec[i] + vec [i+1];
			ans[i]=ans[i+1] =  sum/2;
			//cout<<i<<'.'<<sum<<endl;
			if(ans[i]%2==1)
			{
				
				if(sum%2==1)
				{
					if(vec[i]%2==1)
					{
						ans[i+1]++;
					}
					else
					{
						ans[i]++;
					}
				}
			}
			else
			{
				if(sum%2==1)
				{
					if(vec[i]%2==0)
					{
						ans[i]++;
					}
					else
					{
						ans[i+1]++;
					}
					
				}
			}
			
		}
	}
	rep(i,n)cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int h, n;
	cin >> h >> n;
	ll sum = 0;
	while (n--) {
		int a;
		cin >> a;
		sum += a;
	}
	if (sum >= h)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
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--)
typedef long long LL;
LL N,H;
LL a[100001];
LL b[100001];

int main(){
	cin>>N>>H;
	LL ma=0;
	vector<LL>v;
	REP(i,N){
		cin>>a[i]>>b[i];
		v.push_back(b[i]);
		ma=max(ma,a[i]);
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	LL ans=0;
	REP(i,v.size()){
		if(ma>=v[i])break;
		ans++;
		H-=v[i];
		//cout<<v[i]<<" "<<H<<endl;
		if(H<=0){
			cout<<ans<<endl;
			return 0;
		}
	}
	//cout<<H<<" "<<ma<<endl;
	ans+=((H+ma-1)/ma);
	cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 2676
#include "iostream"
using namespace std;
int abs(int a){
  if(a<=0){
    return(-1*a);
  }
  else{
    return (a);
  }
}
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if((abs(a-c))<=d){
    cout<<"Yes"<<endl;
  }
  else if(((abs(a-b))<=d)&&((abs(b-c))<=d)){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3560
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <queue>

#define MAXN 200005
#define INF 2100000000

using namespace std;

int n, m, st[MAXN], ed[MAXN];
pair<int, int> prs[MAXN * 2];
int head, tail, qu[MAXN];
int cnt[MAXN][2];
int lab[MAXN];
bool flag[MAXN];
char line[MAXN];

int main()
{
    //freopen("c.txt", "r", stdin);
    while (cin >> n >> m) {
        scanf("%s", line);
        for (int i = 1; i <= n; i++) {
            lab[i] = line[i - 1] - 'A';
            cnt[i][0] = cnt[i][1] = 0;
            st[i] = ed[i] = 0;
        }
        int x, y;
        for (int i = 0; i < m; i++) {
            scanf("%d%d", &x, &y);
            prs[i] = make_pair(x, y);
            prs[i + m] = make_pair(y, x);
        }
        sort(prs, prs + m + m);
        st[0] = ed[0] = 0;
        for (int i = 1; i <= n; i++) {
            st[i] = ed[i - 1];
            ed[i] = st[i];
            while (ed[i] < m + m && prs[ed[i]].first == i)
                ed[i]++;
            for (int j = st[i]; j < ed[i]; j++) {
                cnt[i][lab[prs[j].second]]++;
            }
        }
        head = tail = 0;
        for (int i = 1; i <= n; i++) {
            flag[i] = true;
            if (cnt[i][0] <= 0 || cnt[i][1] <= 0) {
                flag[i] = false;
                qu[tail++] = i;
            }
        }

        while (head < tail) {
            int u = qu[head++];
            for (int i = st[u]; i < ed[u]; i++) {
                int v = prs[i].second;
                if (flag[v] && (--cnt[v][lab[u]]) == 0) {
                    flag[v] = false;
                    qu[tail++] = v;
                }
            }
        }
        bool ck[2] = {false, false};
        for (int i = 1; i <= n; i++)
            if (flag[i])
                ck[lab[i]] = true;
        if (ck[0] && ck[1])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;

}


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

int pre[maxn];
int n;

int main()
{
  int ans1 = 0, ans2 = 1e9;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>pre[i];
    ans1 = max(ans1, pre[i]);
    ans2 = min(ans2, pre[i]);
  }
  cout<<ans1 - ans2<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

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

void solve() {
    LL n,k;
    string s;
    cin >> n >> k >> s;
    int m = k * 2 + 1;
    VI be;
    int cnt = 1;
    REP(i,1,n) {
        if (s[i] == s[i-1]) ++cnt;
        else {
            be.push_back(cnt);
            cnt = 1;
        }
    }
    be.push_back(cnt);
    if (be.size() <= m - 1 + (s[0] == '1')) {
        cout << n << endl;
        return;
    }
    int sum = 0;
    int ans = 0;
    if (s[0] == '1') {
        REP(i,0,2*k-1) sum += be[i+1];
        int tmp = sum;
        tmp += be[0];
        if (be.size() > 2 * k) tmp += be[2 * k]; 
        ans = max(ans, tmp);
        for (int i = 2 * k; i + 1 < be.size(); i+=2) {
            sum += be[i] + be[i+1] - be[i - (2 * k - 1)] - be[i - (2 * k - 1) + 1];
            int tmp = sum;
            tmp += be[i - (2 * k - 1) + 1];
            if (i+2 < be.size()) tmp += be[i+2]; 
            ans = max(ans, tmp);
        }
    } else {
        REP(i,0,2*k-1) sum += be[i];
        int tmp = sum;
        if (be.size() > 2 * k - 1) tmp += be[2 * k - 1]; 
        ans = max(ans, tmp);
        for (int i = 2 * k - 1; i + 1 < be.size(); i+=2) {
            sum += be[i] + be[i+1] - be[i - (2 * k - 1)] - be[i - (2 * k - 1) + 1];
            int tmp = sum;
            tmp += be[i - (2 * k - 1) + 1];
            if (i+2 < be.size()) tmp += be[i+2]; 
            ans = max(ans, tmp);
        }
    }

    cout << ans << endl;
}

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

Measured memory_bytes: 1020
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def foo(fe,x,ev):
    k = sum(fe)+1
    n = len(fe)
    d = [ [False]*(2*k+1) for i in range(n+1) ]
    d[0][k] = True
    if len(fe)>0:
        d[1][fe[0]+k] = True
        if not ev:
            d[1][-fe[0]+k] = True
    for i in range(1,n):
        for j in range(-k,k+1):
            if d[i][j+k]:
                d[i+1][j+fe[i]+k] = True
                d[i+1][j-fe[i]+k] = True
    return -k<=x<=k and d[n][x+k]

s = ins()
x,y = inm()
f = [ [], [] ]
strk = 0
turn = 0
n = len(s)
for i in range(n):
    if s[i]=='T':
        f[turn].append(strk)
        turn = 1 - turn
        strk = 0
    else:
        strk += 1
f[turn].append(strk)
if foo(f[0],x,True) and foo(f[1],y,False):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 165852
#include<iostream>
using namespace std;
int main(){
	int n,x;
	for(;;){
	int count=0;
	cin >> n >> x;
	if(n==0 && x==0)	break;
	for(int i=1;i<=n;i++)
		for(int j=i;j<=n;j++)
			for(int k=j;k<=n;k++){
				if(i==j || j==k || k==i)	continue;
				if(i+j+k==x)				count++;
			}
	cout<< count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int a, b, c; cin >> a >> b >> c;
    ll k; cin >> k;
    int ans;
    if (k&1) ans = b - a;
    else ans = a - b;
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include<cstdio>
#define maxn 100050
using namespace std;
int fa[maxn];
int get(int x){
	if (fa[x]==x) return x;else return fa[x]=get(fa[x]);
}
int main(){
	int n,m,ans;
	scanf("%d%d",&n,&m);
	ans=n;
	for (int i=1;i<=n;i++)
	fa[i]=i;
	for (int i=1;i<=m;i++){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		int fx=get(x),fy=get(y);
		if (fx!=fy) {
			fa[fx]=fy;
			ans--;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<complex.h>
#include<math.h>
int main() {
    int x,y,a,b;
    if(1<=x,b<=100){
    scanf("%d %d",&x, &y);
    a=x*2+y*2;
    b=x*y;
    printf("%d %d\n",b,a);}
    return 0;
}



Measured memory_bytes: 2708
mod = 10**9+7
import fractions
def lcm(a,b):
    return (a*b)//fractions.gcd(a,b)
N = int(input())
A = list(map(int,input().split()))
lc = 1
for i in range(N):
    lc = lcm(lc,A[i])
ans = 0
for i in range(N):
    ans += lc//A[i]
print(ans%mod)

Measured memory_bytes: 6112
N=int(input())
dic={}
for i in range(1,N+1):
    dic[i]=0
for x in range(1,int(N**0.5)):
    for y in range(1,N-x**2):
        for z in range(1,N-(x**2+y**2+x*y)):
            if x**2+y**2+z**2+x*y+x*z+y*z>N:break
            if x**2+y**2+z**2+x*y+x*z+y*z in dic:
                dic[x**2+y**2+z**2+x*y+x*z+y*z]+=1


for i in range(1,N+1):
    print(dic[i])

Measured memory_bytes: 70308
#include <stdio.h>
#define MAX 10001

int linerSearch(int);

int S[MAX], n;

int main() {
  int q, key;
  int sum = 0;
  int i;

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

  scanf("%d", &q);
  for( i = 0; i < q; i++ ) {
    scanf("%d", &key);
    if( linerSearch(key) ) sum++;
  }

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

int linerSearch(int key) {
  int i = 0;
  S[n] = key;
  while( S[i] != key ) i++;
  if( i == n ) return 0;
  
  return 1;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;

int main() {
  ll s,w;
  cin >> s >> w;
  if(w>=s) cout << "unsafe" << endl;
  else cout << "safe" << endl;
}


Measured memory_bytes: 3596
import collections
import math

n = int(input())
s = [input() for i in range(n)]
for i in range(n):
	s[i] = ''.join(list(sorted(s[i])))
c = collections.Counter(s)
t = 0
for v in c.values():
	if v>1:
		t += math.factorial(v) // (math.factorial(v - 2) * math.factorial(2))
	else:
		continue
print(t)

Measured memory_bytes: 19852
#include <bits/stdc++.h>
using namespace std;
bool dp[1000010];
 
int main() {
  int N; cin >>N;
  int a=1;
  dp[1]=true;
  for(int i=2;i<100;i++){
    a=i;
    while(a<=1000){
      a=a*i;
      dp[a]=true;
    }
  }
  int kotae,kazu;
  kazu=N;
  while(kazu){
    if(dp[kazu]==true){
      kotae=kazu;
      break;
    }
    kazu--;
  }
  cout<<kotae<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
    #pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize("Ofast")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include<bits/stdc++.h>
    #define int long long
    # define mo 1000000007
    using namespace std;
    #define goku ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    signed main(){
        goku
    int n,k;
    cin>>n>>k;
    int r,s,p;
    cin>>r>>s>>p;
    string t;
    cin>>t;
    int an=0;
    for(int i=0;i<k;i++)
    {
        int pr=i,x=0;
        if(t[i]=='r')
            an+=p;
        else if(t[i]=='s')
            an+=r;
        else
            an+=s;
        for(int j=i+k;j<n;j+=k)
        {
            if(x==0&&t[j]==t[pr])
            {
                x=1;
            }
            else
            {
                x=0;
                  if(t[j]=='r')
                     an+=p;
                 else if(t[j]=='s')
               an+=r;
            else
            an+=s;
  //  cout<<an<<" ";
            }
         //   cout<<an<<" ";
            pr=j;
        }
        //cout<<endl;
    }
    cout<<an<<endl;
       return 0;
    }


Measured memory_bytes: 512
N=int(input())
X=list(map(int,input().split()))
Y=[0]*N
for i in range(N):
  Y[i]=X[i]
X.sort()
L=X[N//2-1]
U=X[N//2]
for i in range(N):
  if(Y[i]<=L):
    print(U)
  else:
    print(L)

Measured memory_bytes: 26180
def combs_mod(n,k,mod):
  #nC0からnCkまで
  inv = [1]*(k+1)
  for i in range(1,k+1):
    inv[i] = pow(i,mod-2,mod)
  ans = [1]*(k+1)
  for i in range(1,k+1):
    ans[i] = ans[i-1]*(n+1-i)*inv[i]%mod
  return ans
def solve():
  mod = 998244353
  N, K = map(int, input().split())
  ans = 0
  if K<N:
    return ans
  com = combs_mod(K,K,mod)
  for r in range(K+1):
    b = K-r
    dif = r-b
    if dif<0 or r<N:
      continue
    elif dif==0:
      com2 = combs_mod(K-1,K-1,mod)
      ans += com2[r]
      if N>=2:
        ans -= com2[N-2]
    elif dif<N:
      ans += com[r] - com[N-1-dif]
    else:
      ans += com[r]
    ans %= mod
  return ans
print(solve())

Measured memory_bytes: 176608
l = []
for x in range(5):
    l.append(int(input()))
k = int(input())

cnt = 0
for i in range(5):
    for j in range(5):
        diff = abs(l[i] - l[j])
        if diff > k:
            cnt += 1

if cnt == 0:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <cctype>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;
const int maxn = 1e6+7;

int main(){
	ll w,h,x,y;
	cin>>w>>h>>x>>y;
	printf("%.6lf ",w*h/2.0);
	if(2*x==w&&2*y==h){
		cout<<1<<endl;
	}
	else{
		cout<<0<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
namespace ino{
    class Inonoa{
        static void Main(){
            string[] h_w = Console.ReadLine().Split(' ');
            int h = int.Parse(h_w[0]);
            int w = int.Parse(h_w[1]);

            int[,] map = new int[h+2,w+2];
            for(int i=0;i<h+2;i++){
                map[i,0] = -9;
                map[i,w+1] = -9;
            }
            for(int i=0;i<w+2;i++){
                map[0,i] = -9;
                map[h+1,i] = -9;
            }

            Queue<int[]> q = new Queue<int[]>();
            for(int i=1;i<h+1;i++){
                char[] tc = Console.ReadLine().ToCharArray();
                for(int j=1;j<w+1;j++){
                    if(tc[j-1]=='#'){map[i,j]=0;q.Enqueue(new int[]{i,j});}
                    else{map[i,j]=-1;}
                    
                }
            }
            int ans = 0;

            while(q.Count>0){
                int[] p = q.Dequeue();
                if(map[p[0]-1,p[1]]==-1){
                    map[p[0]-1,p[1]] = map[p[0],p[1]]+1;
                    q.Enqueue(new int[]{p[0]-1,p[1]});
                    ans = map[p[0],p[1]]+1;
                }
                if(map[p[0]+1,p[1]]==-1){
                    map[p[0]+1,p[1]] = map[p[0],p[1]]+1;
                    q.Enqueue(new int[]{p[0]+1,p[1]});
                    ans = map[p[0],p[1]]+1;
                }
                if(map[p[0],p[1]-1]==-1){
                    map[p[0],p[1]-1] = map[p[0],p[1]]+1;
                    q.Enqueue(new int[]{p[0],p[1]-1});
                    ans = map[p[0],p[1]]+1;
                }
                if(map[p[0],p[1]+1]==-1){
                    map[p[0],p[1]+1] = map[p[0],p[1]]+1;
                    q.Enqueue(new int[]{p[0],p[1]+1});
                    ans = map[p[0],p[1]]+1;
                }
            }

            Console.WriteLine(ans);

        }
    }
}

Measured memory_bytes: 70012
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int table[100001],ans[100001];
stack<int> First[100001];

int main(){

	int N;
	scanf("%d",&N);

	table[0] = 0;
	for(int i = 1; i <= N; i++)table[i] = -1;

	int tmp;

	for(int i = 1; i <= N; i++){
		scanf("%d",&tmp);
		First[tmp].push(i);
		table[tmp]++;
	}

	for(int i = 1; i <= N; i++)table[i] += table[i-1];

	int minimum = BIG_NUM,min_index;

	for(int i = 1; i <= N; i++){
		if(table[i] < minimum){
			minimum = table[i];
			min_index = i;
		}
	}

	int start_pos;

	if(min_index == N){
		start_pos = 1;
	}else{
		start_pos = min_index+1;
	}

	stack<int> S;
	int dealt_num = 0,loc = start_pos;

	while(dealt_num < N){

		while(!First[loc].empty()){
			S.push(First[loc].top());
			First[loc].pop();
		}

		if(S.empty()){
			if(loc == N){
				loc = 1;
			}else{
				loc++;
			}
			continue;
		}

		ans[loc] = S.top();
		S.pop();
		dealt_num++;

		if(loc == N){
			loc = 1;
		}else{
			loc++;
		}
	}

	for(int i = 1; i <= N; i++){
		printf("%d\n",ans[i]);
	}

	return 0;
}

Measured memory_bytes: 71420
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

A = list(map(int, input().split()))


def ok(X):
    cnt = 0
    for a in A:
        cnt += (a - 1) // X

    return cnt <= K


def solve():
    l, r = 0, 1000000000

    while l + 1 < r:
        c = (l + r) // 2
        if ok(c):
            r = c
        else:
            l = c

    return r


print(solve())


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

signed main(void)
{
	int n;
	cin >> n;
	if (n < 105)
		cout << 0 << endl;
	else if (n < 135)
		cout << 1 << endl;
	else if (n < 165)
		cout << 2 << endl;
	else if (n < 189)
		cout << 3 << endl;
	else if (n < 195)
		cout << 4 << endl;
	else
		cout << 5 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    int n; cin>>n;
    vector <int> a(n); 
    rep(i,n) cin>>a[i];
    int ans = INF;
    for(int i=-200;i<=200;i++){
        int cost = 0;
        for(int j=0;j<n;j++){
            cost += (i-a[j])*(i-a[j]);
        }
        chmin(ans, cost);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int a, d, n;

bool is_prime[1000010];

int main(){
	fill(is_prime, is_prime + 1000010, 1);
	is_prime[0] = is_prime[1] = 0;
	for (int i = 2; i <= 1000000; i++){
		if (is_prime[i]){
			for (int j = 2*i; j <= 1000000; j += i)is_prime[j] = 0;
		}
	}
	while (cin >> a >> d >> n&&a + d + n){
		int co = 0;
		for (int i = a; i <= 1000000; i++){
			if (is_prime[i]){
				if ((i - a) % d == 0)co++;
			}
			if (co == n){
				cout << i << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 2136
import Control.Applicative
import Data.List

main :: IO ()
main = do
  n  <- getLine
  xs <- lines <$> getContents
  let cards = [x ++ " " ++ (show n) | x <- ["S", "H", "C", "D"], n <- [1 .. 13]]
  putStr . unlines $ filter (`notElem` xs) cards



Measured memory_bytes: 3572
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int N;
 string u[10];
  double x[10];
  double sum=0;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> x[i];
    cin >> u[i];
    if(u[i] == "JPY"){
      sum += x[i];
    }else{
      sum += x[i] *  380000;
    }
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

pr = [False]*N
wa = [0]*N

acc = 0
wac = 0

for i in range(M):
    p, S = input().split()
    p = int(p)-1
    if pr[p] == True:
        continue
    if S == "AC":
        pr[p] = True
    else:
        wa[p] += 1

for i in range(N):
    if pr[i]:
        acc += 1
        wac += wa[i]

print(acc, wac)

Measured memory_bytes: 4596
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
a=get_i
(N/2).downto(1) do|i|
  cnt=0
  x=i
  while x<=N
    cnt+=a[x-1] 
    x+=i
  end
  if a[i-1]!=cnt%2
      a[i-1]+=1
      a[i-1]%=2
  end
end
ans=[]
a.each_with_index{|x,i| ans<<i+1 if x==1}
puts ans.size
puts ans.join(" ") unless ans.nil?

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int ans=0;
	for(int i=1;i<s.size();++i)if(s.at(i-1)!=s.at(i))++ans;
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 512
#include <cstdio>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int main() {
	double A, B, C, K;
	scanf("%lf %lf %lf %lf", &A, &B, &C, &K);
    int point = min(A, K);
    if (K > A+B) {
        point -= K-A-B;
    }
    printf("%d\n", point);
}

Measured memory_bytes: 1752
#include <stdio.h>
#include <math.h>
 
int main(void)
{
    int n, i;
    int s[1000];
    double m, sum;
    double siguma;
     
    for(; ; ) {
        scanf("%d", &n);
        if(n==0) break;
        else {
            m=0; sum=0;
            for(i=0; i<n; i++) {
                scanf("%d", &s[i]);
                m+=s[i];
            }
            m=(double)m/n;
             
            for(i=0; i<n; i++)
                sum+=pow(s[i]-m, 2);
            sum/=n;
            siguma=sqrt(sum);
            printf("%f\n", siguma);
        }
    }
     
    return 0;
}


Measured memory_bytes: 2056
from itertools import permutations

N,M,R = map(int,input().split())
r = list(map(int,input().split()))

li = [[0 for i in range(N+1)]for j in range(N+1)]

for _ in range(M):
    a,b,c = map(int,input().split())
    li[a][b] = c
    li[b][a] = c

def all_pairs_shortest_paths(W):
    inf = 10**18
    # 頂点の数
    n = len(W)
    # 結果を格納する行列を用意する
    res = [[0] * n for i in range(n)]
    # 用意した行列を初期化する
    for i in range(n):
        for j in range(i, n):
            if i == j:
                val = 0
            elif W[i][j]:
                val = W[i][j]
            else:
                val = inf
            res[i][j] = res[j][i] = val
    # 動的計画法ですべての超点間の最短距離を求める
    for k in range(n):
        for u in range(n):
            for v in range(n):
                res[u][v] = min(res[u][v], res[u][k] + res[k][v])
    return res

lin = all_pairs_shortest_paths(li)

pos = list(permutations(r))

mi = 10**18

for i in pos:
    l = 0
    for j in range(1,R):
        l += lin[i[j-1]][i[j]]
    mi = min(mi,l)

print(mi)

Measured memory_bytes: 53080
#include <bits/stdc++.h>
using longlong=long long;

int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    std::string s;std::cin>>s;
    int ans=0;
    for(char c:s){
        if(c=='+')ans++;
        if(c=='-')ans--;
    }
    std::cout<<ans<<std::endl;
}

Measured memory_bytes: 256
class Prime:
    def __init__(self,number):#N以下の素数
        self.jud=[True]*(number+5)
        self.pri=[]
        self.jud[0]=False
        self.jud[1]=False
        for i in range(number):
            if self.jud[i]:
                self.pri.append(i)
                for j in range(2,(number)//i+1):
                    self.jud[i*j]=False
    
    def judge(self,x):
        return self.jud[x]
    
    def decom(self,x):
        s=x
        a =[]
        if s==1:
            return a
        while s>1:
            for p in self.pri:
                if s%p==0:
                    a.append(p)
                    s=s//p
                    break
        return a
            

A=Prime(10**5)
Q=int(input())
Que=[[int(i) for i in input().split()] for i in range(Q)]
cou=[0]*(10**5+1)
for i in range(3,10**5+1):
    if A.judge(i) and A.judge((i+1)//2):
        cou[i]=cou[i-1]+1
    else:
        cou[i]=cou[i-1]
ans=[]
for l,r in Que:
    ans.append(cou[r]-cou[l-1])
print('\n'.join(map(str,ans)))

Measured memory_bytes: 32476
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) for(int i=0;i<n;i++)
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
int f(pii a){return (a.first*a.first + a.second*a.second)*200 + a.first;}

int main(void){
    int n,m;
    vector<pii> stat;
    for(int i=1;i<151;i++)for(int j=i+1;j<151;j++){
        stat.emplace_back(i,j);
    }
    //sort(all(stat),[](pii a, pii b){return a.first<b.first;});
    sort(all(stat),[](pii a, pii b){return f(a)<f(b);});
    //for(auto i:stat)if(f(i)>=980*980+1000000)cout<<i.first<<" "<<i.second<<"("<<f(i)<<")"<<endl;
    while(cin>>n>>m,n|m){
        pii data=*(find(all(stat),make_pair(n,m))+1);
        cout<<data.first<<" "<<data.second<<endl;
    }
}

Measured memory_bytes: 3220
N=int(input())
for h in range(1,3501):
    for n in range(h,3501):
        if 4*h*n>N*n+N*h:
            w=(N*h*n)/(4*h*n-N*n-N*h)
            if w==int(w):
                print(h,n,int(w))
                exit()

Measured memory_bytes: 3060
#include<stdio.h>
#include<limits>
using namespace std;

int cnt;

void merge(int A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1+1], R[n2+1];
  for (int i=0; i<n1; i++) {
    L[i] = A[left+i];
  }
  L[n1] = numeric_limits<int>::max();
  for (int i=0; i<n2; i++) {
    R[i] = A[mid+i];
  }
  R[n2] = numeric_limits<int>::max();
  int i=0, j=0;
  for (int k=left; k<right; k++) {
    cnt++;
    if (L[i]<R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(int A[], int left, int right) {
  if (left+1 < right) {
    int mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main() {
  cnt = 0;
  int n;
  scanf("%d", &n);
  int A[n];
  for (int i=0; i<n; i++) {
    scanf("%d", &A[i]);
  }
  mergeSort(A, 0, n);
  for (int i=0; i<n; i++) {
    if (i<n-1) {
      printf("%d ", A[i]);
    } else {
      printf("%d", A[i]);
    }

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



Measured memory_bytes: 6500
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1000000007;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int main(){
  cioacc();
  ll n;
  cin >> n;
  unordered_multiset<ll> gr;
  ll ans = 0;
  vl v(n);
  REP(i,n) cin >> v[i];
  sort(ALL(v));
  REP(i,n){
    ll tmp = v[v.size()-i-1];
    ll t = 1LL<<31;
    bool flag = false;
    REP(j,30){
      t >>= 1;
      auto itr = gr.find(abs(tmp-t));
      if(itr!=gr.end()){
        flag = true;
        gr.erase(itr);
        ++ans;
        break;
      }
    }
    if(!flag){
      gr.insert(tmp);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 10056
// abc109_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int H, W;
    cin >> H >> W;
    vector<vector<int>> S(H, vector<int>(W, 0));
    REP(i, H) REP(j, W) cin >> S[i][j];

    vector<tuple<int, int, int, int>> ans;

    REP(i, H){
        REP(j, W-1){
            if (S[i][j] & 1){
                ans.emplace_back(i+1, j+1, i+1, j+2);
                S[i][j+1] += 1;
            }
        }

        if (i == H-1) continue;

        if (S[i][W-1] & 1){
            ans.emplace_back(i+1, W, i+2, W);
            S[i+1][W-1] += 1;;
        }
    }

    print(ans.size());
    for (auto x: ans){
        print(get<0>(x), get<1>(x), get<2>(x), get<3>(x));
    }

    return 0;
}


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

#define IOS cin.tie(0);ios::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vs      vector<string>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

const int INF = 1e9;
const int MOD = 1e9+7;

#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?' ':'\n'); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);}//最小公倍数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

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

const int NMAX = 200;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}

void solve(){
    CIN(D,N);
    int ans=1;
    if(N==100) ans*=(N+1);
    else ans*=N;
    if(D!=0)ans=ans*pow(100,D);
    printf("%d\n",ans);
}

signed main(){
    IOS;
    solve();

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <numeric>
using namespace std;
#define MAX_N 100010

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; }
const long long INF = 1LL << 60;

// Input
int N, M;
long long L[MAX_N], R[MAX_N];

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> L[i] >> R[i];
    }

    long long max_L = 0;
    long long min_R = INF;
    for (int i = 0; i < M; i++) {
        max_L = max(max_L, L[i]);
        min_R = min(min_R, R[i]);
    }

    long long ans = min_R - max_L + 1;
    long long result = (ans >= 0)? ans : 0;
    cout << result << endl;
}

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

int main(void){
   int N,T;
   cin>>N>>T;
   vector<int> t(N);
   for(int i=0;i<N;i++){
      cin>>t[i];
   }
   int ans=T;
   for(int i=0;i<N-1;i++){
      if(t[i+1]-t[i]>=T) ans+=T;
      else ans+=(t[i+1]-t[i]); 
   }
   cout<<ans<<endl;
   return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;

#define pb push_back
#define mp make_pair
#define all(_c) _c.begin(), _c.end()

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

    int n, q;
    cin >> n >> q;

    string s;
    cin >> s;

    vector <int> pos;
    for (int i = 0; i < n - 1; i++)
        if (s[i] == 'A' and s[i + 1] == 'C')
            pos.push_back(i++);

    while (q--) {
        int l, r;
        cin >> l >> r;
        l--, r--;

        cout << upper_bound(all(pos), r - 1) - upper_bound(all(pos), l - 1) << '\n';
    }
    return 0;
}


Measured memory_bytes: 1228
using System;


namespace ConsoleApp11
{
    class Class1
    {
        public static void Main()
        {
            string[] IN = Console.ReadLine().Split();
            long N = long.Parse(IN[0]);
            long A = long.Parse(IN[1]);
            long B = long.Parse(IN[2]);

            
            long up;
            long down;
            long small;
            long big;
            long ans;
            if ((A + B) % 2 == 0)
                ans = Math.Abs((A - B) / 2);
            else
            {
                up = Math.Max(A-1, B-1);
                down = Math.Max(N - A, N - B);
                if (up < down)
                {

                    ans = Math.Min(A - 1, B - 1) + 1 + (Math.Max(A-1,B-1) - (Math.Min(A - 1, B - 1) + 1)) / 2;
                }
                else
                    ans = Math.Min(N - A, N - B) + 1 + (Math.Max(N-A,N-B) - (Math.Min(N - A, N - B) + 1)) / 2;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
n,m = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]
ans1 = [0]*n
ans2 = [0,10,100]
ans3 = ''
sc.sort()
if m == 0:
    print(ans2[n-1])
else:
    temp_i = -1
    temp_j = -1
    for k in sc:
        i = k[0]
        j = k[1]
        if i==1 and j==0 and n!=1:
            print(-1)
            exit()
        if temp_i == i:
            if j != temp_j:
                print(-1)
                exit()
            ans1[i-1]=j
        else:
            ans1[i-1]=j
        temp_i = i
        temp_j = j
    if n==1:
        print(ans1[0])
    else:
        if ans1[0] == 0:
            ans1[0]=1
            for i in ans1:
                ans3 += str(i)
            print(ans3)
        else:
            for i in ans1:
                ans3 += str(i)
            print(ans3)


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

int n;
int w;
long long a[110];//w
long long b[110]; //v
long long f[110][330];
const int INF=(0x7fffffff)/2;
long long ans;

int main() 
{
	cin>>n>>w;
	for (int i=1;i<=n;i++) cin>>a[i]>>b[i];
	for (int i=0;i<110;i++) 
		for (int o=0;o<330;o++) f[i][o]=-INF;
	f[0][0]=0;
	for (int i=1;i<=n;i++)
		for (int o=i-1;o>=0;o--) 
			for (int j=0;j<=3*o;j++) 
				if (f[o][j]!=INF) f[o+1][j+(a[i]-a[1])]=max(f[o+1][j+(a[i]-a[1])],f[o][j]+b[i]);
	
/*	for (int i=1;i<=n;i++) 
	{
		for (int o=0;o<=i*3;o++)  
		{
			cout<<f[i][o]<<" ";
		}
		cout<<endl;
	}
	*/
	for (int i=1;i<=n;i++) 
		for (int o=0;o<330;o++) if (i*a[1]+o<=w && f[i][o]!=INF) ans=max(ans,f[i][o]);
		
	cout<<ans<<endl;
}

Measured memory_bytes: 512