akhauriyash/Code-Regression huggingface dataset:
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include <bits/stdc++.h>
using namespace std ;
 
 
typedef long long                ll;
typedef long double              ld;
typedef unsigned long long       ull;
typedef pair <int,int>           pii;
typedef pair <ll,ll>             pll;
typedef vector <int>             vi;
typedef vector <ll>              vll;
typedef vector <vector <int> >   vvi;
 
inline int Int(){int x; cin >> x; return x;}
inline ll Long(){ll x; cin >> x; return x;}
inline float Float(){float x; cin >> x; return x;}
inline double Double(){double x; cin >> x; return x;}
inline void Yes(){cout << "Yes" << endl;}
inline void No(){cout << "No" << endl;}
inline void YES(){cout << "YES" << endl;}
inline void NO(){cout << "NO" << endl;}
 
const int N             =(int)2e5 + 5;
const int maxN          =(int)1e6 + 6;
const ll  Mod           =(ll)1e9 + 7;
const int inf           =(int)2e9;
const ll  Inf           =(ll)1e18;
 
#define     T           int t,q; cin >> t; for(q=1;q<=t;q++)
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i=(b); i!=(e+1)-2*(b > e); i =i+1-2*(b > e))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
 
 
int main(){
    
    long long A,B,C;

    cin >> A >> B >> C;
    long long x = C-A-B;
    if(x < 0)
    	cout << "No" << endl;
    else if(4*A*B < x*x)
    	cout << "Yes" << endl;
    else
    	cout << "No" << endl;
 

    return 0 ;
}
 
//...............BYE BYE................

Measured memory_bytes: 256
from sys import stdin
input = lambda: stdin.readline().rstrip("\r\n")
from collections import defaultdict as vector
from collections import deque as que
inin = lambda: int(input())
inar = lambda: list(map(int,input().split()))
from heapq import heappush as hpush,heappop as hpop

a=inin()
print(a+a*a+a*a*a)

Measured memory_bytes: 64784
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int acc[2000][2000][4];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  rep(i,h)cin>>s[i];
  // calc ans
  // 0
  rep(i,h) {
    int c=0;
    rep(j,w) {
      if(s[i][j]=='.') {
	c++;
	acc[i][j][0]=c;
      } else {
	acc[i][j][0]=0;
	c=0;
      }
    }
  }
  // 1
  rep(i,h) {
    int c=0;
    revrep(j,w) {
      if(s[i][j]=='.') {
	c++;
	acc[i][j][1]=c;
      } else {
	acc[i][j][1]=0;
	c=0;
      }
    }
  }
  // 2
  rep(j,w) {
    int c=0;
    rep(i,h) {
      if(s[i][j]=='.') {
	c++;
	acc[i][j][2]=c;
      } else {
	acc[i][j][2]=0;
	c=0;
      }
    }
  }
  // 3
  rep(j,w) {
    int c=0;
    revrep(i,h) {
      if(s[i][j]=='.') {
	c++;
	acc[i][j][3]=c;
      } else {
	acc[i][j][3]=0;
	c=0;
      }
    }
  }

  int ans=0;
  rep(i,h) {
    rep(j,w) {
      ans=max(ans,acc[i][j][0]+acc[i][j][1]+acc[i][j][2]+acc[i][j][3]-3);
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;

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

const ld PI = acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
//const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    int n,k,s; cin >> n >> k >> s;
    vi ans(n);
    rep(i,k) {
        ans[i] = s;
    }
    for(int i = k; i < n; ++i) {
        if(s==1) ans[i] = s+1;
        else ans[i] = s-1;
    }
    for(int i = 0; i < n; i++) cout << ans[i] << (i==n-1 ? '\n' : ' ');
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N, A, B;
  std::cin >> N >> A >> B;
  if(A+B>N+1||A*B<N){std::cout << -1 << '\n';return 0;}
  if(B==1) for(int i=1;i<=N;i++) std::cout << i << (i==N?"\n":" ");
  else{
    int now = 0;
    int count = N - A;
    std::vector<int> ans;
    for(int i=1; count>0;i++, count-=B-1) {
      for(int j=min(i*B, (i-1)*B+count+1);j>(i-1)*B;j--){
        now = max(now, j);
        ans.push_back(j);
      }
    }
    for(int i=now+1;i<=N;i++) ans.push_back(i);
    for(int i=0;i<ans.size();i++) std::cout << ans[i] << (i==N-1?"\n":" ");
  }
  return 0;
}


Measured memory_bytes: 3440
#include<bits/stdc++.h>
using namespace std;
char a[105][105],b[105][105];
int main()
{
	int n,m,cnt=0;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{ 
			if(a[i][j]=='#')
			{
				continue;
			}
			if(a[i+1][j]=='#')
				b[i][j]++;
			if(a[i-1][j]=='#')
				b[i][j]++;
			if(a[i][j+1]=='#')
				b[i][j]++;
			if(a[i][j-1]=='#')
				b[i][j]++;
			if(a[i+1][j+1]=='#')
				b[i][j]++;	
			if(a[i+1][j-1]=='#')
				b[i][j]++;
			if(a[i-1][j+1]=='#')
				b[i][j]++;
			if(a[i-1][j-1]=='#')
				b[i][j]++;
			a[i][j]=b[i][j]+48;	
		}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
			cout<<a[i][j];
		cout<<endl;
	}
	return 0;
}

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

