akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define forr(i,z,u,l) for(i=z;i<u;i+=l)
#define f(i,n) for(i=0;i<n;i++)
using namespace std;
#define F first
#define S second
#define vi vector<int>
#define vll vector<long long>
#define vld vector<long double>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vb vector<bool>
#define all(v) v.begin(),v.end()
#define ump unordered_map
#define dbg(x) cout<<#x<<" : "<<x << endl;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvpll vector<vector<pll>>
#define endl "\n"
const ll M = 1e9 + 7;


long long pow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void solve()
{
	ll n,a;
	cin>>n;
	int i;
	ll ans=0;
	cin>>a;
	ll mx = a;
	n--;
	f(i,n){
		cin>>a;
		if(mx>a){
			ans+=mx-a;
		}
		else mx = a;
	}
	cout << ans << endl;
}

signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t;
	t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	
	
	return 0;
}

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

int main(){
    char c;
    cin >> c;
    if ('A' <= c && c <= 'Z'){
        cout << 'A' << endl;
    } else if ('a' <= c && c <= 'z'){
        cout << 'a' << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i){
        int tmp; cin >> tmp;
        if(tmp % 2 == 0 && tmp % 3 != 0 && tmp % 5 != 0){
            cout << "DENIED";
            return 0;
        }
    }
    cout << "APPROVED";

    return 0;
}


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

const long long INF = 200000000;
int N;
long long M;
vector<long long> target;

