akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n,m;
	int i,j;
	cin >> n >> m;
	int coins[m];
	for(int i=0;i<m;i++)
	{
		cin >> coins[i];	
	}
	sort(coins, coins+m);
	int dp[n+1][m+1];
	for(i=0;i<=n;i++)
		for(j=0;j<=m;j++)
			dp[i][j]=0;

	for(i=0;i<=n;i++)
	{
		dp[i][1]=i;
	}


	for(i=2;i<=m;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(j-coins[i-1] >= 0)
			dp[j][i] = min(dp[j][i-1], dp[j-coins[i-1]][i]+1);
			else
				dp[j][i] = dp[j][i-1];
		}
	}
	/*for(i=0;i<=n;i++)
	{
		for(j=0;j<=m;j++)
		{
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/
	cout << dp[n][m] << endl;
	return 0;
}

Measured memory_bytes: 5276
import sys
sys.setrecursionlimit(10**9)

N, M = map(int, input().split())
adjL = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    adjL[A-1].append(B-1)
    adjL[B-1].append(A-1)

if M % 2:
    print(-1)
    sys.exit()

def makeSpanningTree(vNow, vPar):
    useds[vNow] = True
    for v2 in adjL[vNow]:
        if v2 == vPar:
            pass
        elif useds[v2]:
            if vNow < v2:
                anss.append((vNow, v2))
                outdegs[vNow] += 1
        else:
            adjL2[vNow].append(v2)
            adjL2[v2].append(vNow)
            makeSpanningTree(v2, vNow)

anss = []
adjL2 = [[] for _ in range(N)]
outdegs = [0] * N
useds = [False] * (N)
makeSpanningTree(0, -1)

def dfs(vNow, vPar):
    for v2 in adjL2[vNow]:
        if v2 != vPar:
            dfs(v2, vNow)
    if outdegs[vNow] % 2:  # 出す
        anss.append((vNow, vPar))
        outdegs[vNow] += 1
    else:  # 入れる
        anss.append((vPar, vNow))
        outdegs[vPar] += 1

dfs(0, -1)
anss.pop()

print('\n'.join(map(lambda x: str(x[0]+1)+' '+str(x[1]+1), anss)))


Measured memory_bytes: 127284
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)

int main(){
 
 
  ll k,n;
  cin>>k>>n;
 
  vector<ll> A(n);
  rep(i,n){
      cin>>A[i];
  }
 ll ma=0;
  Rep(i,n){
    ma=max(ma,A[i]-A[i-1]);
  }
  ma=max(ma,k-A[n-1]+A[0]);
  cout<<k-ma<<endl;

 
}



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

bool ispri[100010];

void eratos(ll n){
    rep(i,0,floor(sqrt(n)))ispri[i]=1;
    ispri[0]=0;ispri[1]=0;
    rep(i,2,floor(sqrt(n))){
        ll j=2*i;
        while(j<=floor(sqrt(n))){
            ispri[j]=0;
            j+=i;
        }
    }
}

ll nisen[100010];

int main(){
    ll Q;cin>>Q;
    
    nisen[0]=0;
    eratos(10000000010);
    rep(i,1,100000){
        nisen[i]+=nisen[i-1];
        if(i%2==0)continue;
        if(ispri[i]&&ispri[(i+1)/2])nisen[i]++;

    }
    
    rep(i,0,Q){
        ll l,r;
        cin>>l>>r;
        cout<<nisen[r]-nisen[l-1]<<endl;
    }
}







Measured memory_bytes: 1536
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <bitset>
#include <limits.h>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//#define int long long

/*************** using variables ***************/
LL n, m;
/**********************************************/

signed main(){
    cin >> n >> m;
    
    if(n >= 3 && m >= 3){
        cout << (n-2)*(m-2) << endl;
    }else{
        if(n > m) swap(n, m);
        if(n == 2){
            cout << 0 << endl;
        }else{
            cout << max(1LL, m-2) << endl;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n, a[100010];
int main(void){
    // Your code here!
    cin >> n;
    bool ans = false;
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % 2) ans = true;
    }
    if (ans) cout << "first" << endl;
    else cout << "second" << endl;
}


Measured memory_bytes: 1024
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define sc(x) scanf("%lld",&x)
    #define pf(x) printf("%lld\n",x)
    #define int long long
    #define ld long double
    #define all(x) x.begin(),x.end() 
    #define rall(x) x.rbegin(),x.rend()
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int INF = 1e15;
    const int MAX = 2e6 + 7;
    const int MOD =  1000000007;
    const long double PI  =3.141592653589793238463;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ DEB $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;


    vector<string> vec_splitter(string s) 
    {
        for(char& c: s) c = c == ','?  ' ': c;
        stringstream ss; ss << s;
        vector<string> res;
        for(string z; ss >> z; res.push_back(z));
        return res;
    }
    void debug_out(vector<string> args, int idx) { cerr << endl; }
    template <typename Head, typename... Tail>
    void debug_out(vector<string> args, int idx, Head H, Tail... T) 
    {
        if(idx > 0) cerr << ", ";
        stringstream ss; ss << H;
        cerr << args[idx] << " = " << ss.str();
        debug_out(args, idx + 1, T...);
    }
    
    #ifdef XOX
    #define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
    #else
    #define debug(...) 42
    #endif

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    int m;
    void solve()
    {
        cin>>n>>m;
        cout<<(n*(n-1))/2+(m*(m-1))/2<<endl;
        
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);

        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        double k = 100.0;
        int cnt = 0;
        while(X > k){
            k *= 1.01;
            k = (long)k;
            cnt++;
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 35752
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
	    String S = scanner.next();
	    String T = scanner.next();
	    int A = scanner.nextInt();
	    int B = scanner.nextInt();
	    String U = scanner.next();
	    int a=A;
	    int b=B;
	    
	    if(S.equals(U)) {
	    	a = a - 1;
	    }else{
	    	b = b - 1;
	    }
	    System.out.println(a+" "+b);
	}

}