int main() {
	ll n;
	vector<int>a;
	cin>>n;
	if(n==0){
		cout << 0;
		return 0;
	}
	while(n){
		a.push_back(abs(n)%2);
		if(n<0){
			n=(abs(n)+1)/2;
		}
		else{
			n/=2;
			n*=-1;
		}
	}
	for(int i=a.size()-1;i>=0;i--){
		cout << a[i];
	}
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author vdewansa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        MCandies solver = new MCandies();
        solver.solve(1, in, out);
        out.close();
    }

    static class MCandies {
        final int MOD = 1_000_000_000 + 7;

        int add(int a, int b) {
            return (a + b) % MOD;
        }

        int sub(int a, int b) {
            return (a + MOD - b) % MOD;
        }

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int K = in.nextInt();
            int[] a = new int[N + 1];
            for (int i = 1; i <= N; i++) {
                a[i] = in.nextInt();
            }
            int[] ways = new int[K + 1];
            int[] cumsum = new int[K + 1];
            for (int n = 1; n <= N; n++) {
                cumsum[0] = ways[0] = 1;
                for (int k = 1; k <= K; k++) {
                    cumsum[k] = add(cumsum[k - 1], ways[k]);
                }
                for (int k = 1; k <= K; k++) {
                    ways[k] = cumsum[k];
                    if (k - a[n] - 1 >= 0) {
                        ways[k] = sub(ways[k], cumsum[k - a[n] - 1]);
                    }
                }
            }
            out.println(ways[K]);
        }

    }
}



Measured memory_bytes: 22484
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		long a = sc.nextLong();
		long b = sc.nextLong();
		int c = sc.nextInt();
		int d = sc.nextInt();
		
		long divByC = b/c - (a - 1)/c;
		long divByD = b/d - (a - 1)/d;
		
//		System.out.println("divByC "+divByC);
//		System.out.println("divByD "+divByD);
		long lcmCD = lcm(c, d);
		
		long divByLCM = b/lcmCD - (a - 1)/lcmCD;
		
		System.out.println((b - a + 1) - (divByC + divByD - divByLCM));
	}
	
	static int gcd(int a, int b){
    	int tmp;

    	while (a % b != 0)
    	{
    		tmp = b;
    		b = a % b;
    		a = tmp;
    	}
    	return b;
    }

    static long lcm(int a, int b, int gcd){
    	return (long)a*(b/gcd);
    }

    static long lcm(int a, int b){
    	int g = gcd(a, b);

    	return lcm(a,b,g);
    }
}


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

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

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

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

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(max(a * c, a * d), max(b * c, b * d)) << endl;
}

Measured memory_bytes: 3672
#include<iostream>
using namespace std;
string n,s;
int main()
{
	cin>>n;
	s=n;
	for(int i=0;i<n.size();i++)
	 n[n.size()-i-1]=s[i];
	for(int i=0;i<n.size();i++)
	{
		if(n[i]=='b') n[i]='d';
		else if(n[i]=='d') n[i]='b';
		else if(n[i]=='p') n[i]='q';
		else if(n[i]=='q') n[i]='p';
	}
	if(s==n)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 512
#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 h,a;
  cin>>h>>a;
  cout<<(h+a-1)/a<<endl;
  return 0;
}


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

set<char> ch;

