akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <unordered_map>
#include <map>
#include <set>
#include <unordered_set>
#include <sstream>
typedef long long ll;
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    //for writing to files
    //freopen('input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll N;
    cin >> N;
    cout << N * (N+1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
// Grouping

#include <iostream>

using namespace std;

int main(){
	int x, y;
	cin >> x >> y;

	// group1: 1 3 5 7 8 10 12
	// group2: 4 6 9 11
	// group3: 2
	int g[13] = {0,1,3,1,2,1,2,1,1,2,1,2,1};

	if (g[x] == g[y])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

typedef long long ll;
const int MOD = 1000000007;


int main(){
  int N,K;
  cin >> N >> K;
  vector<int> D(K);
  vector<bool> d(10, false);
  for(int i = 0; i < K; i++){
    cin >> D[i];
    d[D[i]] = true;
  }
  ll res = N;
  while(1){
    ll tmp = res;
    bool flag = true;
    while(tmp){
      if(d[tmp%10]){
	flag = false;
	break;
      }
      tmp = tmp / 10;
    }
    if(flag){
      break;
    }else{
      res++;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <bitset>
#include <cmath>
#include <iostream>

using namespace std;

int a(int i) {
  int ret{};
  for (int j = 0; j != i; ++j) {
    ret += lround(pow(2, 2 * j + 1));
  }
  return ret;
}

int main() {
  long long N;
  cin >> N;
  bitset<64> ans;

  for (int i = 0; i != 16; ++i) {
    auto x = ((N + a(i)) >> 2*i) % 4;
    ans.set(2 * i + 1, x & 0x2);
    ans.set(2 * i, x & 0x1);
  }
  
  bool flag{false};
  for (int i = 31; i >= 0; --i) {
    if (flag |= ans.test(i), !flag) continue;
    cout << ans.test(i);
  }
  if (!flag) cout << 0;
  cout << endl;
}


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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T, class Op = multiplies<T>>
constexpr T power(T a, long long n, Op op = Op(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}

template <unsigned M> struct modular {
  using m = modular;
  static constexpr unsigned mod = M;
  unsigned v;
  modular(long long x = 0) : v((x %= mod) < 0 ? x + mod : x) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m b) { if ((int)(v += b.v - mod) < 0) v += mod; return *this; }
  m& operator-=(m b) { if ((int)(v -= b.v) < 0) v += mod; return *this; }
  m& operator*=(m b) { v = (uint64_t)v * b.v % mod; return *this; }
  m& operator/=(m b) { return *this *= power(b, mod - 2); }
  friend m operator+(m a, m b) { return a += b; }
  friend m operator-(m a, m b) { return a -= b; }
  friend m operator*(m a, m b) { return a *= b; }
  friend m operator/(m a, m b) { return a /= b; }
  friend bool operator==(m a, m b) { return a.v == b.v; }
};

using mint = modular<998244353>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector a(3, vector<mint>(512));
  for (int t = 0; t < 3; ++t) {
    int m;
    cin >> m;
    vector<vector<int>> g(n);
    while (m--) {
      int u, v;
      cin >> u >> v;
      --u, --v;
      tie(u, v) = minmax({u, v});
      g[u].push_back(v);
    }
    vector<int> gr(n);
    for (int v = n; v--; ) {
      set<int> se;
      for (int to : g[v]) {
        se.insert(gr[to]);
      }
      for (int x = 0; ; ++x) {
        if (not se.count(x)) {
          gr[v] = x;
          break;
        }
      }
      a[t][gr[v]] += power<mint>(10, 18 * (v + 1));
    }
  }
  mint res;
  for (int i = 0; i < 512; ++i) {
    for (int j = 0; j < 512; ++j) {
      int k = i ^ j;
      res += a[0][i] * a[1][j] * a[2][k];
    }
  }
  cout << res.v << '\n';
}


Measured memory_bytes: 8080
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
  int k;
  int a,b;
  cin >> k >> a >> b;
  int i;
  int flag=0;
  for(i=a;i<b+1;i++){
    if(i%k==0){
      flag=1;
      break;
    }
  }
  if(flag==1) puts("OK");
  else puts("NG");
  return 0; 
}


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

int main()
{
    int n, t;
    cin >> n >> t;
    vector<int> cl(n), tl(n);
    rep(i, n)
    {
        cin >> cl.at(i) >> tl.at(i);
    }

    if (*min_element(tl.begin(), tl.end()) > t)
    {
        cout << "TLE" << endl;
    }
    else
    {
        int min = INT_MAX;
        rep(i, n)
        {
            if (tl.at(i) <= t and min > cl.at(i))
            {
                min = cl.at(i);
            }
        }
        cout << min << endl;
    }
}

Measured memory_bytes: 256
import itertools
import math
import fractions
import functools
import copy

n,m = map(int, input().split())
a = set()
for _ in range(m):
    a.add(int(input()))

dp = [0]*(n+5)
dp[0] = 1
for i in range(n):
    if i+1 not in a:
        dp[i+1] += dp[i]
    if i+2 not in a:
        dp[i+2] += dp[i]
print(dp[n] % 1000000007)

Measured memory_bytes: 478180
#include<stdio.h>
int main(){
    int i;
    char s[10];
    for(i=0;i<10;i++){
        scanf("%c",&s[i]);
    }
    s[3]='8';
    for(i=0;i<10;i++){
        printf("%c",s[i]);
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
#define fin return 0
#define input(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = (ll)1e19;

int r[100], l[100];
int a, b;

#define MAX 9223372036854775807
/*********************** */

int main() {
	int n;cin >> n;
	vi a(n);
	for(int i = 0;i < n;i++)cin >> a[i];
	vi b(n);
	for(int i = 0;i < n;i++)b[i] = a[i];
	sort(all(a));
	int k = 0;
	for(int i = 0;i < n;i++) if(a[i] != b[i]) k++;
	if(k == 2|| k == 0)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


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

int main(void) {

    int N;
    vector<int> a;

    cin >> N;
    a.reserve(N + 1);
    bool impossible = true;
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
    }

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

    if (cnt == 0) cout << "-1" << endl;
    else cout << N - cnt << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
using namespace std;

/*
const int MAX=1000;
vector<vector<int> > memo(MAX,vector<int>(MAX));
vector<vector<int> > done(MAX,vector<int>(MAX));
int dfs(vector<vector<int> > vi,int i,int j,int sum);

int main(){
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	int m,n;
	while(cin>>m>>n&&m!=0&&n!=0){
		vector<vector<int> > ice(m,vector<int>(n));
		int ans=0;
		for(int i=0; i<MAX; ++i){
			for(int j=0; j<MAX; ++j){
				memo[i][j]=0;
				done[i][j]=0;
			}
		}
		for(int i=0; i<n; ++i){
			for(int j=0; j<m; ++j){
				cin >> ice[j][i];
			}
		}
		for(int i=0; i<n; ++i){
			for(int j=0; j<m; ++j){
				if(ice[i][j]==1) {
					ans=max(ans,dfs(ice,i,j,0));
				}
			}
		}
		cout << ans << "\n";
	}
	return 0;
}

int dfs(vector<vector<int> > vi,int i,int j,int sum){
	if(done[i][j]==1) return memo[i][j];
	if(i+1>=vi.size()&&j+1>=vi[i].size()&&i-1<0&&j-1<0&&vi[i+1][j]==0&&vi[i][j+1]==0&&vi[i-1][j]==0&&vi[i][j-1]==0) return sum;
	done[i][j]=1;
	++sum;
	if(i+1<vi.size()) memo[i][j]=dfs(vi,i+1,j,sum+1);
	if(j+1<vi[i].size()) memo[i][j]=dfs(vi,i,j+1,sum+1);
	if(i-1>=0) memo[i][j]=dfs(vi,i-1,j,sum+1);
	if(j-1>=0) memo[i][j]=dfs(vi,i,j-1,sum+1);
	return memo[i][j]; 
}
*/

int main(){
	queue<int> n;
	queue<char> s;
	int m;
	char l;
	cin >> m;
	n.push(m);
	cin >> l;
	s.push(l);
	while(1){
		int t1,t2;
		if(s.front()=='='){
			cout << n.front() << "\n";
			break;
		}
		for(int i=0; i<2; ++i){
			if(i==0){
				int t;
				cin >> t;
				n.push(t);
			} else if(i==1){
				char t;
				cin >> t;
				s.push(t);
			}
		}
		switch(s.front()){
		case '+':
			t1=n.front();
			n.pop();
			t2=n.front();
			n.pop();
			n.push(t1+t2);
			break;
		case '-':
			t1=n.front();
			n.pop();
			t2=n.front();
			n.pop();
			n.push(t1-t2);
			break;
		case '*':
			t1=n.front();
			n.pop();
			t2=n.front();
			n.pop();
			n.push(t1*t2);
			break;
		case '/':
			t1=n.front();
			n.pop();
			t2=n.front();
			n.pop();
			n.push(t1/t2);
			break;
		default:
			break;
		}
		s.pop();
	}
	return 0;
}

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

int main(void){
    int a, b;
    cin >> a >> b;

    for(int i = 1; i <= 1000; i++){
        if((int)(i * 0.08) == a){
            if((int)(i * 0.1) == b){
                cout << i << endl;
                break;
            }
        }
        if(i == 1000) cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define DEBUG 0

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

ll N, K;
#define MAX_N (2000)
#define MAX_A (2000)
ll A[MAX_N+5];
// int gint[MAX_A+5];
ll lint[MAX_A+5];

ll lA[MAX_N+5];

int main(int argc, char *argv[])
{
	ll deno = (1000*1000*1000)+7;
	ios::sync_with_stdio(false);
	cin >> N >> K;
	FOR(n,N) {
		cin >> A[n];
	}
	for(int n=N-1;n>=0;n--) {
		lA[n] = lint[A[n]];
		for(ll i=A[n]+1;i<=MAX_A;i++) {
			lint[i]++;
			lint[i]%=deno;
		}
	}
#if DEBUG
	FOR(n,N) {
		DOUT << "A["<<n<<"]="<<A[n]<<endl;
		DOUT << "lA["<<n<<"]="<<lA[n]<<endl;
	}
#endif
	ll ans = 0;
	FOR(n,N) {
		ans += (ll)lA[n]*(ll)K % deno;
		ans %= deno;
		ans += (lint[A[n]] * (K*(K-1)/2%deno))%deno;
		ans %= deno;
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll unsigned long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

void solve() {
    int i,j,X,N,Y;
    cin >> N >> X >> Y;
    X--; Y--;
    map<int,int> a;
    fo(i,N-1){
      int k;
      Fo(j,i+1,N){
        if(i<=X && Y<=j)
          k=j-i-(Y-X)+1;
        else if(X<=i && j<=Y)
          k=min(j-i,Y-X+1-(j-i));
        else if(j<=X || Y<=i)
          k=j-i;
        else if(i<=X && j<=Y)
          k=X-i+min(j-X,Y-j+1);
        else if(X<=i && Y<=j)
          k=j-Y+min(Y-i,i-X+1);
        a[k]++;
      }
    }
    Fo(i,1,N){
      cout << a[i] << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

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

    return 0;
}




Measured memory_bytes: 3688
k = int(input())
from collections import deque
d = deque([1,2,3,4,5,6,7,8,9])
for i in range(k):
  x = d.popleft()
  m = x%10
  if m != 0:
    d.append(10*x+m-1)
  d.append(10*x+m)
  if m != 9:
    d.append(10*x+m+1)
print(x)

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


int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  if(a==0){
    cout<<1;
  }else if(b==0){
    cout<<2;
  }else if(c==0){
    cout<<3;
  }else if(d==0){
    cout<<4;
  }else{
    cout<<5;
  }




}

Measured memory_bytes: 3636
//ワーシャルフロイド
fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(' ').map(String::toInt)
    val costMap = Array(10) { readLine()!!.split(' ').map(String::toInt).toIntArray() }
    for (i in 0..9) {
        for (j in 0..9) {
            for (k in 0..9) {
                costMap[j][k] = Math.min(costMap[j][k], costMap[j][i] + costMap[i][k])
            }
        }
    }
    val numCount = Array(10) { 0 }
    for (i in 1..h) {
        for (num in readLine()!!.split(' ').map(String::toInt)) {
            if (num != -1) numCount[num]++
        }
    }
    val cost = (0..9).map{numCount[it]*costMap[it][1]}.sum()
    println(cost)
}


Measured memory_bytes: 40384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {

	private static Scanner sc;

	public static void main(String[] args) {
		Main instance = new Main();
		sc = instance.new Scanner();
		instance.solve();
	}

	private void solve() {
		try {
			int n = sc.nextInt();
			
			
			
			System.out.println(n % 2 == 0 ? n / 2 : n / 2 + 1);
			
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private class Scanner {
		String[] s;
		int i;
		BufferedReader br;
		String regex = " ";

		public Scanner() {
			s = new String[0];
			i = 0;
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		@Override
		protected void finalize() throws Throwable {
			try {
				super.finalize();
			} finally {
				destruction();
			}
		}

		private void destruction() throws IOException {
			if (br != null)
				br.close();
		}

		public String next() throws IOException {
			if (i < s.length)
				return s[i++];
			String st = br.readLine();
			while (st == "")
				st = br.readLine();
			s = st.split(regex, 0);
			i = 0;
			return s[i++];
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public Long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public Double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}


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


int main(){
  ll n, sum_a=0;
  cin >> n;
  ll a[n];
  for(ll i=0;i<n;i++){
    cin >> a[i];
    sum_a += a[i];
  }
  ll mi , sum_s = a[0];
  sum_a -= a[0];
  mi = abs(sum_a - a[0]);
  for(ll i=1;i<n-1;i++){
    sum_s += a[i];
    sum_a -= a[i];
    mi = min(mi, abs(sum_s - sum_a));
  }
  cout << mi << endl;
  return 0;
}

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

int N;
int a,b,ans=0;
int P[100010]={};

int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin  >> a >> b;
    for(int j=a-1;j<=b-1;j++){
      P[j]+=1;
    }
  }
  for(int i=0;i<=N+1;i++){
    //cout << P[i] << endl;
  }
  for(int i=1;i<=N+1;i++){
    //cout << P[i] << endl;
    //ans = max(ans,P[i]);
    if(P[i]>=i){
      ans = max(ans,i);
    }
    else if(P[i]==i){
      ans = max(ans,P[i]);
    }
    //cout << i <<":" << ans << endl;
  }
  //if(ans!=0) ans-=1;
  cout << ans << endl;
}



Measured memory_bytes: 3496
#include <bits/stdc++.h>  // ver1.8
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  string s;
  cin >> s;
  string t = "CODEFESTIVAL2016";
  int ans = 0;
  rep(i,0,s.size()){
    if(s[i]!=t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//ALDS1_6_B Sort II - Partition
#include <cstdio>
#include <utility>


int partition(int* A, int p, int r)
{
	int x = A[r];
	int i = p - 1;
	for (int j = p; j < r; j++)
	{
		if (A[j] <= x)
		{
			i++;
			std::swap(A[i],A[j]);
		}
	}
	std::swap(A[i+1],A[r]);
	return i+1;
}

int main(void)
{
	int n;
	int A[100000];
	scanf("%d",&n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d",&A[i]);
	}
	
	int q = partition(A,0,n-1);
	for (int i = 0; i < n; i++)
	{
		if(i) printf(" ");
		if(i==q) printf("[");
		printf("%d", A[i]);
		if(i==q) printf("]");
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 2984
N = int(input())
h = list(map(int,input().split()))
INF = 10*10

dp = [INF]*N
dp[0] = 0
dp[1] = abs(h[1] - h[0])

if N > 3:
    for i in range(2,N):
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]),dp[i-2] + abs(h[i] - h[i-2]))
print(dp[N-1])

Measured memory_bytes: 13928
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  int N,M,K; cin >> N >> M >> K;
  v<int> A(N+1,0),B(M+1,0);
  rep(i,N){
    int a;
    cin >> a;
    A[i+1]=a;
    A[i+1]+=A[i];
  }
  rep(i,M){
    int b;
    cin >> b;
    B[i+1]=b;
    B[i+1]+=B[i];
  }
  int index=M;
  int ans=0;
  rep(i,N+1){
    int num=K-A[i];
    if(num<0) break;
    for(int j=index;j>=0;j--){
      if(num>=B[j]){
        chmax(ans,i+j);
        index=j;
        break;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6264
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    vector<vector<ll>> c(3, vector<ll>(3));
    rep(i, 9) cin >> c[i/3][i%3];
    vector<ll> a(3), b(3);
    a[0] = 0;
    rep(i, 3) b[i] = c[0][i] - a[i];
    ll a21 = c[1][0] - b[0], a22 = c[1][1] - b[1], a23 = c[1][2] - b[2];
    if (!(a21 == a22 && a22 == a23)) {
        cout << "No" << endl;
        return 0;
    }
    ll a31 = c[2][0] - b[0], a32 = c[2][1] - b[1], a33 = c[2][2] - b[2];
    if (!(a31 == a32 && a32 == a33)) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main(){
int D;
  cin >> D;
  
  if(D == 22){
  cout <<"Christmas Eve Eve Eve"<< endl;
  }
  if(D == 23){
  cout <<"Christmas Eve Eve" << endl;
  }
  if(D == 24){
  cout <<"Christmas Eve" << endl;
  }
  if(D == 25){
  cout <<"Christmas"<< endl;
  }
}


Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Usize1;

fn main() {
  input! {
    n: usize,
    m: usize,
    peaks: [usize; n],
  }
  
  let mut goodlooking = vec![true; n];
  
  for _ in 0..m {
    input! {
      a: Usize1,
      b: Usize1,
    }
    if peaks[a] == peaks[b] {
      goodlooking[a] = false;
      goodlooking[b] = false;
    }
    else if peaks[a] > peaks[b] {
      goodlooking[b] = false;
    }
    else {
      goodlooking[a] = false;
    }
  }
  
  let ans = goodlooking.into_iter().filter(|&x| x).count();
  println!("{}", ans);

}

Measured memory_bytes: 5048
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main()
{
	int P, Q, R;

	cin >> P >> Q >> R;

	int kekka = min(P + Q, min(P + R, Q + R));

	cout << kekka << endl;

	return 0;
}

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

int main() {
	int N;
	string A, B, C;
	cin >> N >> A >> B >> C;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if ((A[i] == B[i] && A[i] != C[i]) ||
			(B[i] == C[i] && A[i] != B[i]) ||
			(C[i] == A[i] && A[i] != B[i])) ans++;
		if (A[i] != B[i] && B[i] != C[i] && C[i] != A[i]) ans += 2;
	}
	cout << ans << endl;
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int dig;
	cin >> dig;
	int n;
	cin >> n;
	vector<pair<int, int>> must(n);
	for(auto& p : must) {
		cin >> p.first >> p.second;
	}
	
	auto digits = [](int x) {
		if(x == 0) return 1;
		int ans = 0;
		while(x > 0) {
			ans++;
			x /= 10;
		}
		return ans;
	};
	
	auto digit = [](int x, int k) {
		if(x == 0) return 0;
		vector<int> dumb;
		
		while(x > 0) {
			dumb.push_back(x % 10);
			x /= 10;
		}
		
		reverse(dumb.begin(), dumb.end());
		return dumb[k-1];
	};
	
	for(int x = 0; x <= 1000; x++) {
		if(digits(x) != dig) {
			continue;
		}
		
		bool ok = true;
		
		for(auto p : must) {
			int s = p.first, c = p.second;
			if(digit(x, s) != c) {
				ok = false;
			}
		}
		
		if(ok) {
			cout << x << endl;
			return 0;
		}
	}
	
	cout << -1 << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long l = sc.nextLong();
    long r = sc.nextLong();
    r = Math.min(r,(l+2019));
    long mod = 2019L;
    long ans = (long)Math.pow(10,9)+7;
    for(long i = l; i < r; i++){
        for(long j = i+1; j <= r; j++){
            long tmp = ((i%mod)*(j%mod))%mod;
            ans = Math.min(ans,tmp);
        }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22996
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi 	3.14159265358979323846

int main(){
	ll H,W;
	while(1){
		cin >> H >> W;
		if(H==0&&W==0){break;}
		REP(i,H){
			REP(j,W){
				printf("#");
			}
			printf("\n");
		}
	printf("\n");
	}
  return 0;
}


Measured memory_bytes: 3068
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter printWriter = new PrintWriter(System.out);
        long x = scanner.nextLong();
        int count = 0;
        for (long i = 100; i < x;){
            i *= 1.01;
            count++;
        }
        printWriter.println(count);
        printWriter.flush();
    }
}


Measured memory_bytes: 35880
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

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

    int n;
    int a;
    cin >> n;
    int num;
    int ans = 10000;
    for(int i=0;i<n;i++){
    	cin >> a;
    	num = 0;
    	while(a % 2 == 0) {
    		a /= 2;
    		num++;
    	}
    	ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
    int a,b;
    scanf("%d %d",&a,&b);
    if(a < b){
        printf("a < b\n");
    }else if(a > b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 580
#include <stdio.h>

int main()
{
    int n,i,j;
    char abc[3][101];

    scanf("%d",&n);
    for (i = 0; i < 3; i++)
    {
        scanf("%s",abc[i]);
    }
    
    int buf = 0,ans = 0;
    
    for (i = 0; i < n; i++)
    {
        if(abc[0][i] != abc[1][i] && abc[1][i] != abc[2][i] && abc[2][i] != abc[0][i])
        {
            ans += 2;
        }
        else if(abc[0][i] == abc[1][i] && abc[1][i] == abc[2][i] && abc[2][i] == abc[0][i])
        {
            ans += 0;
        }
        else
        {
            ans += 1;
        }
        
    }
    

    printf("%d",ans);
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

int cmp( const void *p, const void *q ) {
    return -*(int*)p + *(int*)q;
}
//qsort(a,n,sizeof(int),cmp);
//char s[n][11]

int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);

int end(void){
return 0;
}


int main (void){
  long long int sum=1,a[210000],i,n,j=0,dig_n=0,sum_t,dig=0;
	
	scanf("%lld", &n);
	for(i=0; i<n;i++){
     sum_t=sum;
		scanf("%lld", &a[i]);
      sum=sum*a[i];

      if(a[i]==0){
      printf("0\n");
        return 0;
      }
      
      if(sum>1000000000000000000||sum<sum_t){
        j=1;
        
      }

    }
  if(j==1){
            printf("-1\n");
        return 0;
  
  }
        if(sum>1000000000000000000){
        printf("-1\n");
        return 0;
}

printf("%lld",sum);
return 0;
}
  



Measured memory_bytes: 2512
#include<cmath>
#include<cstdio>

using namespace std;

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

int main(){
	for(int p,n;scanf("%d%d",&p,&n),p;){
		double rp=sqrt(p);

		int xopt=100000,yopt=1,uopt=-1,vopt=1;
		for(int y=1;y<=n;y++){
			int x=(int)(y*rp+1);
			if(x<=n && gcd(x,y)==1 && x*yopt<y*xopt){
				xopt=x,yopt=y;
			}

			int u=(int)(y*rp),v=y;
			if(u<=n && gcd(u,v)==1 && v*uopt<u*vopt){
				uopt=u,vopt=v;
			}
		}

		printf("%d/%d %d/%d\n",xopt,yopt,uopt,vopt);
	}

	return 0;
}

Measured memory_bytes: 760
main :: IO ()
main = do
  [r,g,b,n] <- map read.words<$> getLine
  print $ length  [ (ir,ig) | ir <- [0..n`div`r], ig <- [0..n`div`g],ir*r + ig*g <= n , (n - ir*r - ig*g) `mod` b == 0]

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

using namespace std;

int main() {
	int n, l;
	while ( cin >> n, n ) {
		cin >> l;
		string str; cin >> str;

		int mode = 0;
		int chain = 0;
		int ans = 0;
		for (int i = 0; i < str.size(); ++i) {
			if (str[i] == 'I') {
				switch (mode) {
					case 0: mode = 1; break;
					case 1: chain = 0; break;
					case 2:
						if (++chain >= n) {
							++ans;
							--chain;
						}
						mode = 1;
						break;
				}
			}
			else {
				switch (mode) {
					case 0: break;
					case 1: mode = 2; break;
					case 2: mode = 0; chain = 0; break;
				}
			}
		}
		cout << ans << endl;
	}
}

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

using namespace std;

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

    long long sum = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 5 != 0 && i % 3 != 0) sum += i;
    }
  
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3688
N=int(input())
mylist=list(map(int,input().split()))
maximum=0
now_max=0



for i in range(N-1):
    
    if mylist[i]>=mylist[i+1]:
        now_max+=1
        maximum=max(now_max,maximum)
        #print(i)
        #print("now_max is")
        #print(now_max)
    else:
        maximum=max(now_max,maximum)
        now_max=0
print(maximum)
        

Measured memory_bytes: 14224
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int N,K,a[100];
bool dp[2][100001];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	cin >> N >> K;
	for(int i=0; i<N; i++) cin >> a[i];
	for(int nokori=0; nokori<=K; nokori++){
		for(int now=0; now<2; now++){
			bool canWin = false;
			for(int i=0; i<N; i++){
				if(nokori >= a[i]) canWin = (canWin | !dp[(now+1)%2][nokori-a[i]]);
			}
			dp[now][nokori] = canWin;
		}
	}
	cout << (dp[0][K]?"First":"Second") << endl;

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int main(){
	string a,b;
	cin>>a>>b;
	int la=a.size(),lb=b.size();
	int ans=1e9;
	for(int i=0;i+lb<=la;i++){
		int s=0;
		for(int j=0;j<lb;j++){
			if(a[i+j]==b[j]) s++;
		}
		ans=min(ans,lb-s);
	} 
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define ll long long 
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;	
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n) 
{
	for (int i = 0; i < n; ++i)
		cout << arr[i] << ' ';
	cout << endl;
}
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
ll modulo = 1e9 + 7;

ll fpow(ll a, ll n) 
{
	ll ans = 1;
	while (n) 
	{
		if (n&1) ans = (ans*a)%modulo;
		a = (a*a)%modulo; n = n >> 1;
	}
	return ans;
}

void solve() 
{
	int n,m,x;
	cin >> n >> m >> x;
	int arr[n][m];
	int c[n];
	For(i,0,n)
	{
		cin >> c[i];
		For(j,0,m)
		{
			cin >> arr[i][j];
		}
	}	
	int ans = INT_MAX;
	For(i,0,(1 << n))
	{
		int cost = 0;
		int skill[m] = {0};
		For(j,0,n)
		{
			if (i&(1 << j))
			{
				cost += c[j];
				For(k,0,m)
				{
					skill[k] += arr[j][k];
				}
			}
		}
		bool valid = 1;
		For(j,0,m)
		{
			if (skill[j] < x)
			{
				valid = 0;
				break;
			}
		}
		if (valid)
		{
			ans = min(ans, cost);
		}
	}
	if (ans == INT_MAX)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << ans << endl;
	}
}

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

Measured memory_bytes: 3612
import sys
from bisect import bisect
from itertools import accumulate

n, t = map(int, input().split())
constant = []
variable = []
for line in sys.stdin:
    a, b = map(int, line.split())
    if a == 0:
        constant.append(b + 1)
    else:
        variable.append((a / (b + 1), a, b))
constant.sort()
variable.sort(reverse=True)
INF = 10 ** 10
t += 1
t2 = t.bit_length() + 1
# dp[j]: (i番目まで見て) j件の店で買い物を完了した時の、次の店に到着できる最短時間
dp = [INF] * t2
dp[0] = 1
for _, a, b in variable:
    for j in range(t2 - 1, -1, -1):
        if dp[j] == INF:
            continue
        tmp = (a + 1) * dp[j] + b + 1
        if tmp > t:
            continue
        if dp[j + 1] > tmp:
            dp[j + 1] = tmp

const_acc = list(accumulate(constant))
ans = 0

for i, c in enumerate(dp):
    if c == INF:
        break
    remaining = t - c
    k = bisect(const_acc, remaining)
    ans = max(ans, i + k)

print(ans)


Measured memory_bytes: 75228
import sys
from collections import deque, defaultdict
import copy
import bisect
#input=sys.stdin.readline
#sys.setrecursionlimit(10 ** 9)
import math
import heapq

S = input()

RL = []
for i in range(len(S) - 1):
	if S[i] == 'R' and S[i + 1] == 'L':
		RL.append(i)
dist = [0]*len(S)
X = [0]*len(S)
for i in range(len(S)):
	if S[i] == 'R':
		loc = bisect.bisect_left(RL, i)
		dist[i] = RL[loc] - i
		X[i] = RL[loc]
	else:
		loc = bisect.bisect_left(RL, i)
		dist[i] = i - RL[loc - 1] - 1
		X[i] = RL[loc - 1] + 1

num = [0]*len(S)
for i in range(len(S)):
	if S[i] == 'R':
		num[X[i] + ((dist[i])%2)] += 1

	else:
		num[X[i] - ((dist[i])%2)] += 1


for i in range(len(S)):
	print(num[i], end='')
	print(" ", end ="")

Measured memory_bytes: 69084
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n;
string s;
int main() {
    cin >> n >> s;
    int cnt = 0;
    for(int i = 0; i < 1000; ++i) {
        string check;
        if(i < 10) {
            check = "00" + to_string(i);
        }else if(i < 100) {
            check = "0" + to_string(i);
        }else {
            check = to_string(i);
        }

        int now = 0;
        for(int j = 0; j < n; ++j) {
            if(now < 3 && check.at(now) == s.at(j)) now++;
        }
        if(now == 3) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
string S,T;
  cin>>S>>T;
ll ans=0;
ll ansl=0;
for(ll i=0;i<=(ll)(S.length()-T.length());i++){
  ansl=0;
 for(ll j=0;j<(ll)(T.length());j++){
   if(S[i+j]==T[j])ansl++;
 }
  ans=max(ans,ansl);
  //cout<<ans<<endl;
  
}
  cout<<T.length()-ans<<endl;
  
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

struct Day {
  int y, m, d;
  Day(int y = 0, int m = 0, int d = 0) : y(y), m(m), d(d) {}
};
istream& operator >> (istream& is, Day& day) {
  return is >> day.y >> day.m >> day.d;
}
ostream& operator << (ostream& os, Day& day) {
  return os << day.y << " " << day.m << " " << day.d;
}
bool operator < (const Day& lhs, const Day& rhs) { return lhs.y != rhs.y ? lhs.y < rhs.y : lhs.m != rhs.m ? lhs.m < rhs.m : lhs.d < rhs.d; }
bool operator == (const Day& lhs, const Day& rhs) { return lhs.y == rhs.y && lhs.m == rhs.m && lhs.d == rhs.d; }
bool operator != (const Day& lhs, const Day& rhs) { return !(lhs == rhs); }

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  const int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  auto is_leap = [&](int y) { return y % 400 == 0 || (y % 100 != 0 && y % 4 == 0); };
  Day s, t;
  while (cin >> s >> t, s.y != -1) {
    int ans = 0;
    while (s != t) {
      bool leap = is_leap(s.y);
      if (s.d + 1 > days[s.m] + (s.m == 2 && leap)) {
        if (s.m + 1 > 12) s.y++, s.m = 1, s.d = 1;
        else s.m++, s.d = 1;
      } else s.d++;
      ans++;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
int n;
vector<int> dat;
i64 sum = 0;
int smlst = inf;
int cnt = 0;

//inputします
void input() {
	cin >> n;
	dat.resize(n);
	ff(i, 0, n) {
		cin >> dat[i];
		sum += abs(dat[i]);
		if (smlst > abs(dat[i]))smlst = abs(dat[i]);
		if (dat[i] < 0)cnt++;
	}
}

//ライブラリ置き場



//main
int main() {
    input();
	if (cnt % 2 == 0)cout << sum << endl;
	else cout << sum - 2 * smlst << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <map>

using namespace std;
typedef pair<int, int> P;

struct UnionFind{
	int size;
	vector<int> parent;
	
	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		if(root_i == root_j) return;
		parent[root_i] = root_j;
	}
};

int n, m;
UnionFind uf(505);
P edge[3005];
map<int, P> mp;


int main(void)
{
	while(cin >> n){
		cin >> m;
		
		for(int i = 0; i < m; i++){
			int s, t;
			cin >> s >> t;
			edge[i] = make_pair(s, t);
		}
		
		uf.init();
		for(int i = 0; i < m; i++){
			uf.unite(edge[i].first, edge[i].second);
		}
		
		mp.clear();
		for(int i = 1; i <= n; i++){
			mp[uf.root(i)].first++;
		}
		for(int i = 0; i < m; i++){
			mp[uf.root(edge[i].first)].second++;
		}
		
		int ans = 0;
		for(auto it = mp.begin(); it != mp.end(); it++){
			ans += it->second.second - it->second.first + 1;
		}
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include<vector>
using namespace std;
int main(void){
  int N;
  cin >> N;
  vector<int> memo(N);
  vector<int> numbers(N);
  for (int i=N; i>=0; i--) {
      if(i==N){
          
          for (int j = 0; j < N; j++) {
              cin >> numbers.at(j);
              if(numbers.at(j)>j+1){
                  cout << -1 << endl;
                  return 0;
              }
          }
          continue;
      }
    for(int j=i;j>=0;j--){
      if(numbers.at(j)==j+1){
        memo.at(i)=j+1;
        numbers.erase(numbers.begin()+j);
        break;
      }
    
  }
  }
  for(int i=0;i<N;i++){
  cout << memo.at(i)<<endl;
  
  }
}

Measured memory_bytes: 256
def check(operator_list, num_list):
    res = num_list[0]
    for i, op in enumerate(operator_list):
        if op == '+':
            res += num_list[i + 1]
        elif op == '-':
            res -= num_list[i + 1]

    return res == 7

def concat(operator_list, num_list):
    res = str(num_list[0])
    for op, num in zip(operator_list, num_list[1:]):
        res += op
        res += str(num)

    return res + "=7"

def solve():
    line = input()
    num_list = []
    for s in line:
        num_list.append(int(s))

    stack = []
    stack.append([])
    N = len(num_list)
    while len(stack) > 0:
        operator_list = stack.pop()
        # print(operator_list)
        if len(operator_list) == N - 1:
            if check(operator_list, num_list):
                return concat(operator_list, num_list)

        else:
            stack.append(operator_list + [ '+' ])
            stack.append(operator_list + [ '-' ])

    return "No Answer"


print(solve())


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

using namespace std;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for(int i = 0;i < n;++i)
long long N,Y;
int A[1000000];
int main()
{
  cin>>N;
  for(Y=0;N!=0;Y++){
    N--;
    A[Y]=N%26;
    N/=26;
  }
  for(Y--;Y>=0;Y--)cout<<(char)(A[Y]+'a');
  return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<algorithm>

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define EACH(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

struct HeavyLight {
  vector<vector<int> > len,tree;
  int pathCount,n;
  vector<int>size,parent,in,out,path,pathSize,pathPos,pathRoot;

  HeavyLight(vector<vector<int> >tree)
    :tree(tree),n(tree.size()),size(n),parent(n),in(n),out(n),
     path(n),pathSize(n),pathPos(n),pathRoot(n){
    int time=0;
    dfs(0,-1,time);
    buildPaths(0,newPath(0));
    /*
    len=vector<vector<int> >(pathCount);

    REP(i,pathCount){
      int m=pathSize[i];
      len[i].resize(2*m);
      fill(ALL(len[i]),0);
      fill(len[i].begin()+m,len[i].begin()+2*m,1);
      for(int j=2*m-1;j>1;j-=2)len[i][j>>1]=len[i][j]+len[i][j^1];
    }
    */
  }

  void dfs(int u, int p, int &k){
    in[u]=k++, parent[u]=p, size[u]=1;
    EACH(v,tree[u])if(*v!=p)dfs(*v, u, k),size[u]+=size[*v];
    out[u]=k++;
  }

  int newPath(int u){ pathRoot[pathCount]=u; return pathCount++; }

  void buildPaths(int u, int pt){
    path[u]=pt, pathPos[u]=pathSize[pt]++;
    EACH(v,tree[u])if(*v != parent[u])
      buildPaths(*v, 2*size[*v] >= size[u] ? pt : newPath(*v));
  }

  bool isAncestor(int p, int ch){
    return in[p] <= in[ch] && out[ch] <= out[p];
  }

  int lca(int a,int b){
    for(int root; !isAncestor(root=pathRoot[path[a]],b);a=parent[root]);
    for(int root; !isAncestor(root=pathRoot[path[b]],a);b=parent[root]);
    return isAncestor(a,b)?a:b;
  }
};

//Usage: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_C
int main(void){
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<vector<int> >tree(n);
  
  REP(i,n){
    int k;
    cin >> k;
    REP(j,k){
      int ch;
      cin >> ch;
      tree[i].push_back(ch);
    }
  }

  HeavyLight hl = HeavyLight(tree);

  int q;
  cin >> q;
  while(q--){
    int u,v;
    cin >> u >> v;
    cout << hl.lca(u,v) << "\n";
  }
  
  return 0;
}

Measured memory_bytes: 24500
N = int(input())
XY_LIST = [[list(map(int, input().split())) for _ in range(int(input()))] for _ in range(N)]

def count_honest(i):
    l = [(i>>j)%2 for j in range(N)]
    for j in range(N):
        if (i>>j)%2 == 0:
            continue
        for x, y in XY_LIST[j]:
            x = x-1
            if l[x] == y:
                continue
            return 0
    return sum(l)

max_honest = 0
for i in range(1<<N):
    honest = count_honest(i)
    max_honest = max(max_honest, honest)

print(max_honest)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#define LL long long
#define inl inline
#define re register
#define MAXN 101000
using namespace std;
struct line
{
	LL a,b;
	line(LL _a=0,LL _b=0){a=_a,b=_b;}
	void push(LL _a,LL _b){a=_a,b=_b;}
	LL f(LL i){return a+(i-1)*b;}
	LL get(LL i){return max((i-a+b-1)/b,0ll)+1;}
}y[MAXN];
int n;
LL h[MAXN],t,sum[MAXN];
int main()
{
	scanf("%d%lld",&n,&t);
	for(int i=1;i<=n;i++)
		scanf("%lld",&h[i]),sum[i]=h[i]+sum[i-1];
	y[1].push(h[1],h[1]);
	for(int i=2;i<=n;i++)
	{
		if(y[i-1].f(1)+1<=sum[i]&&sum[i]<=y[i-1].f(2))
			 y[i].push(sum[i],y[i-1].f(2)-sum[i]+h[i]);
		else y[i].push(sum[i],h[i]);
	}
	for(int i=1;i<=n;i++)
		printf("%lld\n",y[i].get(t+1));
	return 0;
}
/*
3 0
5
7
3
*/



Measured memory_bytes: 6376
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m, i, j, k, a, b;
	cin >> n >> m;
	vector<vector<int>> adj(n + 1);
	for (i = 0; i < m; i++) {
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	vector<int> parent(n + 1, -1);
	queue<int> q;
	parent[1] = 0;
	q.push(1);

	while (!q.empty()) {
		int id = q.front();
		q.pop();

		for (auto p : adj[id]) {
			if (parent[p] == -1) {
				parent[p] = id;
				q.push(p);
			}
		}
	}

	cout << "Yes\n";
	for (i = 2; i <= n; i++) cout << parent[i] << "\n";


	return 0;
}




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

int main(void){
  int a; cin>>a;
  string s; cin >> s;
  if(a>=3200) cout << s << endl;
  else cout << "red" << endl;
  return 0;
}


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

typedef long long ll;
const ll MOD = 1e9+7;

ll a,b,c,d;

ll lcm(ll x,ll y){
    return x*y/__gcd(x,y);
}

ll f(ll n){
    return n/c+n/d-n/lcm(c,d);
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>a>>b>>c>>d;

    cout<<b-a+1-f(b)+f(a-1);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;

int main()
{
	int n, ans;
	double debt = 100000;

	cin >> n;

	for(int i = 0; i < n; i++)
	{
		debt = ceil((debt * 1.05) / 1000) * 1000;
	}

	ans = debt;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1164