int main(void) {
	while (cin >> N >> M, M) {
		// input
		target.clear(); target.resize(N + 1);
		for (int i = 0; i < N; i++) {
			cin >> target[i];
		}
		target.push_back(0);

		// calc
		vector<long long> ab;
		ab.reserve((N + 1) * (N + 1));
		for (int i = 0; i <= N; i++) {
			for (int j = 0; j <= N; j++) {
				ab.push_back(target[i] + target[j]);
			}
		}

		sort(ab.begin(), ab.end());

		long long res = 0;
		for (int i = 0; i < ab.size(); i++) {
			if (ab[i] > M) {
				break;
			}
			vector<long long>::iterator it = upper_bound(ab.begin(), ab.end(), M - ab[i]);
			res = max(res, ab[i] + *(it - 1));
		}
		
		// output
		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 9528
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstring>

using namespace std;

typedef long long LL;

const int N = 5000 + 5;
const int M = 200 + 5;
const int INF = 1000000000 + 5;

int n, m;
int x[N];
int a[M];
LL tag[N << 2];
LL maxv[N << 2];
vector<pair<int, int> > st[M];

void modify(int t, int l, int r, int a, int b, LL v)
{
    if (b < l || r < a) return;
    if (a <= l && r <= b) {
        tag[t] += v;
        maxv[t] += v;
        return;
    }
    if (tag[t]) {
        tag[t << 1] += tag[t];
        maxv[t << 1] += tag[t];
        tag[t << 1 | 1] += tag[t];
        maxv[t << 1 | 1] += tag[t];
        tag[t] = 0;
    }
    int mid = (l + r) >> 1;
    modify(t << 1, l, mid, a, b, v);
    modify(t << 1 | 1, mid + 1, r, a, b, v);
    maxv[t] = max(maxv[t << 1], maxv[t << 1 | 1]);
}

LL query(int t, int l, int r, int a, int b)
{
    if (b < l || r < a) return 0;
    if (a <= l && r <= b) {
        return maxv[t];
    }
    if (tag[t]) {
        tag[t << 1] += tag[t];
        maxv[t << 1] += tag[t];
        tag[t << 1 | 1] += tag[t];
        maxv[t << 1 | 1] += tag[t];
        tag[t] = 0;
    }
    int mid = (l + r) >> 1;
    return max(query(t << 1, l, mid, a, b), query(t << 1 | 1, mid + 1, r, a, b));
}

void solve()
{
    cin >> n >> m;
    for(int i = 0; i < n - 1; ++ i) {
        scanf("%d", x + i);
    }

    long long ans = 0;
    for(int j = 0; j < m; ++ j) {
        st[j].push_back(make_pair(INF, -1));
    }

    for(int i = 0; i < n; ++ i) {
        long long tmp = 0;
        for(int j = 0; j < m; ++ j) {
            scanf("%d", a + j);
            tmp += a[j];
        }
        ans = max(ans, tmp);

        for(int j = 0; j < m; ++ j) {
            for( ; st[j].size() > 1; ) {
                if (a[j] >= st[j].back().first) {
                    int r = st[j].back().second;
                    int v = st[j].back().first;
                    st[j].pop_back();
                    int l = st[j].back().second + 1;
                    modify(1, 0, n - 1, l, r, -v);
                } else {
                    break;
                }
            }
            modify(1, 0, n - 1, st[j].back().second + 1, i, a[j]);
            st[j].push_back(make_pair(a[j], i));
        }

        if (i > 0) {
            modify(1, 0, n - 1, 0, i - 1, -x[i - 1]);
        }
        ans = max(ans, query(1, 0, n - 1, 0, i));
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 768
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1e9;
#define MOD 1e9+7;
#define INF64 1e18;


using namespace std;

int main() {

	SINT32 N,D,X;
	cin >> N >> D >> X;
	SINT32 ANS = X;


	vector<SINT32> DATA(N);
	
	rep(i,0,N) {
		cin >> DATA[i];
		ANS += 1+((D-1)/DATA[i]);
	}

	cout << ANS << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));　//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

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

struct LinkedList {
	struct Node {
		int key;
		Node* prev;
		Node* next;
	};

	Node* nil;
	Node* tmp;

	void init() {
		nil = (Node*)malloc(sizeof(Node));
		nil->prev = nil;
		nil->next = nil;
		nil->key = 1000000009;
		tmp = nil;
	}

	void move(int d) {
		if (d<0) {
			for (int i = d;i<0;i++) {
				tmp = tmp->prev;
			}
		}
		else {
			for (int i = 0;i<d;i++) {
				tmp = tmp->next;
			}
		}
	}

	void insert(int key) {
		Node* np = (Node*)malloc(sizeof(Node));
		np->key = key;
		np->next = tmp;
		np->prev = tmp->prev;
		tmp->prev->next = np;
		tmp->prev = np;
		if (nil->prev == nil)nil->prev = np;
		tmp = np;
	}

	void deleteTmp() {
		Node* np = tmp;
		tmp->next->prev = tmp->prev;
		tmp->prev->next = tmp->next;
		tmp = tmp->next;
		free(np);
	}

	void printList() {
		Node* np = nil->next;
		while (np != nil->prev) {
			cout << np->key << endl;
			np = np->next;
		}
		cout << np->key << endl;
	}
};



int main(void) {
	LinkedList list;

	list.init();

	int o, q, i, x;

	cin >> q;
	for (i = 0;i<q;i++) {
		cin >> o;
		if (o == 0) {
			cin >> x;
			list.insert(x);
		}
		else if (o == 1) {
			cin >> x;
			list.move(x);
		}
		else {
			list.deleteTmp();
		}
	}
	list.printList();

	return 0;
}




Measured memory_bytes: 18660
// finish date: 2018/01/11
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

#define bigmod 1000000007
using namespace std;

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

int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int factorial(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans = mul(ans, i);
    }
    return ans;
}

int main() {
    int N;
    cin>>N;
    cout << 800 * N - 200 * (N / 15) << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<math.h>
using namespace std;
#define ll long long int
int main()
{
    int n,i;
    cin>>n;
    ll a[n+1],b[n+1],sum=0,count=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]<0)
            count++;
        b[i]=abs(a[i]);
        sum+=b[i];
    }
    sort(b,b+n);
    if(count%2==0)
        cout<<sum<<endl;
    else
        cout<<sum-2*b[0]<<endl;
    return 0;
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1000000007;

double a[200005];
double b[200005];
int main()
{
    //ios::sync_with_stdio(false);
    int n,m;
    double t;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
        scanf("%lf",&a[i]),a[i]=((double)a[i]+1.0)/2;
    for(int i=0;i<m;i++)
        t+=a[i];
    b[0]=t;
    double ans=0;
    //cout<<b[0]<<endl;
    for(int i=1;i<=n-m;i++)
    {
        b[i]=t+a[i+m-1]-a[i-1];
        t=b[i];
        //cout<<b[i]<<endl;
        if(b[i]>ans)
        {
            ans=b[i];
        }
    }
    sort(b,b+n-m+1);
    printf("%.12f",b[n-m]);
    return 0;
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int sign(int x) { return (x > 0) - (x < 0); }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const deque<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const set<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
  int N;
  cin>>N;
  vint A(N);
  rep(i,N)cin>>A[i];
  int ans=0;
  reps(i,N-1){
    if(A[i]<A[i-1]){
      ans+=A[i-1]-A[i];
      A[i]=A[i-1];
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4836
n = input()

if 0 < int(n[:2]) <13 and 0 < int(n[2:]) < 13:
    print('AMBIGUOUS')
elif int(n[:2]) >12 and 0 < int(n[2:]) < 13:
    print('YYMM')
elif int(n[2:]) >12 and 0 < int(n[:2]) < 13:
    print('MMYY')
elif int(n[:2]) == 0 and 0 < int(n[2:]) < 13:
    print('YYMM')
elif int(n[2:]) == 0 and 0 < int(n[:2]) < 13:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 3064
x1,x2,x3,x4,x5,x6 = map(int,(input().split()))
n = int(input())
T=[]
for k in range(n):
    i,j = map(int, (input().split()))
    T.append([i,j])
L=[x1,x2,x3,x4,x5,x6]

for k in T:
    while L[0] != k[0]:
        L = [L[4], L[0], L[2], L[3], L[5], L[1]]
        if L[0] == k[0]:
            pass
        else:
            L = [L[3], L[1], L[0], L[5], L[4], L[2]]

    while L[1] != k[1]:
        L = [L[0], L[3], L[1], L[4], L[2], L[5]]
        if L[1] == k[1]:
            pass
        else:
            L = [L[0], L[3], L[1], L[4], L[2], L[5]]
    print(L[2])

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

using namespace std;


long long int a,e[100010],b,c,d;

long long int  dfs(int x,int s,int t,int u){
  if(x == a) {
    if(s>0 && t>0 && u>0){
      return abs(s-b)+abs(t-c)+abs(u-d)-30;
    }
      else{
        return 1e9;
      }
    }
  
   long long int res0=dfs(x+1,s,t,u);
  long long int res1=dfs(x+1,s+e[x],t,u)+10;
  long long int res2=dfs(x+1,s,t+e[x],u)+10;
  long long int res3=dfs(x+1,s,t,u+e[x])+10;
  return min({res0,res1,res2,res3});
}


int main(){
	cin >> a >> b>>c>>d;
  
  for(int i=0;i<a;i++){
    cin >>e[i];
  }
  
  cout << dfs(0,0,0,0) << endl;
  return 0;
}
      
  
  
  

  




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
	double w,h,x,y;
	cin>>w>>h>>x>>y;
	cout<<std::setprecision(10)<<w*h/2<<" ";
	if(x==w/2&&y==h/2) cout<<1<<endl;
	else cout<<0<<endl;
	
}


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

int main(){
    string s,a,x="Yes";
    cin>>s;
    a=s.substr(0,(s.size()-1)/2);
    if(a!=s.substr((s.size()+1)/2)) x="No";
    s=a;reverse(begin(a),end(a));
    if(a!=s) x="No";
    cout<<x<<endl;
}


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

int n;
int a[100005], l[100005], r[100005];

int main() 
{
	cin >> n;
	for (int i = 0; i < n; i++) 
		cin >> a[i];
	
	l[0] = a[0]; r[n-1] = a[n-1];

	for (int i = 1; i < n; i++) 
		l[i] = __gcd(l[i-1], a[i]);
	
	for (int i = n-2; i >= 0; i--) 
		r[i] = __gcd(r[i+1], a[i]);
	

	int x=max(l[n-2], r[1]);
	for (int i = 1; i < n-1; i++) 
		x = max(x, __gcd(l[i-1],r[i+1]));
	
	cout << x << endl;
}


Measured memory_bytes: 1408
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数

//ライブラリ挿入


int main(){
    int N,M,s,t;
    cin >> N >> M;
    
    // グラフ入力受取 
    vector<vector<int>> G(N);

    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
    }
    cin >> s >> t;
    s--;
    t--;

    // BFS のためのデータ構造
    vector<vector<int>> dist(N,vector<int>(3,-1)); // 全頂点を「未訪問」に初期化
    queue<pair<int,int>> que;
    
    // 初期条件 
    dist[s][0] = 0;
    que.push(make_pair(s,0)); // 0 を橙色頂点にする
    
    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        pair<int,int> q=que.front();
        que.front(); // キューから先頭頂点を取り出す
        que.pop();
        int v=q.first;
        int n=q.second;
    
        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv][(n+1)%3] != -1) continue; // すでに発見済みの頂点は探索しない
            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv][(n+1)%3] = dist[v][n] + 1;
            que.push(make_pair(nv,(n+1)%3));
        }
    }

    if(dist[t][0]!=-1) dist[t][0]/=3;
    cout<<dist[t][0]<<endl;

}

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