Measured memory_bytes: 38796
#include<stdio.h>
int main(void){
	int a,b,c,n,x;
	static int i=0;
	for(;;){
		scanf("%d %d",&n,&x);
	    if(n==0&&x==0){
			break;
		}else{
			for(a=1;a<=n;a++){
				for(b=1;b<=n;b++){
					for(c=1;c<=n;c++){
						if(a!=b&&b!=c&&c!=a){
						if(a+b+c==x){
							i++;
						}
						}
					}
				}
			}
			printf("%d\n",i/6);
			i=0;
		}
	}
	return 0;
}

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

using namespace std;

int main(){
  int n;
  cin>>n;
  vector<pair<int, int> > arr(n);
  for(int i=0;i<n;i++){
    int k;
    cin>>k;
    arr[i]={k,i};
  }
  sort(arr.begin(),arr.end());
  int c=1;
  int mx=1;
  for(int i=1;i<n;i++){
    if(arr[i].second<arr[i-1].second){
      c=1;
    }
    else{
      c++;
      if(c>mx){
        mx=c;
      }
    }
  }
  cout<<n-mx<<'\n';
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for (decltype(n) i = 0; i < n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define readvec(vec)    \
  for (auto& e : vec) { \
    cin >> e;           \
  }
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<string> vecstr;
typedef vector<char> vecchar;
typedef vector<bool> vecbool;
typedef vector<vector<bool>> vec2bool;
typedef vector<vector<int>> vec2int;
typedef vector<vector<double>> vec2d;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  string s;
  cin >> s;
  int n = s.size();
  vector<vecll> dp(n, vecll(13, 0));
  auto ctoi = [](char c) -> int { return c - '0'; };
  if (s[0] == '?') {
    for (int i = 0; i <= 9; i++) {
      dp[0][i] = 1;
    }
  } else {
    dp[0][ctoi(s[0]) % 13] = 1;
  }
  // REP(i, 13) { cout << i << " " << dp[0][i] << endl; }
  // cout << endl;
  for (int i = 1; i < n; i++) {
    if (s[i] == '?') {
      for (int j = 0; j <= 12; j++) {
        for (int k = 0; k <= 9; k++) {
          dp[i][(10 * j + k) % 13] += dp[i - 1][j];
          dp[i][(10 * j + k) % 13] %= MOD;
        }
      }
    } else {
      for (int j = 0; j <= 12; j++) {
        dp[i][(10 * j + ctoi(s[i])) % 13] += dp[i - 1][j];
        dp[i][(10 * j + ctoi(s[i])) % 13] %= MOD;
      }
    }
  }
  // REP(i, 13) { cout << i << " " << dp[1][i] << endl; }
  cout << dp[n - 1][5] << endl;
}


Measured memory_bytes: 13648
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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


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

    int a,b,c; cin >> a >> b >> c;

    if(c-b-a>0 && 4*a*b<(c-a-b)*(c-a-b)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  string s;
  cin >> s;
  ll ans = 0;
  int l = 0, r = s.size()-1;
  while (r - l > 0) {
    if (s[r] == s[l]) {
      l++;
      r--;
      continue;
    }
    if (s[r] == 'x') {
      ans++;
      r--;
      continue;
    }
    if (s[l] == 'x') {
      ans++;
      l++;
      continue;
    }
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
vector<int> G[100050];
int in_degree[100050];
stack<int> q1;
int d[100050];

int main()
{
    int n,m;
    cin>>n>>m;
    while(m--){
        int from , to;
        scanf("%d%d",&from,&to);
        G[from].push_back(to);
        in_degree[to]++;
    }
    for(int i=1;i<=n;i++){
        if(!in_degree[i]){
            q1.push(i);
        }
    }

    while(!q1.empty()){
        int v = q1.top();
        q1.pop();
        for(auto T:G[v]){
            d[T]=max(d[T],d[v]+1);
            in_degree[T]--;
            if(!in_degree[T])   q1.push(T);
        }

    }

    int ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans,d[i]);
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 6528
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> p;
#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 rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template <class T> bool chmax(T &a, const T &b) {
  if(a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if(b < a) {
    a = b;
    return 1;
  }
  return 0;
}

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

int main() {
  int k;
  cin >> k;
  map<ll, ll> m;
  for(int a = 1; a <= k; a++) {
    for(int b = 1; b <= k; b++) {
      ll g = gcd(a, b);
      m[g]++;
    }
  }
  ll ans = 0;
  for(int x = 1; x <= k; x++) {
    for(int c = 1; c <= k; c++) {
      ll g = gcd(x, c);
      ans += m[x] * g;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

string str;
int cur = 0;

int expression();
int term();
int factor();

int expression();

int digit() {
    int a = str[cur] - '0';
    cur++;
    return a;
}

int number() {
    int a = digit();
    while (cur < str.size() && isdigit(str[cur])) {
        a = a * 10 + digit();
    }
    return a;
}

int expression() {
    int a = term();
    while (cur < str.size() && (str[cur] == '+' || str[cur] == '-')) {
        if (str[cur] == '+') {
            cur++;
            int b = term();
            a += b;
        } else if (str[cur] == '-') {
            cur++;
            int b = term();
            a -= b;
        }
    }
    return a;
}

int term() {
    int a = factor();
    while (cur < str.size() && (str[cur] == '*' || str[cur] == '/')) {
        if (str[cur] == '*') {
            cur++;
            int b = factor();
            a *= b;
        } else if (str[cur] == '/') {
            cur++;
            int b = factor();
            a /= b;
        }
    }
    return a;
}

int factor() {
    if (str[cur] != '(') return number();
    cur++;
    int a = expression();
    cur++;
    return a;
}

int main() {
    int N = 0;
    cin>>N;
    for (int n = 0; n < N; n++) {
        cin>>str;
        cur = 0;
        cout<<expression()<<endl;
    }
}

Measured memory_bytes: 3024
N, M = map(int, input().split())
L = sorted([list(map(int, input().split())) for _ in range(M)])

ml = 0
mm = 10**7
for v in L:
    ml = max(ml, v[0])
    mm = min(mm, v[1])

if (mm - ml + 1 <= 0):
    print(0)
    exit()
print(mm - ml + 1)


Measured memory_bytes: 28664
#include <stdio.h>
 
void output(int* list,int listnum,int num,int max) {
    int i;
    if(num<=0) {
        printf("%d",list[0]);
        for(i=1;i<listnum;i++) {
            printf(" %d",list[i]);
        }
        puts("");
    } else {
        for(i=(max>num?num:max);i>0;i--) {
            list[listnum]=i;
            output(list,listnum+1,num-i,i);
        }
    }
}
 
int main(void) {
    int list[30];
    int n;
    while(1) {
        scanf("%d",&n);
        if(n==0)break;
        output(list,0,n,n);
    }
    return 0;
}

Measured memory_bytes: 1040
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

int main() {
  string S;
  cin >> S;

  uint32_t res = 1;

  char Prev = S[0];

  for (uint32_t i = 1; i < S.size(); ++i) {
    if (Prev == '0') {
      ++res;
      Prev = '1';
    } else if (Prev != S[i]) {
      ++res;
      Prev = S[i];
    } else {
      Prev = '0';
    }
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

class Dice
{
public:
    int f[6];
    Dice(){}
    void roll_z(){ roll(1, 2, 4, 3); }
    void roll_y(){ roll(0, 2, 5, 3); }
    void roll_x(){ roll(0, 1, 5, 4); }
    void roll(int i, int j, int k, int l){
        int t = f[i];
        f[i] = f[j];
        f[j] = f[k];
        f[k] = f[l];
        f[l] = t;
    }
    void move(char ch){
        if (ch == 'E') for (int i = 0; i < 3; i++) roll_y();
        if (ch == 'W') roll_y();
        if (ch == 'N') roll_x();
        if (ch == 'S') for (int i = 0; i < 3; i++) roll_x();
    }
};

int main()
{
    Dice dice;
    string dir;
    int q;
    for (int i = 0; i < 6; i++)
        cin >> dice.f[i];
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        int up, front, flag = 0;
        cin >> up >> front;
        while (1)
        {
            if (dice.f[0] == up)
            {
                flag = 1;
                break;
            }
            if (dice.f[1] == front)
            {
                flag = 2;
                break;
            }
            dice.roll_x();
        }
        while (1)
        {
            if (flag == 1)
            {
                if (dice.f[1] == front)
                {
                    break;
                }
                dice.roll_z();
            }
            else 
            {
                if (dice.f[0] == up)
                {
                    break;
                }
                dice.roll_y();
            }
        }
        cout << dice.f[2] << endl;
    }
    return 0;
}


Measured memory_bytes: 3056
#include <iostream>
#include <vector>
#include <cassert>

using namespace std;

int main() {
  int n, q;
  cin >> n >> q;
  vector<vector<int> > A(n);
  while(q--) {
    int k, t;
    cin >> k >> t;
    if(k == 0) {
      int x;
      cin >> x;
      A[t].push_back(x);
    } else if(k == 1) {
      for(int i = 0; i < (int)A[t].size(); ++i) {
	if(i) cout << " ";
	cout << A[t][i];
      }
      cout << endl;
    } else if(k == 2) {
      A[t].clear();
    } else {
      assert(false);
    }
  }
  return 0;
}



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


int main() {
 int N,M;
    cin>>N>>M;
    vector<int>AC(N,0);
    vector<int>WA(N,0);
    int ans=0,pena=0;
    rep(i,M){
        int n;
        string s;
        cin>>n>>s;
        if(s=="AC"&&AC[n-1]==0){
            AC[n-1]=1;
            ans++;
            pena+=WA[n-1];
        }
        else if(s=="WA"&&AC[n-1]==0){
            WA[n-1]++;
        }
    }
cout<<ans<<" "<<pena<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	long double sum = 0, a;
	for (int i = 1; i <= n; i++) {
		cin >> a;
		sum += 1.0 / a;
	}
	printf("%.10Lf", 1.0/sum);
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
 
public class Main {
 
  public static void main(final String[] ars) {
    final Scanner scanner = new Scanner(System.in);
    final int N = Integer.parseInt(scanner.next());
    final int M = Integer.parseInt(scanner.next());
    final List<Shop> list = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      list.add(new Shop(Long.parseLong(scanner.next()), Long.parseLong(scanner.next())));
    }
    list.sort(Comparator.comparingLong(e -> e.price));
 
    long price = 0;
    long count = 0;
    for (final Shop shop : list) {
      if (count + shop.count >= M) {
        price += (M - count) * shop.price;
        break;
      }
      count += shop.count;
      price += shop.count * shop.price;
    }
    System.out.println(price);
  }
}
 
 
class Shop {
  Long price;
  Long count;
 
  public Shop(final Long price, final Long count) {
    this.price = price;
    this.count = count;
  }
}

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

long long extgcd(long long a, long long b, long long& x, long long& y) {
	long long d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	} else {
		x = 1; y = 0;
	}
	return d;
}
int main(){
	long long N;
	long long K;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	scanf("%lld",&K);
	long long maxv = 0;
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
		maxv = max(maxv, A[i]);
	}

	long long g = A[0], x, y;
	for(int i = 1 ; i <= N-1 ; i++){
		g = extgcd(g, A[i], x, y);
	}

	if (K%g == 0 && K <= maxv) printf("POSSIBLE\n"); else printf("IMPOSSIBLE\n");

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main() {
    int a[3],i,d,e;
    e=0;
    d=0;
    for (i=0;i<3;i++){
        cin>>a[i];
        if (d<a[i]){
            d=a[i];
        }
    }
    for (i=0;i<3;i++){
        e=e+a[i];
    }
    cout<<e-d;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
dp=[0]*(10**5+1)
dp[100]=1
dp[101]=1
dp[102]=1
dp[103]=1
dp[104]=1
dp[105]=1
for i in range(106,10**5+1):
    if dp[i-100]==1:
        dp[i]=1
    elif dp[i-101]==1:
        dp[i]=1
    elif dp[i-102]==1:
        dp[i]=1
    elif dp[i-103]==1:
        dp[i]=1
    elif dp[i-104]==1:
        dp[i]=1
    elif dp[i-105]==1:
        dp[i]=1
print(dp[n])

Measured memory_bytes: 9624
#include <iostream>
#include <vector>
using namespace std;
vector<int> G[100010];
int dfs(int s,int p){
	int res = 0;
	for(int v:G[s]){
		if(v!=p){
			res ^= dfs(v,s);
		}
	}
	res++;
	return res;
}

int main(){
	int i,n;
	cin >> n;
	for(i=0;i<n-1;i++){
		int a,b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b); G[b].push_back(a);
	}
	if(dfs(0,-1)==1){
		cout << "Bob" << endl;
	}else{
		cout << "Alice" << endl;
	}
}

Measured memory_bytes: 10368
#include <cstdio>
#include <vector>
using namespace std;
using ll = long long int;
const ll MOD = 1000000007;

ll mod_pow(ll x, ll n) {
    if(n == 0) return 1;
    ll res = mod_pow((x * x) % MOD, n / 2);
    if(n & 1) res = (res * x) % MOD;
    return res;
}

// 髫惹ｹ mod p
vector<ll> fact;
void fact_mod(int n) {
    fact.resize(n+1);
    fact[0] = 1;
    for(int i=0; i<n; i++) {
        fact[i+1] = (fact[i] * (i+1)) % MOD;
    }
}

// 髫惹ｹ励�騾�� mod p
vector<ll> finv;
void fact_inv(int n) {
    finv.resize(n+1);
    finv[n] = mod_pow(fact[n], MOD-2);
    for(int i=n-1; i>=0; i--) {
        finv[i] = (finv[i+1] * (i+1)) % MOD;
    }
}

// fact, finv 繧剃ｽｿ縺｣縺ｦ邨�∩蜷医ｏ縺帙ｒ蜃ｺ縺
// 蝓ｺ譛ｬ逧�↓縺ｯ縺薙ｌ繧剃ｽｿ縺｣縺溘⊇縺�′縺�＞
ll combination_array(int n, int r) {
    if(n < 0 || r < 0 || n < r) return 0;
    ll x = fact[n];
    ll y = (finv[r] * finv[n-r]) % MOD;

    return (x * y) % MOD;
}

ll combination_duplicate(int x, int y) {
    return combination_array(x+y-1, y);
}

const int M = 6000010;
int main() {
    fact_mod(M);
    fact_inv(M);

    while(1) {
        ll A, B, C, X, Y; scanf("%lld%lld%lld%lld%lld", &A, &B, &C, &X, &Y);
        if(A + B + C + X + Y == 0) break;

        ll ans = 0;
        // diff 繧呈ｱｺ繧∵遠縺｡
        for(int D = 0; D <= X+Y; D++) {
            int free_pt = (X+Y-D) / 2, S = A+B+C;
            if( (X+Y-D) % 2 == 1 ) continue;
            if(free_pt > X || free_pt > Y) continue;

            // 蟾ｮ蛻�ｻ･螟悶�轤ｹ謨ｰ繧帝←蠖薙↓驟咲ｽｮ
            ll add = combination_duplicate(S, free_pt);

            // 蠑輔″蛻�￠縺ｮ菴咲ｽｮ
            (add *= combination_array(S, C)) %= MOD;

            // 蜍昴■縺ｮ菴咲ｽｮ
            (add *= combination_array(A+B, A)) %= MOD;

            // P, Q 縺ｮ險育ｮ (縺昴ｌ縺槭ｌ A 莉･荳翫�B 莉･荳翫〒縺ｪ縺代ｌ縺ｰ縺ｪ繧峨↑縺)
            int P = X - free_pt, Q = Y - free_pt;

            if(P < A || Q < B) continue;
            if(A == 0 && P > 0) continue;
            if(B == 0 && Q > 0) continue;
            P -= A, Q -= B;
            if(A > 0) (add *= combination_duplicate(A, P)) %= MOD;
            if(B > 0) (add *= combination_duplicate(B, Q)) %= MOD;

            (ans += add) %= MOD;
            // printf("D = %d, add = %lld\n", D, add);
        }
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 95876
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int r = 0, m = 0;
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;
        if (h >= m) r++;
        m = max(m, h);
    }

    cout << r << endl;

    return 0;
}

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

int main(){
  int n,m;
  cin>>n>>m;
  vector<int>h(n);
  for(int i=0;i<n;i++){
  cin>>h[i];
  }
  vector<int>x(n,1);
  for(int j=0;j<m;j++){
  int a,b;
  cin>>a>>b;
    if(h[a-1]>=h[b-1]){
    x[b-1]=0;
    }
    if(h[a-1]<=h[b-1]){
    x[a-1]=0;
    }
  }
  int ans=0;
  for(int k=0;k<n;k++){
  if(x[k]!=0){
  ans++;
  }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4048
/**
 *       Author:  kulubat
 *       Written on Tuesday, 14 April 2020.
 **/

#include <bits/stdc++.h>


using namespace std;


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

    vector<int> A(3);

    cin >> A[0]; cin >> A[1]; cin >> A[2];

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


    if(A[0] == 5 && A[1] == 5 && A[2] == 7)
        cout <<" YES" << "\n";
    else
        cout << "NO" << "\n";


    return 0;
    
}


Measured memory_bytes: 256
n = int(input())
mod = 1000000007
dp = [[[0]*4 for _ in range(4)] for _ in range(n+1)]
for j in range(4):
    for k in range(4): dp[2][j][k] = 1

for i in range(2,n):
    for j in range(4):
        for k in range(4):
            for l in range(4):
                if (j,k,l) in ((2,1,0),(1,2,0),(1,0,2)): continue
                dp[i+1][j][k] += dp[i][k][l]
                dp[i+1][j][k] %= mod
    dp[i+1][1][2] -= dp[i-1][2][0]
    dp[i+1][1][2] %= mod
    dp[i+1][1][3] -= dp[i-1][2][0]
    dp[i+1][1][3] %= mod
    dp[i+1][1][2] -= dp[i-1][3][0]
    dp[i+1][1][2] %= mod

ans = 0
for j in range(4):
    for k in range(4):
        ans += dp[n][j][k]
        ans %= mod
print(ans)

# for i in range(n+1): print(dp[i])

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+7;


int main()
{
    ll sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    ll h=ty-sy;
    ll w=tx-sx;
    rep(i,h){
        cout << 'U';
    }
    rep(i,w){
        cout << 'R';
    }
    rep(i,h){
        cout << 'D';
    }
    rep(i,w){
        cout << 'L';
    }
    cout << 'L';
    rep(i,h+1){
        cout << 'U';
    }
    rep(i,w+1){
        cout << 'R';
    }
    cout << 'D' << 'R';
    rep(i,h+1){
        cout << 'D';
    }
    rep(i,w+1){
        cout << 'L';
    }
    cout << 'U' << endl;
    return 0;
} 


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
    	Scanner scanner = new Scanner(System.in);
      
      	int N = scanner.nextInt();
 
      	if(N == 1) {
        	System.out.println("Yes");
          	return;
        }
      	for(int i = 2; i < 10; i++) {
      		if(N % i == 0 && (N / i) / 10 == 0) {
        		System.out.println("Yes");
         		return;
        	}
    	}
      	System.out.println("No");
	}
}
 

 



Measured memory_bytes: 25172
import sys

array_data = map(int, raw_input().split())
n = array_data[0]
m = array_data[1]
l = array_data[2]

a = []
for i in range(n):
	partial_a = map(int, raw_input().split())
	a.append(partial_a)

b = []
for j in range(m):
	partial_b = map(int, raw_input().split())
	b.append(partial_b)

c = []
for i in range(n):
	c.append([])
	for j in range(l):
		c[i].append([])
		wa = 0
		for k in range(m):
			wa += a[i][k] * b[k][j]
		c[i][j] = wa

for i in range(len(c)):
	for j in range(len(c[i])):
		if j != len(c[i])-1:
			sys.stdout.write("{:} ".format(c[i][j]))
		else:
			print(c[i][j])

Measured memory_bytes: 7240
var input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/g);
var s = input[0];
for (var i = 0; i < 8; i++) {
    var exp = s[0] + (i & 4 ? "+" : "-") + s[1] + (i & 2 ? "+" : "-") + s[2] + (i & 1 ? "+" : "-") + s[3];
    if (eval(exp) === 7){
        console.log(exp + "=7")
        process.exit();
    } 
}


Measured memory_bytes: 11340
//AUTHOR - NAVEEN KUMAR(@naveen19991124)
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#inlcude<boost/multiprecision/cpp_dec_float.hpp>
#define ll long long
#define ld long double
#define F first
#define S second
#define mem(v) memset(v,0,sizeof(v))
#define all(v) v.begin(), v.end()
#define srt(v) sort(all(v))
#define rsrt(v) sort(v.rbegin(),v.rend())
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define vll vector<ll>
#define mp make_pair
#define fir first
#define sec second
#define dbg1(a) cout<<a<<"\n";
#define dbg2(a,b) cout<<a<<" "<<b<<"\n";
#define hell 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
using namespace std:: chrono;
//using boost :: multiprecision :: cpp_int;
//using boost :: multiprecision :: cpp_dec_float_50;
//using boost :: multiprecision :: cpp_dec_float_100;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1;
a *= a; a %= mod;} return p % mod;}
ll modInverse(ll a, ll m) { ll m0 = m; ll y = 0, x = 1; 
if (m == 1) {return 0;} 
while (a > 1) { ll q = a / m; ll t = m;  m = a % m, a = t; t = y; y = x - q * y; x = t; } 
if (x < 0) {x += m0;} return x; } 
inline ll add(ll a, ll b) { return (((a >= hell) ? a % hell : a) + ((b >= hell) ? b % hell : b) + hell) % hell; }
inline ll subt(ll a, ll b) { return (a - b + hell) % hell; }
inline ll mult(ll a, ll b) { return (1ll * ((a >= hell) ? a % hell : a) * ((b >= hell) ? b % hell : b)) % hell; }
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
ll mylog(ll n,ll b)
{ll i = 1;ll ans = 0;
while(1)
{if(i>n/b){break;} i = i*b;ans++;}return ans;
}
bool compare(const pair<ll,ll> &a,const pair<ll,ll> &b){
if (a.first == b.first)
{return a.second<b.second;} 
return a.first<b.first;
}
bool comparerev(const pair<ll,ll> &a,const pair<ll,ll> &b){
if(a.first == b.first)
{return a.second>b.second;}
return a.first>b.first;
}
int main()
{
    fast
    ll t = 1;
   // cin>>t;
    while(t--){
    ll n;
    cin>>n;
    map<ll,ll>mm;
    f(n-1)
    {
        ll val;
        cin>>val;
        mm[val]++;
    }
    rep(i,1,n+1)
    {
        cout<<mm[i]<<"\n";
    }
    
    } 
    return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    string s;
    int K;
    cin >> s;
    cin >> K;
    vector<string> subStrings;
    set<string> subStringsSet;
    int sSize = s.size();
    for (int i = 1; i <= sSize; ++i)
    {
        for(int j = 0; j <= sSize - i; ++j)
        {
            // subStrings.push_back(s.substr(j, i));
            string subS = s.substr(j, i);
            if (subStringsSet.size() < K)
            {
                subStringsSet.insert(subS);
                if (subStringsSet.size() == K)
                {
                    subStrings.assign(subStringsSet.begin(), subStringsSet.end());
                    sort(subStrings.begin(), subStrings.end());
                }
            }
            else
            {
                bool isInclude = false;
                for (int i = 0; i < K; ++i)
                {
                    if (subStrings[i] == subS){
                        isInclude = true;
                        break;
                    }
                }
                if (!isInclude)
                {
                    for (int k = K - 1; k >= 0; --k)
                    {
                        if (subStrings[k] > subS)
                        {
                            if (k < K - 1) subStrings[k + 1] = subStrings[k];
                            subStrings[k] = subS;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
        }
    }

    cout << subStrings[K - 1] << endl;
}

Measured memory_bytes: 384
/*input
01100110 2
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ll long long 
#define ld long double
#define pii pair<int,int>
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define MP make_pair
const ll INF64=4e12;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1){
            res=(res*a)%MOD;
        }
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
const ll maxn=300+5;
const ll maxlg=__lg(maxn)+2;
int dp[maxn][maxn][maxn];
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    string s;
    int z;
    cin>>s>>z;
    s+="0";
    vector<int> v;
    int cnt=0;
    REP(i,sz(s)){
        if(s[i]=='1') ++cnt;
        else v.pb(cnt),cnt=0;
    }
    int tot=sz(s)-sz(v);
    MNTO(z,tot);
    vector<int> pref;
    REP(i,sz(v)){
        if(i) pref.pb(pref.back()+v[i]);
        else pref.pb(v[i]);
    }
    dp[0][0][0]=1;
    REP(i,sz(v)){
        REP(j,tot+1){
            REP(op,tot+1){
                if(dp[i][j][op]){
                    REP(cur,tot-j+1){
                        if(j+cur<pref[i]) continue;
                        dp[i+1][j+cur][op+max(cur-v[i],0)]+=dp[i][j][op];
                        dp[i+1][j+cur][op+max(cur-v[i],0)]%=MOD;
                    }
                }
            }
        }
    }
    ll ans=0;
    REP(i,z+1) ans+=dp[sz(v)][tot][i],ans%=MOD;
    cout<<ans;
}

Measured memory_bytes: 30608
n = int(input())

ans = 10

def F(a,b):
	return max(len(str(a)),len(str(b)))

i = 1
while i * i <= n:
	if n%i == 0:
		ans = min(ans,F(i,n//i))	
		#print(i,n//i)
	i += 1
print(ans)


Measured memory_bytes: 2940
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#pragma GCC optimize ("unroll-loops")
#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;

#define fi first
#define se second
#define pb push_back
#define sz(x)  ((int)x.size ())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define sqrt(x) sqrt (abs(x))
#define y0 y3451
#define y1 y4562
#define j0 j25624
#define j1 j45624
#define makeunique(x) sort(all(x)), (x).resize (unique(all(x)) - (x).begin())

typedef pair <int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef long double ld;
typedef unsigned int uint;
typedef vector <string> vs;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <vi> vvi;

template <class T> using _tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }
template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }

#define filename ""

const D pi = acos(-1.);
const int N = 2e5 + 20;
const int inf = 1e9 + 7;

int mod = inf;
int n;
ll dp[22][(1 << 21) + 10];
int a[30][30];
int ppc[(1 << 21) + 10];
bool was[22][(1 << 21) + 10];

inline ll go(int x, int mask) {
	if (x == 0 && mask == 0) re 1;
	if (was[x][mask]) re dp[x][mask];
	if (x != ppc[mask]) re 0;
	was[x][mask] = 1;
	for (int i = 0; i < n; i++)
		if ((mask & (1 << i)) && a[x - 1][i])
			dp[x][mask] = (dp[x][mask] + go(x - 1, mask ^ (1 << i))) % mod;
	re dp[x][mask];
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> a[i][j];
	for (int i = 0; i < (1 << n); i++)
		ppc[i] = __builtin_popcount(i);
	cout << go(n, (1 << n) - 1);
	
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    char ans[100][100];
    rep(i, 50)rep(j, 100) {
        ans[i][j] = '.';
        ans[i+50][j] = '#';
    }

    int x = 99, y = 99;
    while (A > 1) {
        ans[y][x] = '.';
        A--;
        x -= 2;
        if (x < 0) {
            x = 99;
            y -= 2;
        }
    }

    x = 0, y = 0;
    while (B > 1) {
        ans[y][x] = '#';
        B--;
        x += 2;
        if (x >= 100) {
            x = 0;
            y += 2;
        }
    }

    puts("100 100");
    rep(i, 100) {
        rep(j, 100) cout << ans[i][j];
        cout << endl;
    }
}

Measured memory_bytes: 256
def main():
    N = int(input())
    txy = [list(map(int,input().split())) for _ in range(N)]
    txy = [[0,0,0]] + txy
    #print(txy)
    for i in range(N):
        temp = txy[i+1][0] - txy[i][0] - abs(txy[i+1][1] - txy[i][1]) - abs(txy[i+1][2] - txy[i][2])  
        if not (temp % 2 == 0 and temp >= 0):
            print("No")
            return
    print("Yes")
        
main()

Measured memory_bytes: 27932
n = int(input())
a = [int(i) for i in input().split()]

mincost = 10000000
for i in range(-100, 101):
    cost = 0
    for j in range(n):
        cost += (a[j]-i) ** 2
    mincost = min(cost, mincost)

print(mincost)

Measured memory_bytes: 3064
n = gets.to_i
min = last = gets.to_i
profits = []
(n-1).times{
  current = gets.to_i
  profits<<(current-min) if (profits.bsearch{|i| i >= 0} == nil) || (current > last)
  min = current if (current < min)
  last = current
}
puts profits.max

Measured memory_bytes: 9672
object Main extends App {
  println((for (_ ← 1 to scala.io.StdIn.readInt) yield { scala.io.StdIn.readLong }).toList.foldLeft(0: Long, 0: Long) {
    case ((_, res), 0) ⇒ (0, res)
    case ((0, res), n) ⇒ (n % 2, res + n / 2)
    case ((1, res), n) ⇒ ((n + 1) % 2, res + (n + 1) / 2)
  }._2)
}

Measured memory_bytes: 36496
from collections import deque
import sys
sys.setrecursionlimit(10**7)
#input = sys.stdin.readline
def solve():
  n = int(input())
  s = input()
  lefte = 0
  righte = s.count("E")
  leftw = 0
  rightw = n-righte
  ans = 10**10
  for i in range(n):
    if s[i] == "E":
      righte -= 1
      ans = min(ans,righte+leftw)
      lefte += 1
    else:
      rightw -= 1
      ans = min(ans,righte+leftw)
      leftw += 1
  print(ans)
      
      
solve()

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


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

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  ll s = 0, sev = 0;
  for(int i=0; i<n; i++){
    cin >> a[i];
    if(i%2) sev += a[i];
    s += a[i];
  }
  vector<ll> ans;
  ans.push_back(s-sev*2);
  for(int i=0; i<n; i++){
    if(i==n-1) ans.push_back(a[i]*2-ans[0]);
    else ans.push_back(a[i]*2-ans[i]);
    cout << ans[i] << " ";
  }
  return 0;
}


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

string s;
int H, W;

int main(void) {
    cin >> H >> W;
    REP(i, H) {
        REP(j, W) {
            cin >> s;
            if(s=="snuke") {
                char c = 'A'+j;
                cout << c << i+1 << endl;
            }
        }
    }
}

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

int main(){
	int n,m,a[20000],b;
	while(cin >> n >> m && (n || m)){
		for(int i = 0;i < n+m;++i){
			cin >> a[i];
		}
		sort(a,a+(n+m));
		b = a[0];
		for(int i = 0;i < n+m-1;++i){
			if(a[i+1] - a[i] > b) b = a[i+1] - a[i];
		}
		cout << b << endl;
	}
}

Measured memory_bytes: 920
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    vector<int>a(n),b(n);
    for(int i = 0;i<n;i++){
        cin >> a[i];
        b[i] = a[i];
    }
    
    sort(a.begin(),a.end());
    cout << abs(a[n/2 -1]-a[n/2]);
    
    
    
}


Measured memory_bytes: 1024
/******************************************
*    AUTHOR:         CHIRAG AGARWAL       *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL; 
typedef long double LD;

bool vis[803][803];
int dis[803][803];
string s[803];
queue<pair<int,int> > q;
int n,m,k;
int dirx[4]={0,0,1,-1};
int diry[4]={1,-1,0,0};

bool isValid(int x,int y)
{
	if(x<n&&x>=0&&y<m&&y>=0)
	{
		return true;
	}	
	return false;
}

int main() 
{
	scanf("%d %d %d",&n,&m,&k);

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

		for(int j=0;j<s[i].size();j++)
		{
			if(s[i][j]=='S')
			{
				q.push(make_pair(i,j));
				vis[i][j]=1;
			}
		}
	}

	while(!q.empty())
	{
		pair<int,int> tmp=q.front();
		q.pop();
		int curx=tmp.first;
		int cury=tmp.second;
	
		for(int i=0;i<4;i++)
		{
			int newx=curx+dirx[i];
			int newy=cury+diry[i];
			if(isValid(newx,newy)&&s[newx][newy]!='#')
			{
				if(!vis[newx][newy])
				{
					dis[newx][newy]=dis[curx][cury]+1;
					vis[newx][newy]=true;
					q.push(make_pair(newx,newy));
				}
			}
		}
	}
	int ans=1e8;

	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(vis[i][j]&&dis[i][j]<=k)
			{
				int mn=i;
				mn=min(mn,n-i-1);
				mn=min(mn,j);
				mn=min(mn,m-1-j);
				ans=min(ans,((mn+k-1)/k)+1);
			}
		}
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    while(1)
    {
        string str;
        getline(cin,str);
        if(str.size()==1&&str[0]=='0')break;
        int S={};
        for(int i=0;i<str.size();i++)
        {
            S+=str[i]-'0';
        }
        cout<<S<<endl;
    }
    return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int gcd(int a, int b)
{
    int dis = a/b;
    int mod = a%b;
    while (mod != 0)
    {
        a = b;
        b = mod;
        mod = a % b;
    }
    return b;
}

int main()
{
    int k;
    cin >> k;
    lint sum = 0;
    for (int a = 1; a <= k; a++)
    {
        for (int b = 1; b <= k; b++)
        {
            for (int c = 1; c <= k; c++)
            {
                sum = sum + gcd(gcd(a,b),c);
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3620
//It's time to be who I am, rather than who I am supposed to be.
#include<bits/stdc++.h>
#define int long long
#define sz(x) (int)(x.size())
using namespace std;

const int N = 1e5+10;
const int mod = 998244353;
const int inf = 1e12;
int n, cost[N][3], dp[N][3];

int solve(int curr, int task){
	if(curr < 1)
		return 0;

	int &ans = dp[curr][task];
	if(ans != 0)
		return ans;

	vector<int> otherTwo;
	for(int i = 0; i < 3; i++)
		if(i != task)
			otherTwo.push_back(i);

	ans = cost[curr][task] + max(solve(curr - 1, otherTwo[0]), solve(curr - 1, otherTwo[1]));

	return ans;
}

int32_t main(){
	ios::sync_with_stdio(false);
   cin.tie(NULL); cout.tie(NULL);

    cin >> n;
    for(int i = 1; i <= n; i++)
    	cin >> cost[i][0] >> cost[i][1] >> cost[i][2];
    dp[1][0] = cost[1][0],
    dp[1][1] = cost[1][1],
    dp[1][2] = cost[1][2];

    cout << max({solve(n,0), solve(n,1), solve(n,2)}) << '\n';
    
}

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

int main()
{
    int N, M;
    cin >> N >> M;
    int correct = 0, penalty = 0;
    bool isAC[N + 1] = {};
    int cnt[N + 1] = {};

    rep(i, M) {
        int p;
        string s;
        cin >> p >> s;
        if (isAC[p]) continue;
        if (s == "WA") {
            cnt[p]++;
        }
        else {
            correct++;
            isAC[p] = 1;
            penalty += cnt[p];
        }
    }

    cout << correct << " " << penalty << endl;

    return 0;
}

Measured memory_bytes: 768
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i = 0;i < n; i++)
#define REP(i,n) for(int i = 1;i <= n; i++)
// ----GCC ONLY---- //
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// ----        ---- //
#define ll long long
#define MOD 10000007
#define PB push_back
 
using namespace std;

int main(){

    double n,m;
    double ans = 0;
    cin >> n >> m;
    double all = 0;

    int A[1010];
    rep(i,n){
         cin >> A[i];
         all += A[i];

    }



    rep(i,n){

        if(!(all / (4 * m) > A[i])){
            ans++;
        }
        
    }

    if(ans >= m && !(ans == 0)){
        puts("Yes");
    }else{
        puts("No");
    }
    return 0;
}


Measured memory_bytes: 256