int main()
{
    string str;
    cin >> str;
    ch.insert(str.begin(), str.end());

    int ans = 1e9;

    for (char c : ch)
    {
        int res = 0;
        int last = 0;
        for (int i = 0; i < str.size(); i++)
        {
            if (str[i] == c)
            {
                res = max(res, last);
                last = 0;
            }
            else ++last;
        }

        res = max(res, last);

        ans = min(ans, res);
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int N;
  cin >> N;
  vector<P> A(N);
  REP(i,N) cin >> A[i].first >> A[i].second;
  
  map<P,int> mp;
  REP(i,N){
    REP(j,N){
      if(i!=j){
        mp[make_pair(A[i].first-A[j].first,A[i].second-A[j].second)]++;
      }
    }
  }

  int MAX=0;
  for(auto x:mp){
    int cnt=0;
    REP(i,N){
      REP(j,N){
        if(i!=j){
          if(A[i].first-A[j].first==x.first.first&&A[i].second-A[j].second==x.first.second){
            cnt++;
          }
        }
      }
    }
    MAX=max(MAX,cnt);
  }

  cout << N-MAX << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

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

    int ans = 0;
    int cnt = 1;
    for (int i = 1; i <= N; ++i) {
        if (a[i] != cnt) {
            ans++;
        } else {
            cnt++;
        }
    }

    cout << (ans == N ? -1 : ans) << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int X, A, B;
    cin >> X >> A >> B;
    cout << X - A - (B * ((X - A) / B)) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int N,M,i,o,temp,line[100];
    scanf("%d %d",&N,&M);
    for(i=0;i<N;i++)
        scanf("%d",&line[i]);
    for(i=1;i<=M;i++){
        for(o=0;o<N-1;o++){
            if(line[o]%i > line[o+1]%i){
                temp=line[o];
                line[o]=line[o+1];
                line[o+1]=temp;
            }
        }
    }
    for(i=0;i<N;i++)
        printf("%d\n",line[i]);
    return 0;
}

Measured memory_bytes: 596
#include<stdio.h>

int main(void)
{
    int a, b;

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

    if((a!=1)&&(b!=1)){
        printf("1\n");
    }else if((a!=2)&&(b!=2)){
        printf("2\n");
    }else {
        printf("3\n");
    }
    return 0;
}

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

const int MOD =1000000007;

signed main() {
int x,t;
cin>>x;

    vector<int> p;
    for(int i=2;;i++){
        t=0;
        for(int j=0;j<p.size();j++){
            if(i%p[j]==0){
                t=1;
                continue;
            }
            if(p[j]*p[j]>i)break;
        }
        if(t==0){
            if(i>=x){
                cout<<i;
                return 0;
            }
            p.push_back(i);
        }
    }

}


Measured memory_bytes: 436
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] n = sc.next().split("");
        for (int i = 0; i < n.length; i++) {
            if ("1".equals(n[i])) {
                n[i] = "9";
                continue;
            }
            if ("9".equals(n[i])) {
                n[i] = "1";
            }
        }
        StringJoiner sj = new StringJoiner("");
        for (int i = 0; i < n.length; i++) {
            sj.add(n[i]);
        }
        System.out.println(sj.toString());
    }

}


Measured memory_bytes: 21332
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;

signed main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (C >= A && C <= B)cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e18;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    ll a[N], b[N];
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];
    ll A[2*N], B[N];
    rep(i, N-1){
        A[i] = a[i]^a[i+1];
        A[N+i] = A[i];
        B[i] = b[i]^b[i+1];
    }
    A[N-1] = a[N-1]^a[0];
    B[N-1] = b[N-1]^b[0];
    ll mix[3*N-1];
    rep(i, N) mix[i] = B[i];
    rep2(i, N, 3*N-2) mix[i] = A[i-N];
    ll cnt[3*N-1];
    cnt[0] = 3*N-1;
    int i = 1, j = 0;
    while(i < 3*N-1){
        while(i+j < 3*N-1 && mix[j] == mix[i+j]) j++;
        cnt[i] = j;
        if(j == 0) {i++; continue;}
        int k = 1;
        while(i+k < 3*N-1 && k+cnt[k] < j) cnt[i+k] = cnt[k], k++;
        i += k, j -= k;
    }
    rep2(i, N, 2*N-1){
        if(cnt[i] >= N-1){
            ll ans = a[i%N]^b[0];
            cout << i%N << ' ' << ans << endl;
        }
    }
}