vector < vector <int> > sav;
char a[15][15], b[15][15];
int used[15];

void dfs(set <int> s, vector <int> rec){
	set <int> s2;
	vector <int> rec2;
	if (s.empty()){
		sav.push_back(rec);
		return;
	}
	for (auto it : s){
		if (it == *s.begin()) continue;
		s2 = s;
		s2.erase(*s.begin());
		s2.erase(it);
		rec2 = rec;
		rec2.push_back(*s.begin());
		rec2.push_back(it);
		dfs(s2, rec2);
	}
}

int main(){
	int h, w, flag, f1, f2, cnt;
	set <int> s;
	vector <int> rec;
	scanf("%d %d",&h,&w);
	for (int i = 1; i <= h; i++) scanf("%s", a[i] + 1);
	for (int i = 1; i <= w; i++) s.insert(i);
	if (w & 1) s.insert(w + 1);
	dfs(s, rec);
	if (w & 1){
		for (int i = 0; i < sav.size(); i++){
			for (int j = 0; j <= w; j++){
				if (sav[i][j] == w + 1){
					sav[i][j] = sav[i][j - 1];
					break;
				}
			} 
		}
	}
	for (int i = 0; i < sav.size(); i++){
		cnt = 0;
		for (int j = 0; j < sav[i].size(); j += 2){
			if (sav[i][j] == sav[i][j + 1]){
				for (int k = 1; k <= h; k++) b[k][w / 2 + 1] = a[k][sav[i][j]];
				continue;
			}
			cnt++;
			for (int k = 1; k <= h; k++){
				b[k][cnt] = a[k][sav[i][j]];
				b[k][w - cnt + 1] = a[k][sav[i][j + 1]];
			}
		}
		memset(used, 0, sizeof(used));
		flag = 1; f2 = 0;
		for (int j = 1; j <= h; j++){
			if (used[j]) continue;
			for (int k = j + 1; k <= h; k++){
				if (used[k]) continue;
				f1 = 1;
				for (int p = 1; p <= w; p++){
					if (b[j][p] != b[k][w - p + 1]){
						f1 = 0;
						break;
					}
				}
				if (f1){
					used[j] = 1;
					used[k] = 1;
					break;
				}
			}
			if (!f1){
				if (h % 2 == 0 || f2){
					flag = 0;
					break;
				}
				f1 = 1;
				for (int k = 1; k <= w; k++){
					if (b[j][k] != b[j][w - k + 1]){
						f1 = 0;
						break;
					}
				}
				if (!f1){
					flag = 0;
					break;
				}
				f2 = 1;
				used[j] = 1;
			}
		}
		if (flag){
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 1152
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define N 105
using namespace std;
string a[N];
int main(){
//	freopen("in.txt","r",stdin);
	ios::sync_with_stdio(false);
	int n,l;
	cin>>n>>l;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		cout<<a[i];
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	while(cin>>n,n){
		vector<int>in(10);
		rep(i,n){
			int a;
			cin>>a;
			in[a]++;
		}
		rep(i,10){
			if(in[i])rep(j,in[i])cout<<"*";
			else cout<<"-";
			cout<<endl;
		}
	}
}

Measured memory_bytes: 1188
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
 
int main(){
    long Q,H,S,D;
    long N;
    long total=0;
    cin>>Q>>H>>S>>D>>N;
    total = (N/2)*min({8*Q,4*H,2*S,D})+(N%2)*min({4*Q,2*H,S});
    cout<<total<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
#debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    N, D = LI()

    # 初めの監視員の位置
    pos = D + 1
    # first + D + 1 まで見れる

    m = 2*D + 1
    ans = N // m
    if ans * m == N:
        print(ans)
    else:
        print(ans+1)
solve()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
//int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    //if(!kaijo[0])init_fact();
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int h,w,n,dp[3010][2];
P p[3010];
signed main(){
    cin>>h>>w>>n;
    rep(i,n){
        cin>>p[i+1].fi>>p[i+1].se;
        p[i+1].fi--,p[i+1].se--;
    }
    p[0]={0,0};
    n++;
    sort(p,p+n);
    dp[0][0]=1;
    init_fact(200010);
    rep(i,n){
        rep(k,2){
            for(int j=i+1;j<n;j++){
                if(p[j].fi<p[i].fi||p[j].se<p[i].se)continue;
                int dx=p[j].fi-p[i].fi;
                int dy=p[j].se-p[i].se;
                dp[j][1-k]+=dp[i][k]*comb(dx+dy,dx)%mod;
                dp[j][1-k]%=mod;
            }
        }
    }
    int ans=comb(h+w-2,h-1);
    for(int i=1;i<n;i++){
        rep(k,2){
            int dx=h-1-p[i].fi;
            int dy=w-1-p[i].se;
            int memo=dp[i][k]*comb(dx+dy,dx)%mod;
            if(k==0)ans=(ans+memo)%mod;
            else ans=(ans-memo+mod)%mod;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#define ll long long 
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	int t = a * b;
	if ((t / 2) * 2 == t)
		cout << "No";
	else cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] array = new int[N];
        long sum = 0;

        long maxSum = 0;
        int startIndexOfmaxSum = 0;

        for (int i = 0; i < N; i++) {
            array[i] = sc.nextInt();

            if (i < K) {
                sum += array[i];
                maxSum += array[i];

            } else {
                sum += array[i];
                sum -= array[i - K];

                if (sum > maxSum) {
                    startIndexOfmaxSum = i - K + 1;
                    maxSum = sum;
                }
            }
        }

        initSumInteger();
        double ans = 0;
        for (int i = startIndexOfmaxSum; i < startIndexOfmaxSum + K; i++) {
            ans += ((double) sumInteger[array[i]] / (double) array[i]);
        }

        System.out.println(ans);
    }

    private static long[] sumInteger = new long[1001];

    private static void initSumInteger() {
        for (int i = 1; i <= 1000; i++) {
            sumInteger[i] = i + sumInteger[i - 1];
        }
    }
}


Measured memory_bytes: 81248
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a;
	int i,t=0;
	for(i=0;i<4;i++)
	{
		scanf("%c",&a);
		if(a=='2')
		{
			t++;
		}
	}
	printf("%d",t);
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <complex>
#include <vector>

using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;

namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

typedef vector<P> G;

struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}


//直線と直線の交差
bool intersectLL(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || // non-parallel
    abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;   // same line
}
bool intersectLS(const L &l, const L &s) {
  return cross(l[1]-l[0], s[0]-l[0])*       // s[0] is left of l
    cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l
}
bool intersectLP(const L &l, const P &p) {
  return abs(cross(l[1]-p, l[0]-p)) < EPS;
}

//線分と線分の交差
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}


bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}

int main()
{
  double x1,y1,x2,y2,x3,y3,xp,yp;
  while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
    int b1 = ccw(P(x1,y1),P(x2,y2),P(xp,yp));
    int b2 = ccw(P(x2,y2),P(x3,y3),P(xp,yp));
    int b3 = ccw(P(x3,y3),P(x1,y1),P(xp,yp));
    
    if((b1==b2) && b2 == b3 && b3 == b1)cout << "YES\n";
    else cout << "NO\n";

  }
}

