akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k;
  int a[1240];
  a[0]=0;
  a[1]=2;
  k=2;
  for(i=3;i<10000;i+=2){
    for(j=3;j<(int)sqrt(i)+1;j+=2){
      if(i%j==0)
	break;
    }
    if(j>=(int)sqrt(i)+1){
      a[k]=a[k-1]+i;
      k++;
    }
  }
  int n;
  while(cin>>n&&n){
    int ct=0;
    j=1229;
    for(i=1;j-i>-1;i++){
      for(;j-i>-1&&a[j]-a[j-i]>n;j--);
      if(j-i>-1&&a[j]-a[j-i]==n)
	ct++;
    }
    cout<<ct<<endl;
  }
  return 0;
}

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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    lint n, blue, red;
    cin >> n >> blue >> red;
    lint total = blue + red;
    if (!blue) cout << "0\n";
    else {
    	lint used = n/total;
    	lint result = used * blue;
    	n -= total * used;
    	cout << result + min(n, blue) << '\n';
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int arr[100009];
int num[100009];
vector<int>v;
int ans = 0,x=0;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        num[arr[i]]++;
    }
    for(int i=1;i<=100000;i++){
        if(num[i] == 0)continue;
        num[i] = num[i]%2;
        if(!num[i]){x++;}
        else ans++;
    }
    ans += (x/2)*2;
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(s,x) memset(s,x,sizeof(s))
#define pb push_back
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;

const int MAXN = 1e5+5;
const ll MOD = 1e9+7;

int main()
{
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (u == s)
        a--;
    else
        b--;
    cout << a << " " << b << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
#define tr(container, it) \
	for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c,x) ((c).find(x) != (c).end())   //O(log n) 
#define contains(c,x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define Ichar(_x) char _x;scanf("%c",&_x);
#define Iint(_x) int _x;scanf("%d",&_x); 
#define Ill(_x)  ll _x;scanf("%lld",&_x);
#define inc(a,b,x)(x)>a && (x)<b	
#define incE(a,b,x)(x)>=a && (x)<=b	
#define max(a,b) (a)>=(b)? (a) : (b) 
#define fileio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
const double pi = 3.14159265358979323846;



#define F first
#define S second
const int MX = 1e5 + 10, MD = 1e9 + 7;
long long n, m, a[MX], ans, tmp, mx, t1, t2, ind, res;
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] > mx) {
			mx = a[i];
			ind = i;
		}
	}
	ans = mx + 1;
	ll t = 50000000000000;
	for (ll i = 0; i < pow(10, 12); )
	{
		printf("");
		i++; t /= abs(t-i);
	}
	if (mx % 2 == 0) {
		t1 = mx / 2;
		for (int i = 0; i < n; i++) {
			if (ind == i)continue;
			if (abs(a[i] - t1) < ans) {
				ans = abs(a[i] - t1);
				res = a[i];
			}
		}
	}
	else {
		t1 = mx / 2;
		t2 = mx / 2 + 1;
		for (int i = 0; i < n; i++) {
			if (ind == i)continue;
			if (abs(a[i] - t1) < ans) {
				ans = abs(a[i] - t1);
				res = a[i];
			}
			else if (abs(a[i] - t2) < ans) {
				ans = abs(a[i] - t2);
				res = a[i];
			}
		}
	}
	cout << mx << " " << res;

}






Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
using Tuple = tuple<int, int, int>;

const double PI=3.1415926535897932;

int main() {
    double r; cin >> r;
    cout << fixed << setprecision(9) << 2 * r * PI << endl;
    return 0;
}

Measured memory_bytes: 3788
def len1(L):
    i,cnt,maxInt=1,0,0
    f=True
    while i<=n:
        if L[i]==1:
            cnt+=1
            i+=1
        elif f:
            f=False
            t=i
            i+=1
            cnt+=1
        else:
            i=t+1
            cnt=0
            f=True
        maxInt=max(maxInt,cnt)
    return maxInt

def len2(L):
    cnt,maxInt=0,0
    for i in range(1,n+1):
        if L[i]==1:
            cnt+=1
        else:
            maxInt=max(maxInt,cnt)
            cnt=0
    return maxInt

while True:
    n,k=map(int,raw_input().split())
    if n==k==0:break
    L=[0]*(n+1)
    for i in range(k):
        L[input()]=1
    print len1(L) if L[0] else len2(L)

Measured memory_bytes: 7412
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = INT()
print(N * N - A)



Measured memory_bytes: 5716
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>

using namespace std;

#define PI 3.14159265358979323846
#define INF 1e+9
#define DIV_NUM (1000000007)