Measured memory_bytes: 20608
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
template<class T> int arrCountVal(int N, T A[], T val){
  int i;
  int res = 0;
  for(i=(0);i<(N);i++){
    if(A[i]==val){
      res++;
    }
  }
  return res;
}
int N;
char S[102];
int main(){
  rd(N);
  rd(S);
  if(arrCountVal(N,S,'R') > arrCountVal(N,S,'B')){
    wt_L("Yes");
    wt_L('\n');
  }
  else{
    wt_L("No");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20191123-1

// --- original code ---
// int N; char S[102];
// {
//   rd(N,S);
//   wt(if[arrCountVal(N,S,'R') > arrCountVal(N,S,'B'), "Yes", "No"]);
// }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a;
}

Measured memory_bytes: 3648
// #include<bits/stdc++.h>
// #define lli long long int
// #define MOD 1000000007
// #define KING 1000000002
// #define queen 1000002
// #define fi first
// #define se second
// #define se second
// #define lsb(i) (i & -i)
// #define nl cout<<'\n'
// #define TEST cout<<"TEST",nl
// #define pr pair<lli,lli>
// #define pb push_back
// #define eb emplace_back
// #define mp make_pair
// #define vi vector<lli>
// #define vpi vector<pr> 
// #define P pair<lli,pr>
// #define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
// #define NA(i,s,n) for(lli i=s;i<n;i++)
// using namespace std;

// void solve(){
//     lli n; cin>>n;
//     vi a(n+1), b(n+1, 0), c(n+1, 0);
//     set<lli> s1, s2;
//     NA(i,1,n+1) {
//         cin>>a[i];
//         s1.insert(a[i]);
//         if(*(s1.rbegin()) == i && s1.size()==i) b[i] = 1;
//     }
//     for(lli i=n; i>0; --i){
//         s2.insert(a[i]); 
//         if(*(s2.rbegin()) == (n-i+1) && s2.size()==(n-i+1)) c[i]=1;
//     }
//     lli res = 0; vi ans;
//     NA(i,1,n) if(b[i] && b[i]==c[i+1]) ++res, ans.pb(i);
//     cout<<res; nl;
//     for(lli i:ans) cout<<i<<' '<<n-i<<'\n';
//     return; 
// }
// int main(){
//     fastIO;
//     lli t = 1; cin>>t; 
//     NA(i,0,t) {
//         // cout<<"Case #"<<(i+1)<<": ";
//         solve();
//     }
//     return 0;
// }


#include<bits/stdc++.h>
#define lli long long int
#define NA(i,s,n) for(lli i=s; i<n; ++i)
#define nl cout<<'\n'
using namespace std;

lli n, k, c, d;
void dvs(lli num, vector<lli> &ans){
    NA(i,1, (lli)sqrt(num) + 1){
        if(!(num%i)){
            if(num/i == i) ans.push_back(i);
            else ans.push_back(i), ans.push_back(num/i);
        }
    }
    // cout<<ans.size()<<'\n'; exit(0);
    return;
}
int main(){

    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
     
    cin>>n;
    vector<lli> aa;
    dvs(n-1, aa);
    lli d1 = aa.size()-1;
    // cout<<d1<<'\n'; 
    vector<lli> a; 
    dvs(n, a);
    NA(i,1,a.size()){
        lli p = a[i], m = n;
        while(m%p == 0 && m) m/=p;
        if(m%p == 1) ++d1;
    }
    cout<<d1;
    return 0;
}

Measured memory_bytes: 384
/////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  Last Updated: 2018-10-23 ...Maybe
//
//    I hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -DDEBUG_LOCAL'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REAP(i,0,n)
#define REAP(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REAP,_REP,)(__VA_ARGS__)

#define _REPR(i,n) REAPR(i,n,0)
#define REAPR(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define REPR(...) _overload3(__VA_ARGS__,REAPR,_REPR,)(__VA_ARGS__)

#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()

#define coutALL(a) {int loop_coutALL=0;for(auto e:a) cout<<(loop_coutALL++?" ":"")<<e; cout<<endl;}

#define coutYN(a) cout<<((a)?"YES":"NO")<<endl;
#define coutYn(a) cout<<((a)?"Yes":"No")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;

#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)

const int INF=1145141919;
//const long long INF=114514191911451419;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename T> istream &operator >> (istream &is, vector<T> &v){for(T &x:v) is>>x;return is;}
template<typename T> ostream &operator << (ostream &os, vector<T> &v){int i=0;for(T &x:v) os<<(i++?" ":"")<<x;return os;}

ll rev(ll n){ll x=0;for(;n>0;){x=x*10+n%10;n/=10;}return x;}

ll upper(ll n,ll m){return (n+m-1)/m;};
ll rounding(ll n){return (long double)n+0.5;};

bool inG(ll x,ll n){return 0<=x && 0<n;}
bool outG(ll x,ll n){return x<0 || n<=x;}

inline int qp(int a,ll b){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
inline int qp(int a,ll b,int mo){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

inline ll fac(ll k,ll n){ll a=1;for(int i=0;i<n;i++)a*=k--;return a;}
inline ll fac(ll k,ll n,int mo){ll a=1;for(int i=0;i<n;i++)a*=k--,a%=mo;return a;}

inline int dsum(ll n){int a=0;for(;n;n/=10)a+=n%10;return a;}

struct Arithmetic{Arithmetic(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}};

//#define DEBUG_LOCAL

#ifdef DEBUG_LOCAL
template<typename T> void deb(T a){cerr<<"deb: "<<a<<"です"<<endl;}
#define debl {cerr<<"debug: "<<__LINE__<<"行目だ"<<endl;}
void what_cr(){cout<<__GCC_ATOMIC_CHAR16_T_LOCK_FREE<<" ←？"<<endl;}
//ori_func S

//ori_func E
#else
template<typename T>void deb(T a){}
#define debl
void what_cr(){}void t_t(){}
#endif

signed main(){

  Arithmetic Exception;

  int n;
  cin>>n;

  coutYN(n==3 || n==5 || n==7);

  return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

#define W -3
#define G -2
#define B -1
#define MAX 101 

void bfs(int);
void enq(int);
int deq(void);

int T[MAX][MAX];
int color[MAX];
int d[MAX];
int n;
int head,tail;
int Q[MAX];

int main()
{
  int i,j,youso,kazu,v;

  scanf("%d",&n);

  for(i=1;i<=n;i++)
    {
      scanf("%d%d",&youso,&kazu);

      for(j=0;j<kazu;j++)
	{
	  scanf("%d",&v);

	  T[i][v]=1;
	}
    }

  bfs(1);

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

void bfs(int s)
{
  int i,u,v;

  for(i=1;i<=n;i++)
    {
      color[i]=W;
      d[i]=-1;
    }
  color[s]=G;
  d[s]=0;
  enq(s);

  while(head!=tail)
    {
      u=deq();
      
      for(v=1;v<=n;v++)
	{
	  if(T[u][v]==1)
	    {
	      if(color[v]==W)
		{
		  color[v]=G;
		  d[v]=d[u]+1;
		  enq(v);
		}
	    }
	}
      color[u]=B;
    }
}

void enq(int u)
{
  Q[tail]=u;
  tail++;
  if(tail==MAX)
    {
      tail=0;
    }
}

int deq(void)
{
  int u;
  u=Q[head];
  head++;
  if(head==MAX)
    {
      head=0;
    }
  return u;
}



Measured memory_bytes: 2112
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#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 PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;
const int MSIZE = 100000;
const double Pi = 3.14159265358979323146;

int main(){
  int n, m; cin >> n >> m;
  vector<int> hs(n+1);
  vector<vector<int>> to(n+1);
  for(int i=1; i<n+1; i++){
    int h;  cin >> h;
    hs[i] = h;
  }

  REP(i, m){
    int a, b; cin >> a >> b;
    to[b].pb(a);
    to[a].pb(b);
  }

  int ans = 0;
  for(int i=1; i<n+1; i++){
    bool ok = true;
    for(int j=0; j<to[i].size(); j++){
      if(hs[i]<=hs[to[i][j]]){
        ok = false;
      }
    }
    if(ok){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8752
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define mp make_pair
#define pb push_back
#define EB emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

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


    sort(all(a));
    cout << a[N-1] - a[0] << endl;
}


Measured memory_bytes: 256
/* 	* In the name of GOD 
	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
const int N = 102345;
int a[N], dp[N];

void solve() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 1; i < n; i++) {
		dp[i] = 1012345678;
		for (int j = i - 1; j >= 0 && j >= i - k; j--) {
			dp[i] = min(dp[j] + abs(a[i] - a[j]), dp[i]);
		}
	}
	cout << dp[n - 1];
}

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


Measured memory_bytes: 4332
#include<cstdio>
int main()
{
	int k, s, ans = 0;
    scanf("%d%d",&k,&s);
    for(int x = 0;x <= k;x++) for(int y = 0;y <= k;y++) if(s - x - y >= 0 && s - x - y <= k) ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w,k;cin >> h >> w >> k;
    ll sx,sy,gx,gy;cin >> sx >> sy >> gx >> gy;
    sx--,sy--,gx--,gy--;
    char c[h][w];
    rep(i,h){
        rep(j,w){
            cin >> c[i][j];
        }
    }
    ll s=sx*w+sy,g=gx*w+gy;
    vector<vector<ll>> d(h*w,vector<ll>(4,INF));
    priority_queue<pair<ll,pair<ll,ll>>,vector<pair<ll,pair<ll,ll>>>,greater<pair<ll,pair<ll,ll>>>> pq;
    rep(i,4){
        d[s][i]=0;
        pq.push({0,{s,i}});
    }
    while(!pq.empty()){
        auto p=pq.top();
        pq.pop();
        ll u=p.first,v=p.second.first,f=p.second.second;
        if(u>d[v][f]){
            continue;
        }
        rep(i,4){
            int x=v/w+dx[i],y=v%w+dy[i];
            ll nx=x*w+y;
            if(x<0||x>=h||y<0||y>=w||c[x][y]=='@'){
                continue;;
            }
            if(i==f){
                if(chmin(d[nx][i],d[v][f]+1)){
                    pq.push({d[nx][i],{nx,i}});
                }
            }
            else{
                if(chmin(d[nx][i],(d[v][f]+k-1)/k*k+1)){
                    pq.push({d[nx][i],{nx,i}});
                }
            }
        }
    }
    ll ans=INF;
    rep(i,4){
        chmin(ans,d[g][i]);
    }
    cout << (ans==INF?-1:(ans+k-1)/k) << endl;
}

Measured memory_bytes: 80704
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

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

int main(){
    int n, c; cin >> n >> c;
    vector<vector<int>> d(c,vector<int>(c)); rep(i,c) rep(j,c) cin >> d[i][j];
    vector<int> c0(c,0), c1(c,0), c2(c,0);
    rep(i,n) rep(j,n){
        int cc; cin >> cc; cc--;
        if((i+j)%3 == 0) c0[cc]++;
        else if((i+j)%3 == 1) c1[cc]++;
        else if((i+j)%3 == 2) c2[cc]++;
    }
    ll ans = 100100100100100;
    rep(i,c) rep(j,c) rep(k,c){
        if(i == j || j == k || k == i) continue;
        ll count = 0;
        rep(l,c) count += c0[l]*d[l][i];
        rep(l,c) count += c1[l]*d[l][j];
        rep(l,c) count += c2[l]*d[l][k];
        if(count < ans) ans = count;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		ArrayList<String> ary = new ArrayList<String>();
		int x,y;
		String op;
		String tmp;
		int cnt = 0;
		Scanner sc = new Scanner(System.in);

		x = sc.nextInt();
		op = sc.next();
		y = sc.nextInt();
		tmp = ArrayAdder(x,y,op);
		ary.add(tmp);
		cnt++;

		while(!tmp.equals("end")){
			sc.hasNext();
			x = sc.nextInt();
			op = sc.next();
			y = sc.nextInt();
			tmp = ArrayAdder(x,y,op);
			ary.add(tmp);
			cnt++;
		}

		for(int i=0;i<cnt-1;i++){
			System.out.println(ary.get(i));
		}
		sc.close();
	}

	public static String ArrayAdder(int x,int y,String op){
		String result = "";
		if(op.equals("+")){
			result = "" + (x + y);
		}else if(op.equals("-")){
			result = "" + (x - y);
		}else if(op.equals("*")){
			result = "" + (x * y);
		}else if(op.equals("/")){
			result = "" + (x / y);
		}else if(op.equals("?")){
			result = "end";
		}else if(x==0 && y==0){
			result = "end";
		}
		return result;
	}

}

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

int main() {
	string a;
  	cin >> a;
	if((a[0]==a[1]&&a[1]==a[2])||(a[1]==a[2]&&a[2]==a[3])) cout << "Yes"<< endl;
    else cout << "No"<< endl;
}	


Measured memory_bytes: 3584
N = int(input())
l = list(map(int, input().split()))
cnt = 0;
loc = 0;
for i in range(1, N+1):
  for j in range(loc, N):
    if(l[j] == i):
      loc = j
      cnt += 1
      break
  if(cnt != i):
    break
if(cnt == 0):
  print(-1)
else:
  print(N-cnt)

Measured memory_bytes: 26012
#include<stdio.h>
int main(){

  int i, j, a, b;

  while(1){
  scanf("%d%d",&a,&b);
  for ( i = 0; i < a; i++ ){
    for ( j = 0; j < b; j++ ){
      if(i!=0&&i!=a-1&&j!=0&&j!=b-1){
	printf(".");
      } else {
	printf("#");
      }
    }
    printf("\n");
  }
  if(a==0 && b==0)break;
  printf("\n");
  }
  return 0;
  }

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 2e5 + 3;

int pai[3][T];
int peso[3][T];
vii g[T];
int n,k,l;

void init() {
    for(int i = 0; i < 3; i++)
        for(int j = 0; j <= n; j++) {
            pai[i][j] = j;
            peso[i][j] = 1;
        }
}

int find(int op, int x) {
    return (pai[op][x] == x? x : pai[op][x] = find(op,pai[op][x]));
}

void join(int op, int x, int y) {
    x = find(op,x);
    y = find(op,y);
    if(x == y) return;
    if(peso[op][x] < peso[op][y]) swap(x,y);
    pai[op][y] = x;
    peso[op][x] += peso[op][y];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> k >> l;
    init();

    while(k--) {
        int a,b; cin >> a >> b;
        if(find(0,a) != find(0,b)) join(0,a,b);
    }

    while(l--) {
        int a,b; cin >> a >> b;
        if(find(1,a) != find(1,b)) join(1,a,b);
    }

    for(int i = 1; i <= n; i++)
        g[find(0,i)].eb(find(1,i),i);

    for(int i = 1; i <= n; i++) {
        sort(g[i].begin(), g[i].end());
        for(int j = 1; j < g[i].size(); j++)
            if(g[i][j].fi == g[i][j-1].fi)
                join(2,g[i][j].se,g[i][j-1].se);
    }

    for(int i = 1; i <= n; i++) cout << peso[2][find(2,i)] << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 15744
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
using ld = long double;
using ml = boost::multiprecision::cpp_int;


#define all(collection) (collection).begin(), (collection).end()              // begin to end
#define divc(a, b) ceil((ld) a / (ld) b);                                     // div ceiling
#define rep(i, begin, end) for (ll i = begin; i < end; i++)                   // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)                  // repeat reverse
#define size(collection) ((ll) (collection).size())                           // collection size
#define sum(begin, end) accumulate(all(begin, end), 0LL)                      // accumulate 
/********** const value **********/
#define llong_max 9223372036854775807                                         // 9 * 10^18
#define mod 1000000007                                                        // 1e9 + 7
#define pi 3.14159265                                                         // 3.14 ...
/********** for each macro **********/
#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, v) fori(i, auto& e: v)
#define forir(i, ...) if(ll i = size(v)) for(__VA_ARGS__) if(i--, true)
#define eachr(i, e, v) forir(i, auto& e: boost::adaptors::reverse(v))


int main(void)
{ 
	ll n; cin >> n;
	string s; cin >> s;

	ll ans = 0;
	rep(i, 0, 1000)
	{
		string word = to_string(i);
		if (size(word) == 1) word = "00" + word;
		else if (size(word) == 2) word = "0" + word;
		
		auto pos1 = s.find(word[0]);
		if (pos1 == string::npos) continue;

		string sub2 = s.substr(pos1 + 1, size(s));
		auto pos2 = sub2.find(word[1]);
		if (pos2 == string::npos) continue;

		string sub3 = sub2.substr(pos2 + 1, size(sub2));
		auto pos3 = sub3.find(word[2]);
		if (pos3 == string::npos) continue;

		ans++;
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 384
import heapq
N = int(input())
L = list(map(int, input().split()))

q = []
for i in range(N):
    heapq.heappush(q, L[i])

while(len(q)>1):
    x = heapq.heappop(q)
    y = heapq.heappop(q)
    new = (x+y)/2
    heapq.heappush(q, new)

if len(q)==1:
    ans = heapq.heappop(q)
    print(ans)


Measured memory_bytes: 3188
n = gets.to_i
v = gets.chomp.split.map(&:to_i)
c = gets.chomp.split.map(&:to_i)
a = []
n.times do |i|
  a.push(v[i] - c[i])
end

sum = 0
a.each do |i|
  if i > 0
    sum += i
  end
end

puts sum

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 2e5 + 5;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
 
int fac[MAX_N], inv[MAX_N];
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b, bool usemod = true) {ll c = 1LL; while (b > 0) {if (b & 1LL) {if(!usemod)c*=a;else c = a * c%mod;}if (!usemod) a*=a;else a = a * a%mod; b >>= 1LL;}return c;}
void _nCr() {fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) {fac[i] = fac[i - 1LL] * i%mod;}for (int i = 0; i < MAX_N; i++) {inv[i] = POW(fac[i], mod - 2);}}
ll nCr(ll n, ll r) {return (fac[n] * inv[r] % mod)*inv[n - r] % mod;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}

bool solve() {
	int n,k;cin >> n >> k;
	if (n == 2) {
		if (k == 0) {
			cout << 1 << endl << 1 << " " << 2;
		} else {
			cout << -1 << endl;
		}
	} else if (n == 3) {
		if (k == 0) {
			cout << 3 << endl;cout << 1 << " " << 2 << endl;cout << 3 << " " << 2 << endl;cout << 1 << " " << 3 << endl;
		} else if (k == 1) {
			cout << 2 << endl;cout << 1 << " " << 2 << endl;cout << 3 << " " << 2 << endl;
		} else {
			cout << -1 << endl;
		}
	} else {
		if (k > (n-2)*(n-1)/2) cout << -1 << endl;
		else {
			int tmp = (n-2)*(n-1)/2;
			vp ans;
			FOR (i,2,n+1) {
				ans.push_back({1,i});
			}
			FOR (i,2,n+1) {
				FOR (j,2,n+1) {
					if (i<=j) continue;
					else {
						if (tmp == k) {
							cout << ans.size() << endl;
							REP (i,ans.size()) {
								cout << ans[i].F << " " << ans[i].S << endl;
							}
							return 0;
						} else {
							ans.pb({i,j});
							tmp--;
						}
					}
				}
			}
			if (tmp == k) {
							cout << ans.size() << endl;
							REP (i,ans.size()) {
								cout << ans[i].F << " " << ans[i].S << endl;
							}
							return 0;
						}
		}
	}
}

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

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

using namespace std;

#define int long long 

string ch = "abcdefghijklmnopqrstuvwxyz";

int32_t main()
{
	int n;
	cin >> n;
	string s = "";
	if(n <= 26)
	{
		cout << ch[n-1] << endl;
		return 0;
	}
	while(1)
	{
		if(n <= 0)
		{
			//s.push_back(ch[n-1]);
			break;
		}
		int indx = n%26;
		if(indx == 0) s.push_back('z');
		else s.push_back(ch[indx-1]);
		if(indx == 0)
		{
			n = n/26;
			n--;
		}
		else n = n/26;
	}
	reverse(s.begin(),s.end());
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3588
#include<iostream>
using namespace std;
long long n,m,x;
int main()
{
    cin>>n>>m;
    x=2*n;
    if(x>m) cout<<m/2<<endl;
    else if(x==m)cout<<n<<endl;
    else
	{
    m=m-x;
    m=m/4;
    cout<<n+m<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var s = Console.ReadLine().Trim();
        var t = 0;
        var tmax = 0;
        for (int i = 0; i < n; i++)
            if (s[i] == 'I') { t++; tmax = Math.Max(tmax, t); }
            else t--;
        Console.WriteLine(tmax);
    }
}


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

long long n, m, s, u, v, z;
long long d[51][2500];
const long long INF = 1e18;

struct edge {
	long long to, c, tm;
};

vector<edge> G[51];
typedef tuple<long long, long long, long long> P;
priority_queue<P, vector<P>, greater<P>> Q;

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

	fill((long long*)d, (long long*)(d + n + 1), INF);

	for (int i = 0; i < m; i++) {
		edge e;
		cin >> u >> v >> e.c >> e.tm;

		e.to = v;
		G[u].push_back(e);
		e.to = u;
		G[v].push_back(e);

		z = max(z, e.c);
	}

	z *= n - 1;
	s = min(s, z);

	for (int i = 1; i <= n; i++) {
		long long c, d;
		cin >> c >> d;

		edge e;
		e.to = i;
		e.c = -c;
		e.tm = d;
		G[i].push_back(e);
	}

	d[1][s] = 0;
	Q.push(P(0, s, 1));

	while (!Q.empty()) {
		P p = Q.top();
		Q.pop();

		int ut = get<2>(p), uc = get<1>(p);

		if (d[ut][uc] < get<0>(p))
			continue;

		for (edge e : G[ut]) {
			long long uw = uc - e.c;

			uw = min(uw, z);

			if (uw < 0)
				continue;

			if (d[e.to][uw] > d[ut][uc] + e.tm) {
				d[e.to][uw] = d[ut][uc] + e.tm;
				Q.push(P(d[e.to][uw], uw, e.to));
			}
		}
	}

	for (int i = 2; i <= n; i++) {
		long long mn = INF;
		for (int j = 0; j <= z; j++)
			mn = min(mn, d[i][j]);

		cout << mn << endl;
	}
}


Measured memory_bytes: 7276
#include<bits/stdc++.h>
using namespace std;
pair<int, int> ans[100100];
int main(){
    int n, m, p, b = 0, c = 0;
    char a;
    cin >> n >> m;
    while(m--){
        cin >> p >> a >> a;
        if(ans[p].second == 0){
            if(a == 'C'){
                ans[p].second = 1;
                c++;
                b += ans[p].first;
            }
            else if(a == 'A'){
                ans[p].first++;
            }
        }
    }
    cout << c << ' ' << b << endl;
    return 0;
}

Measured memory_bytes: 1152
#!/usr/bin/env python3

from copy import deepcopy

def dfs(x, adj, visited):
    for y, flag in enumerate(adj[x]):
        if flag and y not in visited:
            visited.add(y)
            dfs(y, adj, visited)

def is_simply_connected(adj):
    n = len(adj)
    visited = {0}
    dfs(0, adj, visited)
    return len(visited) == n

def main():
    n, m = map(int, input().split())
    adj = [[(i == j) for i in range(n)] for j in range(n)]
    edges = set()
    for i in range(m):
        a1, b1 = map(int, input().split())
        a = a1 - 1
        b = b1 - 1
        edges.add((a, b))
        adj[a][b] = True
        adj[b][a] = True

    res = 0
    for a, b in edges:
        adjc = deepcopy(adj)
        adjc[a][b] = False
        adjc[b][a] = False
        if not is_simply_connected(adjc):
            res += 1
    print(res)

main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<pair<float,string>> m(n);
  for (int i = 0; i < n; i++) {
    cin >> m[i].first >> m[i].second;
  }
  const float b2y = 380000.0;
  float sum =0;
  for (int i=0; i<n; i++) {
    if (m[i].second =="BTC"){
      sum += m[i].first * b2y;
    }else {
      sum += m[i].first;
    }    
  }
  cout << sum;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define all(v) (v).begin(),v.end()
#define fi first
#define se second
const ll inf=(1e18);
bool dp[200000];
int main(){
int n,k;
cin>>n>>k;
vector<int> a(n);
for(int i=0;i<n;i++)cin>>a[i];
//sort(all(a));
for(int i=0;i<=k;i++){
  for(int j=0;j<n;j++){
      if(i>=a[j]) dp[i]|=!dp[i-a[j]];
  }
}
if(dp[k])cout<<"First"<<endl;
else cout<<"Second"<<endl;
}



Measured memory_bytes: 384
n, w = list(map(int, input().split()))
wv = [list(map(int, input().split())) for i in range(n)]

dp = [[0] * (w + 1) for i in range(n)]


for i in range(n):
    for j in range(w + 1):
        use = 0
        if j - wv[i][0] >= 0:
            use = dp[i - 1][j - wv[i][0]] + wv[i][1]
        nouse = dp[i - 1][j]

        dp[i][j] = max(use, nouse)

print(max(dp[-1]))


Measured memory_bytes: 120940