Measured memory_bytes: 1212
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

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

const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const long double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//







int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    for(int i = 0; i < n; i++){
        cin >> a[i+1];
    }
    vector<int> b(n+1);
    for(int i = n; i >= 1; i--){
        int sum = 0;
        for(int j = i+i; j <= n; j += i){
            sum ^= b[j];
        }
        b[i] = sum ^ a[i];
    }

    vector<int> ans;
    for(int i = 1; i <= n; i++){
        if(b[i]) ans.push_back(i);
    }

    cout << ans.size() << endl;
    for(int i = 0; i < ans.size(); i++){
        printf("%d%c", ans[i], i+1==ans.size()?'\n':' ');
    }

    return 0;
}





































Measured memory_bytes: 3064
n = int(input())
f = [0, 0, 0]
for i in range(n) : 
    a = list(map(int, input().split()))
    f = [max(f[1], f[2]) + a[0], max(f[0], f[2]) + a[1], max(f[0], f[1]) + a[2]]

print(max(f[0], f[1], f[2]))


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define PER(a,b,c) for(int a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
using namespace std;
const double Pi=acos(-1.0);
const int MAXN=1e6+5;
int n,m,t;
int v[MAXN];
char s[MAXN];
int main(){
    cin>>s+1;
    int ans=0;
    int sum=0;
    n=strlen(s+1);
    REP(i,1,n){
        if(s[i]=='R')sum++;
        else sum=0;
        ans=max(ans,sum);
    }
    cout<<ans;
}

Measured memory_bytes: 3172
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[50000];
int main()
{
	gets(a);
	for(int i=0;i<strlen(a);i++){
		if(a[i]=='C'){
			for(int j=i+1;j<=strlen(a);j++){
				if(a[j]=='F'){
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
n = input()
k = int(input())

if(k == 1):
    print(n[0])
elif(len(n)==1):
    print(n)
elif(n[0]== '1'):
    i = 1
    while(n[i] == '1'):
        i += 1
        if(i == len(n)):
            break
    if(k <= i):
        print(1)
    else:
        print(n[i])
else:
    print(n[0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

signed main(){
    string S, T;
    cin >> S >> T;
    int N = S.length();
    int ans = 0;
    REP(i, N){
        if(S[i] != T[i]) ans++;
    }
    PRINT(ans);
    return 0;
}

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

int balls[10];
bool drop(int pos, int left, int right) {
    if (pos == 10) return true;
    return balls[pos] > left && drop(pos+1, balls[pos], right) || balls[pos] > right && drop(pos+1, left, balls[pos]);
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 10; ++j) 
            cin >> balls[j];
        if (drop(0, 0, 0)) 
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}


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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n, h, w;

int main() {
  cin >> h >> w >> n;
  cout << (n + max(h, w) - 1) / max(h, w);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


vector<int> v[100000];
vector<bool> u(100000,false);

int main(){
  int N, L;
  cin >> N >> L;
  if(L+N-1 < 0) cout << (2*L+N-2) * (N-1) /2 << endl;
  else if(L > 0) cout << (2*L + N) * (N-1) / 2<< endl;
  else cout << (2*L+N-1) * N / 2 << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb  push_back

const int INF = 1001001001;
const int N = 110, MAX_V = 2 * N;
const int src = 210, sink = 211;

typedef pair<int, int> P;

struct Edge { int to, cap, cost, rev; };

int h[MAX_V];   // potential
vector<Edge> G[MAX_V];

void add_edge(int from, int to, int cap, int cost)
{
    G[from].pb((Edge){ to, cap, cost, (int)G[to].size() });
    G[to].pb((Edge){ from, 0, -cost, (int)G[from].size()-1 });
}

int min_cost_flow()
{
    int res = 0;
    int dist[MAX_V], prevv[MAX_V], preve[MAX_V];
    bool first = true;
    
    while(true)
    {
        priority_queue<P, vector<P>, greater<P> > que;
        fill_n(dist, MAX_V, INF);
        dist[src] = 0;
        que.push(P(0, src));
        
        // dijkstra
        while(!que.empty())
        {
            P p = que.top(); que.pop();
            int v = p.second;
            if(dist[v] < p.first) continue;
            rep(i, G[v].size())
            {
                Edge &e = G[v][i];
                if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
                    dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
                    prevv[e.to] = v; preve[e.to] = i;
                    que.push(P(dist[e.to], e.to));
                }
            }
        }
        
        if(!first) rep(v, MAX_V) h[v] += dist[v];
        first = false;
        if(h[sink] >= 0) return res;
        
        int f = INF;
        for(int v = sink; v != src; v = prevv[v])
            f = min(f, G[prevv[v]][preve[v]].cap);
        res -= f * h[sink];
        for(int v = sink; v != src; v = prevv[v]) {
            Edge &e = G[prevv[v]][preve[v]];
            e.cap -= f;
            G[v][e.rev].cap += f;
        }
    }
}

int main()
{
    int Nn, Np, Kn[N], Kp[N], M, P, L, In, Ip, NJ;
    string A, J;
    
    while(cin >> Nn >> Np && Nn)
    {
        map<string, int> table;
        fill_n(h, MAX_V, 0);
        rep(i, MAX_V) G[i].clear();
        
        rep(i, Nn) cin >> Kn[i], add_edge(src, i, Kn[i], 0);
        rep(i, Np) cin >> Kp[i], add_edge(Nn+i, sink, Kp[i], 0);
        cin >> M;
        rep(i, M) cin >> A >> P, table[A] = P;
        cin >> L; int vmax = 0;
        rep(i, L) {
            int v = 0;
            cin >> In >> Ip >> NJ;
            rep(j, NJ) cin >> J, v += table[J];
            add_edge(In-1, Nn+Ip-1, INF, -v);   // reverse sign of cost
            h[Nn+Ip-1] = min(h[Nn+Ip-1], -v);
            vmax = max(vmax, v);
        }
        
        h[sink] = -vmax;
        cout << min_cost_flow() << endl;
    }
}

Measured memory_bytes: 976
MOD=10**9+7
def facinv(N):
    fac,finv,inv=[0]*(N+1),[0]*(N+1),[0]*(N+1)
    fac[0]=1;fac[1]=1;finv[0]=1;finv[1]=1;inv[1]=1
    for i in range(2,N+1):
        fac[i]=fac[i-1]*i%MOD
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        finv[i]=finv[i-1]*inv[i]%MOD
    return fac,finv,inv

def COM(n,r):
    if n<r or r<0:
        return 0
    else:
        return ((fac[n]*finv[r])%MOD*finv[n-r])%MOD

def PER(n,r):
    if n<r or r<0:
        return 0
    else:
        return (fac[n]*finv[n-r]%MOD)

N,M=map(int,input().split())
fac,finv,inv=facinv(M)

ans=PER(M,N)**2%MOD
res=0
for r in range(1,N+1):
    f=COM(N,r)*PER(M,r)%MOD*(PER(M-r,N-r)**2%MOD)%MOD
    res=(res+(pow(-1,r-1)*f)+MOD)%MOD
print((ans-res+MOD)%MOD)

Measured memory_bytes: 95472
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    char A[3];
    rep(i,1){
        cin >> A;
    }
     sort(A,A+3);
    cout << (A[0]=='a' &&A[1]=='b'&&A[2]=='c'? "Yes" : "No") << endl;
}

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

int main()
{
    int h, w;
    cin >> h >> w;
    int cnt = 0;
    rep(i, h)
    {
        string s;
        cin >> s;
        rep(j, w)
        {
            if (s[j] == '#')
                cnt++;
        }
    }

    if (cnt == h + w - 1)
        cout << "Possible" << endl;
    else
        cout << "Impossible" << endl;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <algorithm>

using namespace std;

int a, b;
int p[5678], q[5678];

int main()
{
	scanf("%d %d", &a, &b);
	for (int i = 0; i < a; ++i)scanf("%d", p + i);
	for (int j = 0; j < a; ++j)scanf("%d", q + j);
	int ans = 0;
	for (int bed = 0; bed < b; ++bed)
	{
		int aitr = 0;
		for (int x = bed; x < b; ++x)
		{
			while (a != aitr && p[aitr] != q[x])
			{
				++aitr;
			}
			if (a == aitr)
			{
				ans = max(ans, x - bed);
				break;
			}
			++aitr;
			if (x == b - 1)
			{
				ans = max(ans, b - 1 - bed);
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2776
#include <cstdint>
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  int64_t total = 1000;
  int64_t stock = 0;
  int64_t price = 0;
  int pre;
  cin >> pre;
  for (int n = 1; n < N; ++n) {
    int cur;
    cin >> cur;
    if (pre < total && pre < cur) {
      stock = total / pre;
      total %= pre;
      price = pre;
    } else if (cur < pre) {
      total += pre * stock;
      stock = 0;
      price = 0;
    }
    if (n == N - 1 && 0 < stock) {
      total += cur * stock;
      stock = 0; price = 0;
    }
    pre = cur;
  }
  cout << total << endl;

  return 0;
}


Measured memory_bytes: 3632
#!/usr/bin/env python3
import sys
from collections import defaultdict
from collections import Counter

def solve(N: int, s: "List[str]"):
    count_dict = defaultdict(int)
    for i, string in enumerate(s):
        string = list(string)
        info = sorted(Counter(string).items(), key=lambda x:x[0])
        info = tuple([tuple([i, j]) for i, j in info])
        count_dict[info] += 1

    result = 0
    for _, v in count_dict.items():
        result += int((v-1) * 0.5 * (1 + v-1))
    print(result)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [ next(tokens) for _ in range(N) ]  # type: "List[str]"
    solve(N, s)

if __name__ == '__main__':
    main()


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

using namespace std;

vector<bool> vis;
vector<vector<int>> map;

int dfs(int n){
 
    int max = 1;
 
    vis[n] = true;   
    
    for(int i = 0; i < map[n].size(); i++){
        
        if(!vis[map[n][i]]){
            max += dfs(map[n][i]);
        }
        
    }
    
    return max;

}

int main()
{
    
    int n, m, a, b;
    cin >> n >> m;
    
    for(int i = 0; i < n+1; i++){
        
        map.push_back(vector<int>());
        vis.push_back(false);
        
    }
    
    for(int i = 0; i < m; i++){
        
        cin >> a >> b;
        
        map[a].push_back(b);
        map[b].push_back(a);
        
    }

    int g = 1;
    
    for(int i = 0; i < map.size(); i++){
        
        if(map[i].size() == 0 || vis[i])
            continue;
            
        int tmp = dfs(i);
        
        if(tmp > g)
            g = tmp;
        
    }
    
    cout << g << "\n";

    return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int ans;
string s,hoge = "CODEFESTIVAL2016";

signed main() {
    cin >> s;
    rep(i,s.size()) if (s[i] != hoge[i]) ans++;
    cout << ans << endl;
}












Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
#define ll long long
int n,a=0,w=0,t=0,r=0;
signed main(){
	cin>>n;
	for(int i=0;i<n;i++){
		string s;cin>>s;
		if(s[0]=='A')a++;
		if(s[0]=='W')w++;
		if(s[0]=='T')t++;
		if(s[0]=='R')r++;
	}
	cout<<"AC"<<" "<<"x"<<" "<<a<<endl;
	cout<<"WA"<<" "<<"x"<<" "<<w<<endl;
	cout<<"TLE"<<" "<<"x"<<" "<<t<<endl;
	cout<<"RE"<<" "<<"x"<<" "<<r<<endl;
	return 0;
} 

Measured memory_bytes: 3628
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    let b: usize = read();
    println!(
        "{}",
        match a % 2 != 0 && b % 2 != 0 {
            true => "Yes",
            false => "No",
        }
    )
}


Measured memory_bytes: 4352
//simple
#include<stdio.h>

int main(void){
    long long k,a,b,r[64]={0},i,t;
    scanf("%lld",&k);
    printf("50\n");
    a=k/50;
    b=k%50;
    t=49+a-b;
    for(i=1;i<=50;i++){
        if(i<=b){r[i]=t+51;}
        else{r[i]=t;}
    }
    for(i=1;i<=50;i++){
        if(i==50){printf("%lld\n",r[i]);}else{printf("%lld ",r[i]);}
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = sc.nextInt();
        if(a+b>x&&a<=x){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 24020
#include <stdio.h>

int main(void){
	int w,h,i,j;
	do{
		scanf("%d %d",&h,&w);
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				if((i+j)%2==0)
					putchar('#');
				else
					putchar('.');
			}
			putchar('\n');
		}
		if(w!=0 || h!=0)
			putchar('\n');
	}while(w!=0 && h!=0);
		
		
	return 0;
}

Measured memory_bytes: 572
n = int(input())
li = [list(map(int, input().split())) for i in range(n)]
li = [[0,0,0]] + li

for i in range(n):
    t_diff = li[i+1][0] - li[i][0]
    xy_diff = sum(li[i+1][1:]) - sum(li[i][1:])

    if t_diff < xy_diff or t_diff % 2 != xy_diff % 2:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 28068
#include<iostream>
#include<string>
#include <vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
#define PI 3.141592653589793
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 998244353;

int main() {
	int n, k;
	cin >> n >> k;
	vll h(n);
	rep(i, n) cin >> h[i];
	vsort(h);
	ll ans = 1e9 + 7;
	for (int i = 0; i < n - k + 1; i++) {
		ans = (h[i + k - 1] - h[i] <= ans) ? h[i + k - 1] - h[i] : ans;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main() {
	int i, j, x, y;
	int sum = 0;
	int v[101][101] = {0};
	cin >> y;cin >> x;
	for (i = 0; i < y; i++) {
		for (j = 0; j < x; j++) {
			cin >> v[i][j];
		}
	}
	for (i = 0; i < y; i++) {
		for (j = 0; j < x; j++) {
			v[i][x] = v[i][x] + v[i][j];
		}
		sum = sum + v[i][x];
	}
	for (i = 0; i < y; i++) {
		for (j = 0; j < x; j++) {
			v[y][j] = v[y][j] + v[i][j];
		}
	}
	v[y][x] = sum;
	for (i = 0; i <= y; i++) {
		for (j = 0; j < x; j++) {
			cout << v[i][j] << " ";
		}
		cout << v[i][j]<<"\n";
	}
}


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

int main(){
    int A,B,C,D;
    int count = 0;
    cin >> A >> B >> C >> D;
    while(A > 0 && C >0){
        if(count % 2 == 0){
            C = C - B;
        }else{
            A = A - D;
        }
        count++;
    }
    if(count % 2 == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3644
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)

	N, W := getInt(), getInt()
	w := make([]int, N)
	v := make([]int, N)
	for i := 0; i < N; i++ {
		w[i], v[i] = getInt(), getInt()
	}

	var dp [101][100001]int
	for i := 0; i < N; i++ {
		for j := 0; j <= 100000; j++ {
			dp[i][j] = math.MaxInt32
		}
	}

	dp[0][0] = 0
	for i := 0; i < N; i++ {
		for j := 0; j <= 100000; j++ {
			if j-v[i] < 0 {
				dp[i+1][j] = dp[i][j]
			} else {
				dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]]+w[i])
			}
		}
	}

	max := 0
	for i := 0; i <= 100000; i++ {
		if dp[N][i] <= W && i > max {
			max = i
		}
	}

	out(max)
}


Measured memory_bytes: 84608
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,a,ak,h;
    cin>>n>>k>>a;
    h=a;
    for(int i=2;i<=n;i++){
        cin>>ak;
        a=__gcd(a,ak);       
        h=max(ak,h);
    }
    if(k%a==0&&k<=h)    
        cout<<"POSSIBLE"<<endl;
    else
        cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

Measured memory_bytes: 256