akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int tmp = 0;

    for(;;){
        long long a;
        cin >> a;
        if(a == 0)
            return 0;
        //a = ++ tmp;

        bool plus = true;
        if(a < 0){
            a *= -1;
            plus = false;
        }

        vector<int> x(12, 0);
        for(int i=0; i<10; ++i){
            int b = a % 10;
            a /= 10;

            if(plus){
                x[i] += b;
            }else if(b > 0){
                x[i] += 10 - b;
                x[i+1] += 1;
            }

            if(x[i] >= 10){
                x[i] -= 10;
                if(x[i+1] > 0)
                    x[i+1] -= 1;
                else{
                    x[i+2] += 1;
                    x[i+1] += 9;
                }
            }

            /*
            if(plus){
                b += x[i];
                if(b <10)
                    x[i] = b;
                else{
                    x[i+2] = 1;
                    x[i+1] = 9;
                    x[i] = b - 10;
                }
            }else{
                if(b != 0){
                    b = 10 + b - x[i];
                    if(b <= 10)
                        x[i] = 10 - b;
                    else{
                        x[i+1] += 1;
                        x[i] = 20 - b;
                    }
                }
            }
            */

            plus = !plus;
        }

        int i = 11;
        while(x[i] == 0)
            -- i;
        do{
            cout << x[i];
        }while(--i >= 0);
        cout << endl;


    }
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    String line[] = new String[h];
    for(int i = 0 ; i < h ; ++i){
      line[i] = sc.next();
    }
    
    int s[][] = new int[h][w];
    for(int i = 0 ; i < h ; ++i){
      for(int j = 0 ; j < w ; ++j){
        if(line[i].charAt(j) == '.'){
          s[i][j] = 0;
        }else{
          s[i][j] = -1;
        }
      }
    }
    
    //int count = 0;
    for(int i = 0 ; i < h ; ++i){
      for(int j = 0 ; j < w ; ++j){
        if(s[i][j] != -1){
          //左上
          if(i!=0 && j!=0 && s[i-1][j-1]==-1){
            s[i][j]++;
          }
          //上
          if(i!=0 && s[i-1][j]==-1){
            s[i][j]++;
          }
          //右上
          if(i!=0 && j!=w-1 && s[i-1][j+1]==-1){
            s[i][j]++;
          }
          //右
          if(j!=w-1 && s[i][j+1]==-1){
            s[i][j]++;
          }
          //右下
          if(i!=h-1 && j!=w-1 && s[i+1][j+1]==-1){
            s[i][j]++;
          }
          //下
          if(i!=h-1 && s[i+1][j]==-1){
            s[i][j]++;
          }
          //左下
          if(i!=h-1 && j!=0 && s[i+1][j-1]==-1){
            s[i][j]++;
          }
          //左
          if(j!=0 && s[i][j-1]==-1){
            s[i][j]++;
          }

        }

      }
    }
    
    for(int i = 0 ; i < h ; ++i){
      for(int j = 0 ; j < w ; ++j){
        if(s[i][j] == -1){
          System.out.print("#");
        }else{
          System.out.print(s[i][j]);
        }
        
      }
      System.out.println();
    }

  }
}

Measured memory_bytes: 36448
#include<bits/stdc++.h>
#define maxn 100009
#define LL long long
using namespace std;
struct data{
  int nex,to,w;
}e[maxn*2];
int head[maxn],edge=0,tot,t[3],co[maxn],flag;
inline void add(int from,int to,int w){
  e[++edge]=(data){head[from],to,w};
  head[from]=edge;
}
void dfs(int x){
  t[co[x]]++;
  for(int i=head[x];i;i=e[i].nex){
    int v=e[i].to;if(e[i].w==1)tot++;
    if(co[v]==-1) co[v]=(co[x]+e[i].w+3)%3,dfs(v);
    else if(co[v]!=(co[x]+e[i].w+3)%3) flag=1;
  }
}
int main(){
  int n,m;LL ans=0;
  scanf("%d%d",&n,&m);
  for(int i=1,x,y;i<=m;i++)
    scanf("%d%d",&x,&y),add(x,y,1),add(y,x,-1);
  memset(co,-1,sizeof(co));
  for(int i=1;i<=n;i++)
    if(co[i]==-1){
      t[0]=t[1]=t[2]=tot=flag=0;
      co[i]=0;dfs(i);
      if(flag) ans+=(LL)(t[1]+t[2]+t[0])*(t[1]+t[2]+t[0]);
      else if(t[0] && t[1] && t[2]) ans+=(LL)t[0]*t[1]+(LL)t[1]*t[2]+(LL)t[2]*t[0];
      else ans+=tot;
    }
  printf("%lld",ans);
  return 0;
}


Measured memory_bytes: 6528
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define INF   (1e9 + 7)
#define MAX_N (50)

int N, M;
int S[MAX_N][2], C[MAX_N][2];

void solve() {
  for (int i = 0; i < N; i++) {
    int a = S[i][0], b = S[i][1];
    int goal = -1, cost = INF;
    for (int j = 0; j < M; j++) {
      int c = C[j][0], d = C[j][1];
      int x = abs(a - c) + abs(b - d);
      if (x < cost) {
        cost = x;
        goal = j + 1;
      }
    }
    printf("%d\n", goal);
  }
}