int main() {

	int N;
	cin >> N;
	vector<long long> inputs;
	for (int i = 0; i < N; i++) {
		long long tmp;
		cin >> tmp;
		inputs.push_back(tmp);
	}

	sort(inputs.begin(), inputs.end());
	inputs.erase(unique(inputs.begin(), inputs.end()), inputs.end());

	if (N == inputs.size()) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<bool> from1(n+1), toN(n+1);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        if (a == 1) from1[b] = true;
        if (b == n) toN[a] = true;
    }

    rep(i,n){
        if (from1[i] && toN[i]){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

template <typename T>
static inline T ArraySum(vector<T>& A) {
  T res = 0;
  for (auto itr = A.begin(); itr < A.end(); ++itr) res += *itr;
  return res;
}

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

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

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

u32 DP[3010][3010];

int main() {
  cout << setprecision(18);
  string s, t;
  cin >> s >> t;
  for (u32 i = 1; i <= s.size(); ++i) {
    for (u32 j = 1; j <= t.size(); ++j) {
      if (s[i - 1] == t[j - 1])
        DP[i][j] = DP[i - 1][j - 1] + 1;
      else
        DP[i][j] = max(DP[i - 1][j], DP[i][j - 1]);
    }
  }

  string res;
  u32 i = s.size(), j = t.size();
  while (i > 0 && j > 0) {
    if (s[i - 1] == t[j - 1])
      res += s[i - 1], --i, --j;
    else if (DP[i][j - 1] > DP[i - 1][j])
      --j;
    else
      --i;
  }
  reverse(res.begin(), res.end());
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 35584
#include<iostream>
#include<cmath>
#include<algorithm>
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<<#X<<": "<<X<<" ";
#define ARDEB(i,X) cout<<#X<<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(X) {}
#define END {}
#endif
using namespace std;
int main(){
	/*int n,a[2001];
	int m,c[1001];
	cin>>n>>m;
	for(int i=0;i<n*2;i++)a[i]=i+1;
	/*for(int i=0;i<m;i++){
		cin>>c[i];
		if(c[i]==0){
			
			}
		}
	}
	for(int j=1;j<n;j++){
		swap(a[j],a[n+j-1]);
		for(int j=0;j<n*2;j++)cout<<a[j]<<" ";
		cout<<endl;
		swap(a[n+j-1],a[j+1]);
		for(int j=0;j<n*2;j++)cout<<a[j]<<" ";
		cout<<endl;
		swap(a[j+2],a[j+3]);
		for(int j=0;j<n*2;j++)cout<<a[j]<<" ";
		cout<<endl;
	}
	for(int j=0;j<n*2;j++)cout<<a[j]<<" ";*/
	int k;
	cin>>k;
	if(k/10==9 || k%10==9)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  bool ans = true;
  
  rep(i,n){
    if(a[i]%2==1) continue;
    else{
      if(a[i]%3!=0 && a[i]%5!=0){
        ans = false;
        break;
      }
    }
  }
  
  if(ans==true) dunk("APPROVED");
  else dunk("DENIED");
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N, D, X, a;
    cin >> N >> D >> X;
    int ans = X;
    rep(0, i, N)
    {
        cin >> a;
        ans += 1 + (D - 1) / a;
    }
    cout << ans << endl;
}

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

int main()
{
    string s,t;
    cin >> s >> t;
    int i;
    vector<char> arr1(26,'A');
    vector<char> arr2(26,'A');
    for(i = 0;i < s.size();++i){
        if(arr1.at((int)s.at(i)-97) != 'A' || arr2.at((int)t.at(i)-97) != 'A'){
            if(arr1.at((int)s.at(i)-97) != t.at(i) || arr2.at((int)t.at(i)-97) != s.at(i)){
                cout << "No" << endl;
                return 0;
            }
        }else{
            arr1.at((int)s.at(i)-97) = t.at(i);
            arr2.at((int)t.at(i)-97) = s.at(i);
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <limits.h>
using namespace std;
typedef long long ll;
const int inf=1<<30;
const int INF=INT_MAX;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, c[26];
  for(int i = 0; i < 26; ++i) {
    c[i] = 1;
  }
  cin >> n;
  char ch;
  for(int i = 0; i < n; ++i) {
    cin >> ch;
    ++c[ch - 'a'];
  }
  ll ans = 1;
  for(int i = 0; i < 26; ++i) {
    ans = (ans * (ll)c[i]) % (1000000007);
  }
  if(ans == 0) {
    ans = 1000000001;
  } else {
    ans -= 1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#encoding utf-8

n, k = map(int, input().split())

count = 0
if k == 0:
    count = n**2
else:
    for i in range(k, n+1):
        count += int(n/i)*(i-k)
        if (n%i-k >= 0):
            count += n%i-k+1
print(count)


Measured memory_bytes: 2940
#include<stdio.h>

int main(){
	int W,H,x,y,r;
	scanf("%d",&W);
	scanf("%d",&H);
	scanf("%d",&x);
	scanf("%d",&y);
	scanf("%d",&r);
	
	//top check
	if((x-r)>=0 && (x+r)<=W &&(y-r)>=0 && (y+r)<=H) printf("Yes\n");
	else printf("No\n");
	return 0;	
}


Measured memory_bytes: 2112
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function lower_bound(d,a,b,e){for(var c;1<b-a;)d[c=a+b>>1]<e?a=c:b=c;return d[a]<e?b:a};

console.log(main());
function main(){
  var n = o.a(), m = o.a();
  var a = o.l();
  a.sort((a,b)=>a-b);
  var ok = 0, ng = a[n-1]*2+1;
  while(ng-ok > 1){
    var mid = ok+ng >> 1;
    var cnt = n*n;
    for(var i = 0; i < n; i++){
      cnt -= lower_bound(a,0,n,mid-a[i]);
    }
    if(cnt >= m)ok = mid;
    else ng = mid;
  }
  var b = Array(n+1);
  b[0] = 0;
  for(var i = 0; i < n; i++)b[i+1] = b[i]+a[i];
  var ans = 0;
  var cnt = n*n;
  for(var i = 0; i < n; i++){
    var id = lower_bound(a,0,n,ok-a[i]+1);
    cnt -= id;
    ans += a[i]*(n-id) + b[n] - b[id];
  }
  return ans + (m-cnt) * ok;
}

Measured memory_bytes: 28500
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
const int MAXN=2e5+10;
int N;
vector<int>G[MAXN];
int c[MAXN];
ll ans[MAXN];
ll cal(int n)
{
    return (ll)n*(n+1)/2;
}
int num[MAXN];
int csz[MAXN];
void dfs(int rt,int fa)
{
    csz[rt]=1;
    int cl=c[rt];
    int t=num[cl];
    for(int v:G[rt]){
        if(v==fa)continue;
        int cur=num[cl];
        dfs(v,rt);
        int tmp=csz[v]-(num[cl]-cur);
        ans[cl]-=cal(tmp);
        csz[rt]+=csz[v];
    }
    num[cl]=t+csz[rt];
}
void solve()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    for(int u=1;u<=N;u++)cin>>c[u];
    for(int u=0;u<N-1;u++){
        int a,b;
        cin>>a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for(int c=1;c<=N;c++)ans[c]=cal(N);
    dfs(1,0);
    for(int c=1;c<=N;c++){
        ans[c]-=cal(N-num[c]);
        cout<<ans[c]<<'\n';
    }
}
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    solve();
}

Measured memory_bytes: 37164
#include <bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


struct UnionFind{
    int par[MAX];
    int kosuu[MAX];
    UnionFind(int n){
        REP(i,n) par[i]=i;
        REP(i,n) kosuu[i] = 1;
    }

    int root(int x){
        int tmp;
        if(par[x]==x) return x;
        else{
            tmp=root(par[x]);
            par[x]=tmp;
            return tmp;
        }
    }

    bool same(int x,int y){
        return root(x) == root(y);
    }

    void unite(int x,int y){
        if(not same(x,y)){ 
        kosuu[root(y)] += kosuu[root(x)];
        par[root(x)] = root(y);
        }
    }

    int renketu_kosuu(int x){
        return kosuu[root(x)];
    }
};


signed main(){
    int n,m;
    cin >> n >> m;
    UnionFind u(n + 1);
    int x,y,z;
    REP(i,m){
        scanf("%lld%lld%lld",&x,&y,&z);
        u.unite(x,y);
    }
    int check[n+1] = {};
    int ans = 0;
    FOR(i,1,n+1){
        check[u.root(i)] ++;
        if(check[u.root(i)] == 1) ans ++;

    }
    cout << ans << endl;

}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define FOR(i, j, k, in) for (int i = j; i < k; i += in)
#define RFOR(i, j, k, in) for (int i = j; i >= k; i -= in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> ais(n), bis(m), sbis(m);
    REP(i, n)
    cin >> ais[i];
    REP(i, m)
    cin >> bis[i];
    partial_sum(begin(bis), end(bis), begin(sbis));
    ll best = (ll)distance(begin(sbis), upper_bound(begin(sbis), end(sbis), k));
    ll s = 0ll;
    REP(i, n) {
        if (ais[i] + s > k) break;
        s += ais[i];
        ll current = (ll)i + 1ll + (ll)distance(begin(sbis), upper_bound(begin(sbis), end(sbis), k - s));
        best = max(best, current);
    }
    cout << best << endl;
}

Measured memory_bytes: 7952
#include <atcoder/all>
#include <iostream>
#include <vector>

using namespace std;
using namespace atcoder;

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<int64_t> a(N), b(M);
    for(int i=0; i<N; i++) {
        cin >> a[i];
    }
    for(int i=0; i<M; i++) {
        cin >> b[i];
    }

    vector<int64_t> c = convolution(a, b);

    for(auto e: c) {
        cout << e << ' ';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 27284
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,sum = 0,ans = 0;
  vector<int> x(100);
  cin >> n;
  for(int i = 0; i < n; i++){
	cin >> x.at(i);
    sum += x.at(i);
  }
  sum = round((double)sum/n);
  for(int i = 0; i < n; i++){
    ans += (x.at(i) - sum)*(x.at(i) - sum);
  }
  cout << ans << endl;
}

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

#define pr pair<int, int>

using namespace std;

const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;


//#define DEBUG

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

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;
}


int a[10010][10010], b[1000];
int dp[10010][3];
 

int main()
{
    int N, M; cin >> N >> M;
    cout << ((N * (N-1)) + (M * (M-1)))/2 << endl;

    

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int a[1000], i, j, N, flag=0;
	N = 3;
	for (i = 0;i < N;i++) {
		cin >> a[i];
		flag++;
		for (j = 0;j < i;j++) {
			if (a[i] == a[j]) {
				flag--;
				j = i;
			}
		}
	}
	cout << flag << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>

using namespace std;
string st;
long long ans,len;
int main()
{
 cin>>st;
 len=st.size();
 for(int i=0;i<len;i++)
 {
  if(i!=0&&i!=len-1) ans++;
 }
 cout<<st[0]<<ans<<st[len-1];
 return 0;
}



Measured memory_bytes: 256
#! -*- coding:utf-8 -*-
import math
n = input()
for x in xrange(n):
    x1,y1,x2,y2,x3,y3 = map(float,raw_input().split())
    a1 = 2.0*(x2-x1)
    b1 = 2.0*(y2-y1)
    x12 = x1**2
    y12 = y1**2
    c1 = x12-x2**2+y12-y2**2
    a2 = 2.0*(x3-x1)
    b2 = 2.0*(y3-y1)
    c2 = x12-x3**2+y12-y3**2
    denom=(a1*b2-a2*b1)
    # print "x1^2 : "+str(x12)
    # print "y1^2 : "+str(y12)
    # print "a1 : "+str(a1)
    # print "b1 : "+str(b1)
    # print "c1 : "+str(c1)
    # print "a2 : "+str(a2)
    # print "b2 : "+str(b2)
    # print "c2 : "+str(c2)
    # print "denom : "+str(denom)
    x = (b1*c2-b2*c1)/denom
    y = (c1*a2-c2*a1)/denom
    r = math.sqrt((x-x1)**2+(y-y1)**2)

    print "%.3f %.3f %.3f"%(x,y,r)

Measured memory_bytes: 6436
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    int N, M;
    cin >> N >> M;
    int a[M] = {0};
    int b[M] = {0};
    
    for(int i = 0; i < M; i++)
    {
        cin >> a[i];
        cin >> b[i];
    }

    int num[N] = {0};
    for(int i = 0; i < M; i++)
    {
        num[a[i]-1]++;
        num[b[i]-1]++;
    }     

    for(int i = 0; i < N; i++)
    {
         cout << num[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
from sys import stdin
from fractions import gcd
from functools import reduce

def gcd_l(l):
    return reduce(gcd, l)

N, K = [int(_) for _ in stdin.readline().rstrip().split()]
A = [int(_) for _ in stdin.readline().rstrip().split()]
ans = gcd_l(A)
if K % ans == 0 and max(A) >= K:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 88172
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var nm = Console.ReadLine().Split(' ');
                int n = int.Parse(nm[0]), m = int.Parse(nm[1]);
                if (n + m == 0) break;

                var a = new int[m];
                while (n-- != 0)
                {
                    var t = Console.ReadLine().Split(' ')
                        .Select(int.Parse)
                        .ToArray();
                    for (int i = 0; i < m; i++)
                    {
                        a[i] += t[i];
                    }
                }
                var l = a.Select((v, i) => new KeyValuePair<int, int>(i + 1, v))
                    .OrderByDescending(kvp => kvp.Value)
                    .ThenBy(kvp => kvp.Key).ToArray()
                    .Select(kvp => kvp.Key.ToString()).ToArray();
                Console.WriteLine(string.Join(" ", l));
            }
        }
    }
}

Measured memory_bytes: 6736
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
 
//INSERT ABOVE HERE
signed main(){
  Int n,v;
  cin>>n>>v;
  vector<Int> x(n);
  for(Int i=0;i<n;i++) cin>>x[i];
 
  vector<vector<Int> > dpl,dpr;
  while(1){
    {
      vector<Int> dp(n);
      dp.back()=n;
      for(Int i=n-2;i>=0;i--){
	if(x[i+1]-x[i]<=v) dp[i]=dp[i+1];
	else dp[i]=i+1;
      }
      dpl.emplace_back(dp);
    }
    {
      vector<Int> dp(n);
      dp.front()=-1;
      for(Int i=1;i<n;i++){
	if(x[i]-x[i-1]<=v) dp[i]=dp[i-1];
	else dp[i]=i-1;
      }
      dpr.emplace_back(dp);
    }
    if(!v) break;
    v>>=1;
  }
 
  Int k=dpl.size();
  vector<Int> dp(1<<k,0);
  vector<Int> pd(1<<k,n-1);
  
  for(Int b=0;b<(1<<k);b++){
    for(Int i=0;i<k;i++){
      if((b>>i)&1) continue;
      chmax(dp[b|(1<<i)],(dp[b]<n?dpl[i][dp[b]]:n));
      chmin(pd[b|(1<<i)],(~pd[b]?dpr[i][pd[b]]:-1));
    }
  }
 
  vector<Int> ans(n+1);
  
  
  for(Int b=0;b<(1<<k);b+=2){
    Int a=((1<<k)-2)^b;
    Int c=dp[a]<n?dpl[0][dp[a]]:n;
    if(pd[b]>=c) continue;
    ans[dp[a]]++;
    ans[c]--;
    continue;
    cout<<a<<" "<<b<<endl;
    cout<<dp[a]<<" "<<pd[b]<<" "<<c<<endl;
    cout<<endl;
  }
  
  
  for(Int i=0;i<n;i++){
    cout<<(ans[i]?"Possible":"Impossible")<<endl;
    ans[i+1]+=ans[i];
  }
  return 0;
}

Measured memory_bytes: 73060
S = input()
T = input()
for i in range(len(S)):
    cnt = i+1
    flag = True
    for j in range(len(S)):
        if cnt >= len(S):
            cnt = 0
        if T[j]!=S[cnt]:
            flag = False
            break
        cnt+=1
    if flag:
        break
print("Yes") if flag else print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!

void solve(){
    ll n,k,q;
    cin>>n>>k>>q;
    
    k-=q;// decrease the points of each individual by q(for q right answers)
    
    vll right(n+1,k);
    for(ll i=0;i<q;i++){
        ll x;
        cin>>x;
        right[x]++;
    }
    for(ll i=1;i<=n;i++){
        
        if(right[i]>0){
            cout<<"Yes";
        }
        else{
            cout<<"No";
        }
        cout<<endl;
    }
}



int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 3956
def p_d():
    H, W, K = map(int, input().split())
    mod = 10 ** 9 + 7
    dp = [0] * W
    dp[0] = 1
    fib = [1, 1]
    for i in range(2, W):
        fib.append(fib[i - 2] + fib[i - 1])
    some = [0] * W
    for i in range(W):
        some[i] = fib[i] * fib[W - i - 1]
    some_2 = [0] * (W - 1)
    for i in range(W - 1):
        some_2[i] = fib[i] * fib[W - i - 2]
    for i in range(1, H + 1):
        w = 0
        NEXT = [0] * W
        for j in range(W):
            if j > 0:
                NEXT[j - 1] += dp[j] * some_2[j - 1]
                NEXT[j - 1] %= mod
            if j < W - 1:
                NEXT[j + 1] += dp[j] * some_2[j]
                NEXT[j + 1] %= mod
            if dp[j] > 0:
                NEXT[j] += dp[j] * some[j]
                NEXT[j] %= mod
            w += 1
        dp = NEXT
    print(dp[K - 1] % mod)


if __name__ == '__main__':
    p_d()


Measured memory_bytes: 38256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
long long int h[200000],d[200000];
long long int i,n,m,j,k,l=0;
struct ss
{
    int f,t,k;
    long long int c;
}a[200000];
void  sk(int u,int v, long long int w)
{
    a[l].c=w;
    a[l].f=u;
    a[l].t=v;
    a[l].k=h[u];
    h[u]=l++;
}
void dfs(int u,int f)
    {
        for(int i=h[u];i!=-1;i=a[i].k)
        {
            int to=a[i].t;
            if(to==f) continue;
            d[to]=d[u]+a[i].c;
            dfs(to,u);
        }
    }
int main()
{
    int x,y,s1,s2,k1,k2;
    long long int z;
    scanf("%lld",&n);
    memset(h,-1,sizeof(h));
    memset(d,0,sizeof(d));
    for(i=1;i<=n-1;i++)
    {
        scanf("%d %d %lld",&x,&y,&z);
        sk(x,y,z);
        sk(y,x,z);
    }
    scanf("%d %d",&k1,&k2);
    dfs(k2,-1);
    for(int i=1;i<=k1;i++)
    {
        scanf("%d %d",&s1,&s2);
        printf("%lld\n",d[s1]+d[s2]);
    }
    return 0;
}


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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string S;
cin>>S;
int S1=stoi(S.substr(0,2));
int S2=stoi(S.substr(2,4));

if((S1>12||S1==0) && S2<=12 && S2>0)cout<<"YYMM"<<endl;
else if((S2>12||S2==0) && S1<=12 && S1>0)cout<<"MMYY"<<endl;
else if((S1>12 && S2>12)||S1==0||S2==0)cout<<"NA"<<endl;
else cout<<"AMBIGUOUS"<<endl;


//system("pause");
return 0;
}

Measured memory_bytes: 256
//#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 F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, d[N], c[N], ost[N], ans, res;

inline int f (int x) {
   int res = 0;
   while (x) {
      ans ++;
      res += x % 10;
      x /= 10;
   }   
   ans --;
   return res;
}

inline int calc (int dig, int kol) {
   int now = dig;
   int used = 0;
   bool ok = 0;
   ans = 0;
   kol --;
   while (1) {
      while (now > 9) now = f (now);
      if (kol == 0) break;
      if (used > 0 && now == dig && !ok) {
         ok = 1;
         ans += (kol / used) * ans;
         kol %= used;          
      }
      if (kol == 0) break;
      now += dig;
      ans ++;
      kol --;       
      used ++;
   }
   res += ans;
   return now; 
}

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n;
   for (int i = 1; i <= n; i ++) {
      cin >> d[i] >> c[i];
      ost[i] = calc (d[i], c[i]);
   }
   int kol = ost[1];
   for (int i = 2; i <= n; i ++) {
      if (kol + ost[i] > 9) res += 2, kol = f (kol + ost[i]);
      else res ++, kol += ost[i];     
   }
   cout << res;
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
int main(){map<int,int>HIM;vector<int>v;int n,ans,i,MC;cin>>n;for(i=1;i<=n;i++){cin>>MC;if(HIM[MC]==0)v.push_back(MC);HIM[MC]++;}for(i=0;i<v.size();i++) {if(HIM[v[i]]>=v[i])ans+=HIM[v[i]]-v[i]; else ans+=HIM[v[i]];}cout<<ans<<endl;return 0;}

Measured memory_bytes: 5112
n = int(input())
A = list(map(int, input().split()))

def gcd(x, y):
  if x < y:
    x, y = y, x
  tem = x%y
  ans = y
  while tem != 0:
    yn = tem
    tem = y%yn
    if tem == 0:
      ans = yn
      break
    y = yn
  return ans
  
ansl = []
L = [0]*(n-1)
R = [0]*(n-1)

L[0] = A[0]
for i in range(1, n-1):
  L[i] = gcd(L[i-1],A[i])

R[n-2] = A[n-1]
for i in range(n-3,-1,-1):
  R[i] = gcd(R[i+1],A[i+1])
  
for i in range(n):
  if i == 0:
    ansl.append(R[i])
  elif i == n-1:
    ansl.append(L[i-1])
  else:
    ansl.append(gcd(L[i-1],R[i]))

print(max(ansl))

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

ll calc(ll a,ll b){
  if(!b) return 1;
  if(b%2) return (a*calc(a,b-1))%MOD;
  ll d=calc(a,b/2);
  return (d*d)%MOD;
}

ll modcom(ll a,ll b){
  if(a<b) return 0;
  if(a/2<b) b=a-b;

  ll rtn=1;
  for(ll i=a;i>a-b;i--){
    rtn*=i;
    rtn%=MOD;
  }
  for(ll i=b;i>0;i--){
    rtn*=calc(i,MOD-2);
    rtn%=MOD;
  }
  return rtn;
}

int main(){
  ll x,y,ans=0;cin>>x>>y;
  ll n=2*y-x,m=2*x-y;
  if(!(n%3)&&!(m%3)&&n>=0&&m>=0) ans=modcom((n+m)/3,n/3);
  cout<<ans;
}

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

#include <string.h>
int main() {
    string s1;
    cin >> s1;
    int cnt = 0;

    if (s1[0] == '1') cnt++;
    if (s1[1] == '1') cnt++;
    if (s1[2] == '1') cnt++;

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

int64_t table[51][51];

// パスカルの三角形で二項係数を計算
void InitializeTable(const int n)
{
    for (int i = 0; i <= n; ++i)
    {
        for (int j = 0; j <= i; ++j)
        {
            if (j == 0 || j == i)
            {
                table[i][j] = 1;
            }
            else
            {
                table[i][j] = table[i - 1][j - 1] + table[i - 1][j];
            }
        }
    }
}

int main()
{
    int n, a, b;
    std::cin >> n >> a >> b;

    InitializeTable(n);

    std::vector<int64_t> arr(n);
    for (int i = 0; i < n; ++i)
    {
        int64_t v;
        std::cin >> v;
        arr[i] = v;
    }
    // 降順でソート
    std::sort(arr.begin(), arr.end(), std::greater<int64_t>());

    const int m = std::distance(arr.begin(), std::find(arr.begin(), arr.end(), arr[a - 1]));
    const int count = std::count(arr.begin(), arr.end(), arr[a - 1]);
    int64_t combination = 0;
    if (m != 0)
    {
        const int k = a - m;
        combination = table[count][k];
    }
    else
    {
        for (int k = a; k <= b; ++k)
        {
            combination += table[count][k];
        }
    }

    const int64_t sum = std::accumulate(arr.begin(), arr.begin() + a, static_cast<int64_t>(0));
    const double ave = static_cast<double>(sum) / a;

    std::cout.precision(20);
    std::cout << std::fixed << ave << std::endl;
    std::cout << combination << std::endl;

    return 0;
}


Measured memory_bytes: 3852
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProblemD
{
    class Program
    {
        // Reg 061 C
        static void Main(string[] args)
        {
            var S = Console.ReadLine().ToCharArray();
            var iter = Math.Pow(2,  (S.Length - 1));
            long res = 0;
            for (int i = 0; i < iter; i++)
            {
                long resTemp = 0;
                string temp = "";
                //String bit = Convert.ToString(i, 2);
                for (int j = S.Length - 2; j >= 0; j--)
                {
                    if ((i & 1 << j) == 0)
                        temp += S[S.Length - j - 2];
                    else
                    {
                        temp += S[S.Length - j - 2];
                        resTemp += long.Parse(temp);
                        temp = "";
                    }
                }
                resTemp += long.Parse(temp + S.Last());
                res += resTemp;
            }
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 27932
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
        

fast();
//ll t;cin>>t;while(t--)
{
    ll n;
    cin>>n;
     if(n>=30)
      Yes
    else
      No
}
return 0;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define fill(x,v) memset(x, v, sizeof(x))
#define endl '\n' 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define IO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
const ld eps=(ld)1e-9;
const ld PI=(ld)acos(-1.0);
const int inf=1e9+5;
const ll linf=1e18L+5;
const int mod=1e9+7;

void solve(){
	string s,a,b,t;
	a="dream";b="erase";
	cin>>s;
	int n=s.length(),f=1;
	for (int i = 0; i < n; ++i)
	{
		t=s.substr(i,5);
		if(t.length()==5){
			if(t==a){
				if(i+6<n && s.substr(i+5,2)=="er"){
					if(i+10<n && s.substr(i+5,6)==b+"r"){
						i+=10;
					}
					else if(i+9<n && s.substr(i+5,5)==b){
						i+=9;
					}
					else i+=6;
				}
				else{
					i+=4;
				}
			}
			else if(t==b){
				if(i+5<n && s[i+5]=='r'){
					i+=5;
				}
				else i+=4;
			}
			else{
				f=0;
			}
		}
		else {
			f=0;
		}
	}
	cout<<(f==1?"YES":"NO");
}
int main(){fio;
int test=1;
// cin>>test;
while(test--){
	solve();
	cout<<endl;
}
return 0;
}


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

int
main()
{
	char str[1001];
	scanf("%s", str);

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

	char order[10];
	char p[1001];
	int a, b;
	int ni, si;
	for (ni = 0; ni < n_orders; ni++)
	{
		scanf("%s", order);
		if (strcmp(order, "print") == 0)
		{
			scanf("%d %d", &a, &b);
			for (si = a; si <= b; si++)
			{
				putchar(str[si]);
			}
			putchar('\n');
			continue;
		}
		if (strcmp(order, "reverse") == 0)
		{
			scanf("%d %d", &a, &b);
			strcpy(p, str);
			for (si = a; si <= b; si++)
			{
				str[si] = p[a+b-si];
			}
			continue;
		}
		if (strcmp(order, "replace") == 0)
		{
			scanf("%d %d %s", &a, &b, p);
			for (si = a; si <= b; si++)
			{
				str[si] = p[si-a];
			}
			continue;
		}
	}

	return 0;
}

Measured memory_bytes: 588
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main()
{
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> a(q);
	rep(i, q) cin >> a.at(i);
	vector<int> score(n, k-q);
	rep(i, q) {
		score.at(a.at(i) - 1)++;
	}
	rep(i, n) {
		if (score.at(i) > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll n,a,b;
	cin>>n>>a>>b;
	ll ans = min(n*a,b);
	cout<<ans<<"\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


Measured memory_bytes: 3592
import sys
sys.setrecursionlimit(100000000)

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

if M == 0:
    A = []
else:
    A = [0]*M
    for i in range(M):
        A[i] = int(input())

A.append(N+1)

# DP version
DP = [0]*(N+1)
DP[0] = 1
# １段の階段を登るやり方の数
DP[1] = 1
# 2段の階段を登るやり方の数
#DP[2] = 2

for i in range(2,N+1):
    DP[i] = DP[i-1] + DP[i-2]

def step_comb(L):
    if DP[L]>0:
        return DP[L]
    DP[L] = step_comb(L-1) + step_comb(L-2)
    return DP[L]
    
total_comb = 1
NOW = 0
for a in A:
    if NOW == a:
        print(0)
        sys.exit()
    L = a-1-NOW
    total_comb *= step_comb(L)
    NOW = a + 1
    if NOW == N:
        break
    
print(total_comb % 1000000007 )


Measured memory_bytes: 463988
//author : Simanta Turja
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int sz = ( int ) s.size();
    if ( s[0] != 'A' ) {
        puts("WA");
        return 0;
    }
    int cnt = 0;
    for ( int i = 2; i < sz - 1; i++ ) {
        if( s[i] == 'C' )
            cnt++;
    }
    if ( cnt != 1 ) {
        puts("WA");
        return 0;
    }
    for ( int i = 1; i < sz; i++ ) {
        if ( s[i] >= 'A' && s[i] <= 'Z' && s[i] != 'C' ) {
            puts("WA");
            return 0;
        }
    }
    puts("AC");
    return 0;
}

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

int W=0;
int a=0;
int b=0;

cin>>W>>a>>b;

if(a<=b && b<=a+W || a<=b+W && b+W<=a+W){
	cout<<0;
}else{
if(a+W<b)cout<<b-a-W;
if(b+W<a)cout<<a-b-W;
}

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	lint N, K;
	cin >> N >> K;
	vector<int>D(K);
	int n = 0;
	rep(i, K) {
		cin >> D[i];
	}
	int cnt = 0;
	while (1) {
		n = N;
		while (n != 0) {
			rep(i, K) {
				if (n % 10 == D[i]) {
					cnt++;
				}
			}
				n /= 10;
				//cout << n <<'n'<< endl;
		}
		//cout << cnt << 'c' << endl;
		if (cnt == 0) {
			cout << N << endl;
			return 0;
		}
		cnt = 0;
		N++;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include <iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {X=X;}
#define TF(f) {f=f;}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 1000000;
#define NMAX 50
#define MAX 10

    int N,M,A,B;
    string S;
    ll X,ans=0;

    bool fir=true;



int main(){
    ios_base::sync_with_stdio(false);
    cin>>X;
    ans=(X/11)*2;
    if(X%11==0){}
    else if((X%11)<=6){
      ans++;
    }else{
      ans+=2;
    }
    cout<<ans;

}
//ABC057 Maximum Average Sets


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

const int MAX_N = 1000000;
int n;
int ptr;
bool isPrime[MAX_N+1];
int prime[MAX_N];

int main()
{
  prime[ptr++] = 2;
  for(int i=2; i<=MAX_N; i*=2) isPrime[i] = true;
  for(int i=3; i<=MAX_N; i+=2){
    if(!isPrime[i]){
      prime[ptr++] = i;
      for(int j=2*i; j<=MAX_N; j+=i){
        isPrime[j] = true;
      }
    }
  }

  while(cin >> n){
    cout << (upper_bound(prime, prime+ptr, n) - prime) << endl;
  }

  return 0;
}

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

const int N = 305;

int a[N][N];
bool mark[N];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			char c;
			cin >> c;
			a[i][j] = (c - 'a');
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
			//	cout << i << " " << j << " " << k << " " << (j + k) % n << " " << (i - k + n) % n << endl;
				if (a[i][j] != a[(j + k) % n][(i - k + n) % n]) {
					mark[k] = true;
				}
			}
		}
	}
	int ans = 0;
	for (int k = 0; k < n; k++) {
		if (!mark[k]) {
			ans += n;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
using namespace std;
using ll = long long;
const int mod = 10000007;

ll n, h[100000], memo[100000], ans;

ll dp(int num);
int main() {
	fill(memo, memo + 100000, -1);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	memo[0] = 0;
	memo[1] = abs(h[1] - h[0]);
	cout << dp(n - 1) << endl;
}
ll dp(int num) {
	if (memo[num] == -1) {
		memo[num] = min(dp(num - 2) + abs(h[num] - h[num - 2]), dp(num - 1) + abs(h[num] - h[num - 1]));
	}
	return memo[num];
}


Measured memory_bytes: 4864