int main() {
  scanf("%d %d", &N, &M);
  for (int i = 0; i < N; i++) scanf("%d %d", &S[i][0], &S[i][1]);
  for (int i = 0; i < M; i++) scanf("%d %d", &C[i][0], &C[i][1]);

  solve();

  return 0;
}


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

using namespace std;

int main()
{
    long long  n, m, d, c, i;
    cin>>n>>m;
    d=m/n;
    c=m%n;
    for(i=d; i>0 ;i--)
    {
        if(c%i==0)
        {
            cout<<i<<endl;
            return 0;
        }
        c+=n;
    }
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#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 REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


ll a, b, c;
int main() {
	cin >> a >> b >> c;
	if (a < c and b > c)cout << "Yes" << endl;
	else if (a > c and b < c)cout << "Yes" << endl;
	else cout << "No" << endl;
}




Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C, long long D){
	while(1){
		C-=B;
		if(C<=0){
			cout << YES << endl;
			break;
		}
		A-=D;
		if(A<=0){
			cout << NO << endl;
			break;
		}
	}

}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    solve(A, B, C, D);
    return 0;
}


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

int main()
{
  string s;
  cin >> s;
  string t;
  cin >> t;
  int slen = s.length();
  int tlen = t.length();

  vector<vector<int>> cnum(26);
  vector<int> ccnt(26);
  for (int i=0; i<slen; i++) {
    cnum[s[i]-'a'].push_back(i+1);
  }
  ll cnt = 0;
  ll prev = 0;
  for (int i=0; i<tlen; i++) {
    int j = t[i] - 'a';
    if (cnum[j].empty()) {
      cout << -1 << endl;
      return 0;
    }
    ccnt[j]++;
    if (upper_bound(cnum[j].begin(), cnum[j].end(), prev) == cnum[j].end()) {
      if (cnt % slen == 0) {
        cnt = cnt + cnum[j][0];
      } else {
        cnt = (cnt/slen+1)*slen + cnum[j][0];
      }
      prev = cnum[j][0];
    } else {
      ll tmp = *upper_bound(cnum[j].begin(), cnum[j].end(), prev);
      cnt = cnt - prev + tmp;
      prev = tmp;
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 1216
from collections import Counter
n = int(input())
a1, a2 = [], []
for idx, ai in enumerate(map(int, input().split())):
    a1.append(ai+idx)
    a2.append(idx-ai)
cnt = Counter(a2)
res = 0
for idx, i in enumerate(a1):
    cnt[a2[idx]] -= 1
    res += cnt[i]
print(res)

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL ex_gcd(LL a, LL b, LL & x, LL & y) {
	LL d = a;
	if(b != 0) {
		d = ex_gcd(b, a % b, y, x);
		y -= (a / b) * x;
	} else { x = 1; y = 0; }
	return d;
}
LL divmod(LL x, LL y, LL MOD) {
	LL inv, m;
	ex_gcd(y, MOD, inv, m);
	if(inv < 0) { inv += MOD; }
	return x * inv % MOD;
}

LL n, a[100001], b[100001], v, MOD = 1e9 + 7;

int main() {
	cin >> n;
	inc(i, n + 1) { cin >> a[i]; }
	
	if(n == 1) { cout << "1\n1\n"; return 0; }
	
	inc(i, n + 1) { b[i] = -1; }
	inc(i, n + 1) {
		if(b[ a[i] ] != -1) {
			v = n + 1 - (abs(b[ a[i] ] - i) + 1);
			break;
		}
		b[ a[i] ] = i;
	}
	
	LL p = 1, q = n - 1, r = 1, s;
	inc1(k, n + 1) {
		// printf("%lld, %lld, %lld, %lld\n", p, q, r, s);
		LL ans = 0;
		if(k - 1 <= v) { ans += MOD - p; }
		if(inII(k - 0, 0, n - 1)) { ans += q; }
		if(inII(k - 1, 0, n - 1)) { ans += r * 2; }
		if(inII(k - 2, 0, n - 1)) { ans += s; }
		ans %= MOD;
		
		cout << ans << "\n";
		
		s = r;
		r = q;
		(q *= n - 1 - k) %= MOD;
		q = divmod(q, k + 1, MOD);
		(p *= v - (k - 1)) %= MOD;
		p = divmod(p, k, MOD);
	}
	
	return 0;
}


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

using namespace std;

int main() {
	char a = 'A', b;
	int n, ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b;
		if (a != b) {
			ans += 1;
			a = b;
		}
	}
	cout << ans;
	return 0;
}

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

int main() { int N;
  cin >> N;
  vector<string> v(N);

  int f = 0;
  for (int i = 0; i < N; i++) {
    cin >> v.at(i);
    if(v.at(i) =="Y"){
      f = 1;
      break;
    }
  }
  if(f==1){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 3584
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

pii p[100000];
vpii v;
int ans1[100001],ans2[100001];
int main() {
    int i;
    int N,L,R;
    scanf("%d",&N);
    for (i = 0; i < N; i++) scanf("%d %d",&L,&R),p[i] = mp(L,R);
    sort(p,p+N);

    for (i = 0; i < N; i++) {
        while (!v.empty() && (v.back().second >= p[i].second)) v.pop_back();
        v.pb(p[i]);
    }
    int l = 0,r = 1e9;
    for (i = 0; i < v.size(); i++) {
        l = max(l,v[i].first),r = min(r,v[i].second);
        ans1[i] = max(r-l+1,0);
    }
    l = 0,r = 1e9;
    for (i = v.size()-1; i >= 0; i--) {
        l = max(l,v[i].first),r = min(r,v[i].second);
        ans2[i] = max(r-l+1,0);
    }
    int ans = 0;
    for (i = 0; i < v.size(); i++) ans = max(ans,ans1[i]+ans2[i+1]);
    int m1 = 1e9,mi,m2 = 1e9;
    for (i = 0; i < N; i++) {
        if (p[i].second <= m1) m2 = m1,m1 = p[i].second,mi = i;
        else if (p[i].second <= m2) m2 = p[i].second;
    }
    for (i = 0; i < N; i++) {
        int l = (i == N-1) ? p[N-2].first:p[N-1].first;
        int r = (i == mi) ? m2:m1;
        ans = max(ans,p[i].second-p[i].first+1+max(r-l+1,0));
    }
    printf("%d\n",ans);

    return 0;
}



Measured memory_bytes: 2676
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

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

const int mod = 1000000007;


int tri[1000][1000];

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

  int n;
  cin >> n;

  int k;
  for(k = 1; k*k-k < 2*n; k++);

  if (k*k-k==2*n) {
    cout << "Yes" << endl;

    cout << k << endl;
    int kk = k-1;

    cout << kk << " "; 
    int cnt = 1;
    rep(i, kk) {
      rep(j, kk-i) {
        tri[i][j] = cnt++;
      }
    }

    rep(i, kk) {
      cout << tri[0][i] << " ";
    }
    cout << endl;

    rep(i, kk-1) {
      cout << kk << " "; 
      int j = 0;
      while(tri[i][j]) {
        cout << tri[j][i] << " ";
        j++;
      }
      j--;
      int i_ = i;
      while(i_ >= 1) {
        i_--;
        cout << tri[j][i_] << " ";
      }
      cout << endl;
    }

    cout << kk << " "; 
    rep(i, kk) {
      cout << tri[i][kk-i-1] << " ";
    }
    cout << endl;
    
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3200
k = gets.to_i
a =[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

puts a[k-1]

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

int main() {
	string str;
	bool flag=1;
	cin>>str;
	char a=str[0];
	for(int i=1; i<str.length(); i++) {
		if(i==str.length()-1) {
			if(str[i]>a) break;
			else {
				flag=0;
				break;
			}
		}
		if(str[i]>a) break;
		else if(str[i]<a) {
			flag=0;
			break;
		}
	}
	for(int i=0; i<str.length(); i++) {
		str[i]=a+flag;
		cout<<str[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<list>
#include<climits>

using namespace std;
#define rep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
    int n,c;
    cin>>n>>c;
    int d[31][31];
    rep(i,0,c)rep(j,0,c)cin>>d[i][j];
    int col[3][31];
    int tab[3][31];
    rep(i,0,3)rep(j,0,31)col[i][j]=tab[i][j]=0;
    rep(i,0,n)rep(j,0,n){
        int t;
        cin>>t;
        t--;
        col[(i+j+2)%3][t]++;
    }
    rep(i,0,3)rep(j,0,c)rep(k,0,c){
        tab[i][j]+=d[k][j]*col[i][k];
    }
    int ret=(int)1e9;
    rep(i,0,c)rep(j,0,c)rep(k,0,c){
        if(i!=j&&j!=k&&k!=i)
            ret=min(ret,tab[0][i]+tab[1][j]+tab[2][k]);
    }
    cout<<ret<<endl;
	return 0;
}



Measured memory_bytes: 256
a,b = gets.split(" ").map(&:to_i)
count = 0

2.times do 
    case a <=> b
    when 1 then
        count = count + a
        a = a - 1
    when 0 then
        count = count + a
        a = a - 1
    when -1 then 
        count = count + b
        b = b - 1
    end
end

puts count

Measured memory_bytes: 1788
n, x = map(int, input().split())
l = list(map(int, input().split()))
bound = []
for i in range(n+1):
    if i == 0:
        bound += [0]
    else:
        bound += [bound[i-1] + l[i-1]]
    if bound[i] > x:
        print(len(bound) - 1)
        exit()
print(len(bound))

Measured memory_bytes: 9096
let array_of_string s = Array.init (String.length s) (fun i -> s.[i])

let () =
  read_line ()
  |> array_of_string
  |> Array.map (fun c -> Char.code c - Char.code '0')
  |> Array.to_list
  |> (fun (h :: t) -> List.fold_left (fun acc d ->
      List.concat @@ List.map (fun (x, s) ->
        [ (x + d, Printf.sprintf "%s+%d" s d);
          (x - d, Printf.sprintf "%s-%d" s d) ]) acc) [(h, string_of_int h)] t)
  |> List.find (fun (x, _) -> x = 7)
  |> snd
  |> Printf.printf "%s=7"

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
inline int rd(char c[]){
  int i, 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]);
  }
}
char S[3][12];
int L[3];
int main(){
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<3;Lj4PdHRW++){
      L[Lj4PdHRW] = rd(S[Lj4PdHRW]);
    }
  }
  if(S[0][L[0]-1]==S[1][0] && S[1][L[1]-1]==S[2][0]){
    wt_L("YES");
    wt_L('\n');
  }
  else{
    wt_L("NO");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// char S[3][12]; int L[3];
// {
//   rd(S@L(3));
//   wt( if[ S[0][L[0]-1]==S[1][0] && S[1][L[1]-1]==S[2][0], "YES", "NO" ] );
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
  int n,m;
  cin >> n >> m;
  int ans = 0;
  ans += (n*(n-1))/(1*2);
  ans += (m*(m-1))/(1*2);
  cout << ans << endl;
return 0;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int main()
{
        //input->compute->output//

        int N;
        cin >> N;
        if (N / 10 == 9 || N % 10 == 9)
        {
                cout << "Yes" << endl;
        }
        else
        {
                cout << "No" << endl;
        }

        return 0;
}


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

using namespace std;

#define ll unsigned long long

void solve(){

    ll n; cin >> n;
    vector<ll> arr ((int)1e5+100, 0);
    ll sm = (ll)0;
    for(ll i = 0; i < n; ++i){
        ll x; cin >> x;
        sm += x;
        ++arr[x];
    }
    ll q; cin >> q;
    while(q--){
        ll b, c; cin >> b >> c;
        if(b == c){
            cout << sm << "\n";
            continue;
        }
        sm += (c - b) * arr[b];
        arr[c] += arr[b];
        arr[b] = 0;
        cout << sm << "\n";
    }

}


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

	return 0;
}



Measured memory_bytes: 3968
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long &x, long long &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a%b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a + b + 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
  //fmt.Print("Input :")
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  var length int
  var min int
  var max int
  var sum int
  var input int

  if sc.Scan() { length, _ = strconv.Atoi(sc.Text()) }
  if sc.Scan() { min, _ = strconv.Atoi(sc.Text()) }
  max = min
  sum = min
  for i := 0; i < length-1; i++ {
    if sc.Scan() {
      input , _ = strconv.Atoi(sc.Text())
      sum += input
      if min > input { min = input }
      if max < input { max = input }
    }
  }

  fmt.Printf("%d %d %d\n", min, max, sum)
}



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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int h, w, k;
    cin >> h >> w >> k;

    vector<string> c(h);
    rep(i, h) cin >> c[i];


    int res = 0;
    rep(ih, 1<<h){
        rep(iw, 1<<w){
            vector<int> use_h(h, 0), use_w(w, 0);

            rep(j, h){
                if(ih & (1<<j)) use_h[j] = 1;
            }
            rep(j, w){
                if(iw & (1<<j)) use_w[j] = 1;
            }

            int cnt = 0;
            rep(i, h) rep(j, w){
                if(use_h[i] == 1 || use_w[j] == 1) continue;
                if(c[i][j] == '.') continue;

                ++cnt;
            }

            if(cnt == k) ++res;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3652
class Dice{
	
public:
	Dice(int top, int front, int right,
		 int left, int back, int bottom);  //?????????????????????(?????°??????)
	int get_right();
	void roll_topfront(int top, int front);
	void roll(char r);
	
private:
	
	void roll_top(int top);
	void roll_front(int front);
	void roll_n();
	void roll_e();
	void roll_s();
	void roll_w();
	int m_top;
	int m_front;
	int m_right;
	int m_left;
	int m_back;
	int m_bottom;
	void show_all();
};

#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> Dice_bec;

int main(void)
{
	Dice_bec dice_bec;
	int num;
	int q;  //???????????°
	
	for(int i = 0; i < 6; i++){
		cin >> num;
		dice_bec.push_back(num);
	}
	cin >> q;
	
	
	Dice dice(dice_bec[0], dice_bec[1], dice_bec[2],
			  dice_bec[3], dice_bec[4], dice_bec[5]);  //?????????????????????
			  
	
	for(int i = 0; i < q; i++){
		
		int top, front;
		cin >> top
		    >> front;
		dice.roll_topfront(top, front);
		
		cout << dice.get_right() << endl;
	}
	
	return 0;
	
}

Dice::Dice(int top, int front, int right,      //?????????????????????
		   int left, int back, int bottom) :
		   m_top(top), m_front(front), m_right(right),
		   m_left(left), m_back(back), m_bottom(bottom)
{
	//	????????????
}


void Dice::roll_topfront(int top, int front)
{
	roll_front(front);
	roll_top(top);
}

void Dice::roll_front(int front)
{
	if(front == m_front){
	}
	//????????¢
	else if(front == m_top){
		roll_s();
	}
	else if(front == m_back){
		for(int i = 0; i < 2; i++){
			roll_s();
		}
	}
	else if(front == m_bottom){
		roll_n();
	}
	//?¨??????¢
	else if(front == m_right){
		roll_w();
		roll_s();
	}
	else if(front == m_left){
		roll_e();
		roll_s();
	}
}

void Dice::roll_top(int top)
{
	while(top != m_top){
		roll_e();
	}
	
}

void Dice::roll_n()
{
	int temp = m_back;
	
	m_back   = m_top;
	m_top    = m_front;
	m_front  = m_bottom;
	m_bottom = temp;
	
}
void Dice::roll_e()
{
	int temp = m_top;
	
	m_top    = m_left;
	m_left   = m_bottom;
	m_bottom = m_right;
	m_right  = temp;
	
}

void Dice::roll_s()
{
	int temp = m_front;
	
	m_front  = m_top;
	m_top    = m_back;
	m_back   = m_bottom;
	m_bottom = temp;
}

void Dice::roll_w()
{
	int temp = m_left;
	
	m_left   = m_top;
	m_top    = m_right;
	m_right  = m_bottom;
	m_bottom = temp;
}

int Dice::get_right()
{
	return m_right;
}


void Dice::show_all()
{
	cout << m_top << ' '
		 << m_front << ' '
		 << m_right<< ' '
		 << m_left << ' '
		 << m_back << ' '
		 << m_bottom << ' ' << endl;
}

void Dice::roll(char r)
{
	switch(r){
	case 'N' :
		 roll_n();
		 break;
	case 'E' :
		 roll_e();
		 break;
	case 'S' :
		 roll_s();
		 break;
	case 'W' :
		 roll_w();
		 break;
	}
}

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

#define F first
#define S second
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const long long max_n = 100011, inf = 1000111222;



int main() {
	int n, k = -1;
	cin >> n;
	for (int i = 2; 1LL * i * (i - 1) / 2 <= n; ++i) {
		if (1LL * i * (i - 1) / 2 == n) {
			k = i;
			break;
		}
	}
	if (k == -1) {
		cout << "No" << endl;
		return 0;
	}
	std::vector<std::vector<int> > sets(k);
	int cnt = 0;
	for (int i = 0; i < k; ++i) {
		for (int q = i + 1; q < k; ++q) {
			++cnt;
			sets[i].push_back(cnt);
			sets[q].push_back(cnt);
		}
	}
	cout << "Yes\n";
	cout << sets.size() << endl;
	for (int i = 0; i < sets.size(); ++i) {
		cout << sets[i].size() << " ";
		for (int val : sets[i]) {
			printf("%d ", val);
		}
		std::cout << "\n";
	}
	std::cout << endl;
	return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>


using namespace std;
typedef long long ll;
ll N;

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

int main(){

    ll N, X;
    cin >> N >> X;

    vector<ll > p(N + 1, 0);
    p[0] = X;
    for(ll i = 1; i <= N; i++){
        cin >> p[i];
    }

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

    map<ll, ll> mp;

    for(ll i = 1; i <= N; i++){
        //cout << p[i]  << endl;
        mp[p[i] - p[i-1]]++;
    }

    ll ans = 0;
    auto begin = mp.begin(), end = mp.end();
    for (auto iter = begin; iter != end; iter++) {
        if(iter == begin){
            ans = iter->first;
            //cout << "a" << endl;
        }else{
            ans = gcd(ans, iter->first);
        }
    }

    cout << ans << endl;


}

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

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}

int main() {
  int k;
  cin >> k;
  ll ans = 0;
  for (int a = 1; a <= k; ++a) {
    for (int b = 1; b <= k; ++b) {
      for (int c = 1; c <= k; ++c) {
	int g = gcd(a, gcd(b, c));
	ans += g;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define deb(x) cout<<#x<<" : "<<x<<"\n";
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define deb_arr(a,n) {cout<<#a<<":";for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';}
#define deb_mat(dist,n,m) {cout<<#dist<<"\n";for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}}
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define all(a) (a).begin(),(a).end()
#define bs binary_search
#define sz size()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define clr fflush(stdout);
//#define clr cout.flush();
#define N 200001
#define fpr(i,a,b) for(int i=a;i<b;i++)
#define fdr(i,a,b) for(int i=a;i>b;i--)
#define repp(i,a,b,d) for(int i=a;i<b;i+=d)
#define repd(i,a,b,d) for(int i=a;i>b;i-=d)
#define LLMIN LLONG_MIN
#define LLMAX LLONG_MAX
#define AKASH_PATEL ios_base::sync_with_stdio(false);
#define SVNIT_SURAT cin.tie(NULL);cout.tie(NULL);
#define mset(x,a) memset(x,a,sizeof(x));
#define nl cout<<'\n';
#define print(c) cout<<c<<'\n';
#define setp(n) cout << fixed << setprecision(n)
#define take_arr(a,n) fpr(i,0,n) cin>>a[i];
#define print_arr(a,n) for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';
#define take_mat(mat,n,m) fpr(i,0,n) fpr(j,0,m) cin>>mat[i][j];
#define set_mat(mat,n,m,k) fpr(i,0,n) fpr(j,0,m) mat[i][j]=k;
#define print_mat(dist,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
template< class T > bool odd(T a) { return a&1; }
template< class T > bool even(T a) { return !(a&1); }
int main()
{
//#ifndef ONLINE_JUDGE
//    freopen("../ip.txt", "r", stdin);
//    freopen("../op.txt", "w", stdout);
//#endif
    AKASH_PATEL;
    SVNIT_SURAT;
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll sum,n;
        cin>>sum>>n;
        ll a[n];
        take_arr(a,n)
        ll tp=accumulate(a,a+n,0ll);
        if(tp>sum)
        {
            print("-1")
        }
        else
        {
            print(sum-tp)
        }
    }
    return 0;
}





Measured memory_bytes: 3732
import sys

def daysOfYear(y):
    if y <= 0:
        return 0
    elif y % 3 == 0:
        return 200
    else:
        return 195

def daysOfMonth(y, m):
    if y % 3 == 0 or m % 2 == 1:
        return 20
    else:
        return 19


mil = 1
for i in xrange(1, 1000):
    mil += daysOfYear(i)

raw_input()
for line in sys.stdin:
    y, m, d = map(int, line.split())
    s = 0
    for i in xrange(1, y):
        s += daysOfYear(i)
    for i in xrange(1, m):
        s += daysOfMonth(y, i)
    print mil - s - d

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int h,w,n,k;
int mp[52][52];

int main(){
  scanf("%d%d%d%d",&h,&w,&n,&k);
  REP(i,h)REP(j,w){
    printf("? %d %d %d %d\n",i,j,i,j);
    fflush(stdout);
    int p;
    scanf("%d",&p);
    mp[i][j] = p;
  }
  ll ans = 0;
  ll b = 1;
  REP(i,h)REP(j,w){
    ans = (ans+mp[i][j]*b)%k;
    b = b*2%k;
  }
  printf("! %lld\n",ans);
  return 0;
}


Measured memory_bytes: 724
#include <iostream>

using namespace std;

int main(){
   int a,b;
   cin>> a>>b;
   if (a+b>a-b&&a+b>=a*b){cout<<a+b<<endl;}

   else if (a-b>=a+b&&a-b>a*b){cout<< a-b<<endl;}
    
   else {cout<< a*b<<endl;}

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-15;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
struct Point{double x,y;};
double dis(Point a,Point b){
  return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
Point tri(Point a, Point b, Point c){
  double a1,a2,b1,b2,c1,c2;
  a1=2*(b.x-a.x);
  b1=2*(b.y-a.y);
  c1=a.x*a.x-b.x*b.x+a.y*a.y-b.y*b.y;
  a2=2*(c.x-a.x);
  b2=2*(c.y-a.y);
  c2=a.x*a.x-c.x*c.x+a.y*a.y-c.y*c.y;
  Point p;
  p.x=(b1*c2-b2*c1)/(a1*b2-a2*b1);
  p.y=(c1*a2-c2*a1)/(a1*b2-a2*b1);
  return p;
}
int main(){
  startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,k,l,N;
  cin>>N;
  double ans=inf,fir;
  vector<Point> v(N);
  Point x;
  rep(i,N)cin>>v[i].x>>v[i].y;
  sort(all(v),[](auto a,auto b){if(a.x!=b.x){return a.x<b.x;}else{return a.y<b.y;}});
  rep(i,N)For(j,i+1,N){
    double res=dis(v[i],v[j])*0.5;
    fir=res;
    x.x=(v[i].x+v[j].x)/2;
    x.y=(v[i].y+v[j].y)/2;
    rep(k,N){
      if(i==k||j==k)continue;
      if(dis(x,v[k])>fir+eps){
        res=inf;
        break;
      }
    }
    chmin(ans,res);
  }
  rep(i,N)For(j,i+1,N)For(k,j+1,N){
    if((v[i].x-v[k].x)*(v[j].y-v[k].y)!=(v[i].y-v[k].y)*(v[j].x-v[k].x)){
      x=tri(v[i],v[j],v[k]);
      fir=dis(x,v[i]);
      rep(l,N){
        if(l==i||l==j||l==k)continue;
        if(dis(x,v[l])>fir+eps){
        fir=inf;
        break;
        }
      }
      chmin(ans,fir);
    }
  }
  print(ans);
  return 0;
}


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

hedfoot = [[0]*(10) for i in range(10)];

for i in range(1,n+1) :
	hed = i % 10;
	i_str = str(i);
	foot = int(i_str[0]);
	hedfoot[foot][hed] += 1;

ans = 0;
for i in range(1,n+1) :
	hed = i % 10;
	i_str = str(i);
	foot = int(i_str[0]);
	ans += hedfoot[hed][foot];

print(ans);

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    string a;
    int c,i;
    cin>>a;
    c=0;
    for(i=0;i<=3;i++)
    {
        if(a[i]==43)
            c++;
        else
            c--;
        /*cout<<a<<endl;
        cout<<c<<endl;*/
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 256
l=raw_input()
k=l.split()
a=int(k[0])
op=k[1]
b=int(k[2])
#
while op<>'?':
        if op=='+':
                print a + b
        if op=='-':
                print a - b
        if op=='*':
                print a * b
        if op=='/':
                print a / b
#
        l=raw_input()
        k=l.split()
        a=int(k[0])
        op=k[1]
        b=int(k[2])

Measured memory_bytes: 6428
MOD = 10**9+7
n = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))
C = [0]*n
if T[0] > A[0] or T[-1] < A[-1]:
  print(0)
  exit()
C[0], C[-1] = 1, 1
for i in range(1, n-1):
  if T[i-1] == T[i]:
    t = -T[i]
  else:
    t = T[i]
  if A[i] == A[i+1]:
    a = -A[i]
  else:
    a = A[i]
  if t > 0 and a > 0:
    if t != a:
      print(0)
      exit()
    C[i] = 1
  else:
    if t > 0:
      if t > abs(a):
        print(0)
        exit()
      C[i] = 1
    elif a > 0:
      if a > abs(t):
        print(0)
        exit()
      C[i] = 1
    else:
      C[i] = min(-t, -a)
ans = 1
for i in C:
  ans *= i
  ans %= MOD
print(ans)

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

using namespace std;

int n, k;

int sche[100];

int dp[100][4][4];

int rec(int day, int a, int b) // a = i - 2 ??\???, b = i - 1 ??\???
{
	if (day == n) return 1;

	if (dp[day][a][b] >= 0) return dp[day][a][b];
	
	int res = 0;
	
	if (sche[day]) {
		if (sche[day] != a || sche[day] != b) {
			res += rec(day + 1, b, sche[day]);
			res %= 10000;
		}
	} else {
		for (int i = 1; i <= 3; ++i) {
			if (a == b && b == i) continue;
			res += rec(day + 1, b, i);
			res %= 10000;
		}
	}

	return dp[day][a][b] = res;
}

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

	for (int i = 0; i < k; ++i) {
		int day; cin >> day; --day;
		cin >> sche[day];
	}

	memset(dp, -1, sizeof(dp));

    int ans = 0;

    if (sche[0] && sche[1]) {
        ans += rec(2, sche[0], sche[1]) % 10000;
    } else if (sche[0]) {
        for (int j = 1; j <= 3; ++j) {
            ans += rec(2, sche[0], j);
            ans %= 10000;
        }
    } else if (sche[1]) {
        for (int i = 1; i <= 3; ++i) {
            ans += rec(2, i, sche[1]);
            ans %= 10000;
        }
    } else {
        for (int i = 1; i <= 3; ++i) for (int j = 1; j <= 3; ++j) {
            ans += rec(2, i, j);
            ans %= 10000;
        }
    }

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

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

const int INF = INT_MAX / 2;

int main(){
    int N, M; cin >> N >> M;
    vector<int> h(N);
    for (int i = 0; i < N; i++) cin >> h[i];
    vector<int> m(N, -INF);

    for (int i = 0; i < M; i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        m[a] = max(m[a], h[b]);
        m[b] = max(m[b], h[a]);
    }

    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        if(h[i]>m[i]) cnt++;
    }
    
    cout << cnt << endl;
    
}

Measured memory_bytes: 4056
l, r = [int(v) for v in input().split()]

ans = 2019
if r - l >= 673:
  ans = 0
else:
  for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
      cand = (i * j) % 2019
      if cand < ans:
        #print(i, j, cand)
        ans = cand
          
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
typedef long long ll;
using namespace std;



int main()
{
    int N;
    cin >> N;
    vector<int> L(N);
    for(int i = 0; i < N; i++) cin >> L[i];
    sort(L.begin(),L.end());
    int total = 0;
    for (int i = 0; i < N -1; i++)
    {
        total += L[i];
    }
    if(total > L[N - 1]) cout << "Yes" << endl;
    else cout << "No" << endl;

} 

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

bool d[10010][1270];

int main() {

  long long int n, m, r, q, input_t, input_n, input_m, input_s;

  while( true ) {

    cin >> n >> m;

    if ( n == 0 ) break;

    cin >> r;

    for ( long long int i = 0; i < 10010; i++ ) {
      for ( long long int j = 0; j < 1270; j++ ) {
	d[i][j] = false;
      }
    }
    long long int pc[1010] = {0};
    for ( long long int i = 0; i < r; i++ ) {
      cin >> input_t >> input_n >> input_m >> input_s;
      if ( pc[input_n] == 0 ) {
	pc[input_n] = input_t;
      }else {
	for ( long long int i = pc[input_n]; i < input_t; i++ ) {
	  d[input_m][i] = true;
	}
	pc[input_n] = 0;
      }
    }
    cin >> q;
    for ( long long int i = 0; i < q; i++ ) {
      cin >> input_t >> input_s >> input_m;
      long long int ans = 0;
      for ( long long int j = input_t; j < input_s; j++ ) {
	if ( d[input_m][j] ) ans++;
      }
      cout << ans << endl;
    }

  }

  return 0;

}

Measured memory_bytes: 13572
#include <iostream>
using namespace std;
int main(){
    int dice[6];
    int n;
    int x,y;
    for(int i=0;i<6;i++){
        cin>>dice[i];
    }
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        if((x==dice[3] && y==dice[1]) || (x==dice[4] && y==dice[3]) || (x==dice[2] && y==dice[4]) ||(x==dice[1] && y==dice[2])){
            cout<<dice[0]<<endl;
        }
        else if((x==dice[0] && y==dice[3]) || (x==dice[3] && y==dice[5]) || (x==dice[5] && y==dice[2]) || (x==dice[2] && y==dice[0])){
            cout<<dice[1]<<endl;
        }
        else if((x==dice[0] && y==dice[1]) || (x==dice[1] && y==dice[5]) || (x==dice[5] && y==dice[4]) || (x==dice[4] && y==dice[0])){
            cout<<dice[2]<<endl;
        }
        else if((x==dice[0] && y==dice[4]) || (x==dice[4] && y==dice[5]) || (x==dice[5] && y==dice[1]) || (x==dice[1] && y==dice[0])){
            cout<<dice[3]<<endl;
        }
        else if((x==dice[0] && y==dice[2]) || (x==dice[2] && y==dice[5]) || (x==dice[5] && y==dice[3]) || (x==dice[3] && y==dice[0])){
            cout<<dice[4]<<endl;
        }
        else if((x==dice[2] && y==dice[1]) || (x==dice[1] && y==dice[3]) || (x==dice[3] && y==dice[4]) || (x==dice[4] && y==dice[2])){
            cout<<dice[5]<<endl;
        }
    }
return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <string.h>
#pragma warning(disable : 4996)
#pragma warning(disable : 4996)

#define H_MAX 10000
#define N_MAX 1000
#define INF 100000000


int min(int a, int b) {
	if (a < b) return a;
	return b;
}

// DP[j] jのダメージを与えるために使用する最低の魔力　
int DP[H_MAX+1];

int main(void) {
	int H, N;
	scanf("%d %d", &H, &N);
	for (int j = 0; j <= H; ++j) {
		DP[j] = INF;
	}
	DP[0] = 0;
	for (int i = 1; i <= N; ++i) {
		int A, B;
		scanf("%d %d", &A, &B);
		for (int j = 0; j <= H; ++j) {
			if (A >= H) {
				if(DP[H] > B) DP[H] = B;
			}
			else {
				int AA = A;
				do {
					if ((j >= AA) && (DP[j - AA] + B < DP[j])) DP[j] = DP[j - AA] + B;
					--AA;
				} while (j + AA > H);
			}
		}
	}
	printf("%d\n", DP[H]);
	return 0;
}
 

Measured memory_bytes: 256
/*
2017_05_13_AC
<point>
・経路のコストが最大化するようにWFする。（いつもと逆）
（？）・ノード[N-1]が、自分自身への”正の”経路を持っている場合は、
　無限にコストを増やすことが可能になる。
　※N-1からN-1への初期値は-1。
・計算時間は、ピッタリ10^9なのでギリギリ通る。
<caution>

*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)
#define F first
#define S second

using namespace std;

const long long INF = 1e18;

int N,M;
long long road[1010][1010];

int main() {
  cin>>N>>M;

  REP(i,0,N){
    REP(j,0,N){
      if(i==j) road[i][j] = 0;
      else road[i][j] = (-1)*INF;
    }
  }

  REP(i,0,M){
    int a, b, c;
    cin>>a>>b>>c;
    road[a-1][b-1] = c;
  }

  REP(k,0,N){
    REP(i,0,N){
      REP(j,0,N){
        road[i][j] = max(road[i][j],road[i][k] + road[k][j]);
      }
    }
  }

  bool flag = false;
  REP(i,0,N) if(road[i][i]>0) flag = true;

  if(road[N-1][N-1] > 0){
  //if(flag){
    cout<<"inf"<<endl;
  }else{
    cout<<road[0][N-1]<<endl;
  }

  return 0;
}


Measured memory_bytes: 8192
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=10000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
int n,k,dp[100100],h[100100];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int main()
{
	n=read();k=read();
	rep(i,1,n) h[i]=read();
	memset(dp,0x3f,sizeof(dp));dp[1]=0;
	rep(i,1,n)
		rep(j,1,min(i,k))
			dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
	//rep(i,1,n) cout << dp[i] << " ";cout << endl;
	printf("%d",dp[n]);
	return 0;
}


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


void cc_env() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	//
#endif
}



int main() {
	// cc_env();
	// input part
	int N, K;
	cin >> N >> K;

	vector<int> inputArr(N);
	for (int i = 0; i < N; i++)
		cin >> inputArr[i];

	// procssing part;

	vector<bool> dp(K + 1, false);

	for (int i = 1; i <= K; i++) {
		for (int j = 0; j < (int)inputArr.size(); j++) {
			if (i - inputArr[j] < 0) break;

			else if (dp[i - inputArr[j]] == false) {
				dp[i] = true;
				break;
			}
		}
	}


	string ans = dp[K] == true ? "First" : "Second";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256