akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

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

ll lcm(ll a, ll b) {
  return a/gcd(a,b)*b;
}

int main() {
  // 最小公倍数
  int N;cin>>N;
  vector<ll> TS(N);
  REP(i,N) cin>>TS[i];
  ll ans = TS[0];
  FOR(i,1,N) ans = lcm(ans,TS[i]);
  OUT(ans);

  return 0;
}

Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,z;
    char ca,cb,cc;
    cin>>n;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    rep(i,n){
        if(maxi<=v[i]) sum++;
        maxi=max(maxi,v[i]);
    }
    cout<<sum<<endl;


    

    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

bool dp[101010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin>>N>>K;
    vector<int> a(N);
    REP(i,N) cin>>a[i];

    for(int i=1;i<=K;i++){
        for(int j=0;j<N;j++){
            if(i-a[j]>=0) dp[i] |= !dp[i-a[j]];
        }
    }
    if(dp[K]) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ps push
#define pf push_front
#define mp make_pair
#define And &&
#define Or ||
#define inf INT_MAX
#define ppb pop_back
#define ppf pop_front
#define ignr cin.ignore()
#define Sort(name) sort(name.begin(),name.end())
#define For(name,start,finish) for(int name=start;name<finish;name++)
#define fast_in_out ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

//int row[]={-1,0,1,0};
//int col[]={0,1,0,-1};

const int N=1e3+10;
//vector<pair<int,int> > vec(N);
vector<int> vec;
ll Max(ll a,ll b){if(a>b)return a;return b;}


int main()
{
	fast_in_out;
	
	int n,m;
	cin>>n>>m;
	ignr;
	
	string str;
	cin>>str;
	
	str[m-1]=str[m-1]-'A'+'a';
	cout<<str<<endl;

	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif*/
	int n, a;
	cin >> n;
	vector<int> v[200001];
	for(int i=1; i<=(n-1); i++)
	{
		cin >> a;
		v[a].pb(i);
	}
	for(int i=1; i<=n; i++)
	{
		cout << v[i].size() << endl;
	}
	return 0;
}


Measured memory_bytes: 14592
#include"bits/stdc++.h"

using namespace std;

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

int main(){
    int i;
    //入力
    long n;
    cin>>n;
    //処理
    //出力
    cout<<n*(n-1)/2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

ll solve(vector<pll> v){
	sort(ALL(v));
	set<ll> s;
	REP(i, n) s.insert(v[i].second);
	ll ans = abs(v[0].first - v.back().first) * abs(*s.begin() - *s.rbegin());
	ll amin = v.back().first;
	ll amax = v.back().first;
	REP(i, n - 1){
		ll a, b; tie(a, b) = v[i];
		amin = min(amin, b);
		amax = max(amax, b);
		if(amin <= a) break;
		s.insert(a);
		ans = min(ans, abs(min(amin, v[i + 1].first) - max(amax, v.back().first)) * abs(*s.begin() - *s.rbegin()));
	}
	return ans;
}

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin >> n;
	vector<pll> v1, v2;
	REP(i, n){
		ll x, y;
		cin >> x >> y;
		if(x > y) swap(x, y);
		v1.eb(x, y);
		v2.eb(-y, -x);
	}
	
	cout << min(solve(v1), solve(v2)) << endl;
	return 0;
}


Measured memory_bytes: 25052
#include <iostream>
using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  ll t = 1;
  for (ll i = 0; i < n; ++i) {
    t *= (i + 1) % MOD;
    t %= MOD;
  }
  
  cout << t % MOD << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

deque<int> hist;
int n;

void dfs(const Graph &G, int v, int p, bool &arrived) {
  hist.push_back(v);
  
  for (auto nv : G[v]) {
    if (nv == p) continue;

    if (nv == n-1) {
      arrived = true;
      hist.push_back(nv);
      return;
    }

    dfs(G, nv, v, arrived);

    if (arrived) return;
  }

  hist.pop_back();
}

int main() {
  cin >> n;
  Graph edge(n);
  rep(i,n-1) {
    int a, b; cin >> a >> b; --a; --b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }

  bool arrived = false;

  dfs(edge, 0, -1, arrived);

  const int black = -1, gray = 0, white = 1;
  vi color(n, gray);
  bool fennec = true;
  queue<int> paint;

  while (!hist.empty()) {
    if (fennec) {
      paint.push(hist.front());
      color[hist.front()] = black;
      hist.pop_front();
    }
    else {
      color[hist.back()] = white;
      hist.pop_back();
    }
    fennec ^= true;
  }

  int sum = 0;
  while (!paint.empty()) {
    int v = paint.front(); paint.pop();
    ++sum;
    for (auto nv : edge[v]) {
      if (color[nv] == gray) {
        color[nv] = black;
        paint.push(nv);
      }
    }
  }

  if (sum > n-sum) cout << "Fennec\n";
  else cout << "Snuke\n";
  return 0;
}


Measured memory_bytes: 14336
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
using namespace std;

int main()
{
	string A, B, C;
	cin >> A >> B >> C;
	if (*(A.end() - 1) == *B.begin() && *(B.end() - 1) == *(C.begin()))
		printf("YES\n");
	else
		printf("NO\n");
	int wait; cin >> wait;
}


Measured memory_bytes: 256
void main() {
	auto N = ri;
	int[] A;
	int[] B;
	foreach(i; 0..N) {
		auto ip2 = readAs!(int[]), a = ip2[0], b = ip2[1];
		A ~= a;
		B ~= b;
	}
	ulong tmp;
	ulong cnt;
	foreach_reverse(i; 0..N) {
		auto mov = (B[i] - (A[i] + tmp) % B[i]) % B[i];
		debug "tmp: %d, cnt: %d, mov: %d".writefln(tmp, cnt, mov);
		tmp+=mov;
		cnt+=mov;
	}
	cnt.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 4348
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		long X = Long.parseLong(in.next());
		long Y = Long.parseLong(in.next());
		int ans = 0;
		while(X<=Y){
			ans++;
			X = X << 1;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
from itertools import groupby
n = int(input())
s = [input() for _ in range(n)]
print('AC x {}'.format(s.count('AC')))
print('WA x {}'.format(s.count('WA')))
print('TLE x {}'.format(s.count('TLE')))
print('RE x {}'.format(s.count('RE')))



Measured memory_bytes: 16152
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.StringTokenizer;

public class Main {
	
	public static long mod_pow(long a, long x, long p) {
		if(x == 0) {
			return 1;
		}else if(x == 1) {
			return a;
		}else if((x % 2) == 1) {
			return (mod_pow(a, x - 1, p) * a) % p;
		}else {
			final long ret = mod_pow(a, x / 2, p);
			return (ret * ret) % p;
		}
	}
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int X = sc.nextInt();
			final int A = sc.nextInt();
			
			System.out.println(X < A ? 0 : 10);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>

using namespace std;
// for loop
#define F(i, L, R) for(int i = L; i < R; i++)
#define FE(i, L, R) for(int i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(int i = L; i > R; i--)
#define FRE(i, L, R) for(int i = L; i >= R; i--)

// data types
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

int main() {
    int n;
    cin >> n;
    char str[4010];
    scanf("%s", str);
    vi r,g,b;
    F(i, 0, n){
        char c = str[i];
        if(c == 'R')r.pb(i);
        if(c == 'G')g.pb(i);
        if(c == 'B')b.pb(i);
    }
    ll ans  = 0;
    F(i, 0, r.size()){
        F(j, 0, g.size()){
            int diff = abs(r[i] - g[j]);
            int maxn = max(r[i], g[j]) + diff;
            int minn = min(r[i], g[j]) - diff;
            if(diff % 2 == 0){
                int midn = (r[i] + g[j])/2;
                if(str[midn] == 'B')ans++;
            }
            if(maxn < n){
                if(str[maxn] == 'B')ans++;
            }
            if(minn >= 0){
                if(str[minn] == 'B')ans++;
            }
        }
    }
    ll answer = (r.size()) * (g.size()) * (b.size()) - ans;
    cout << answer << endl;
}


Measured memory_bytes: 3704
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int A=1e9,B=1e18;
int S,x=1e9,xx=1,y,yy;

signed main(){
	read(S);
	yy=S/x;
	if(x*yy<S) yy++;
	y=x*yy-S;
	printf("0 0 %lld %lld %lld %lld\n",x,y,xx,yy);
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    string S,T;
    cin >> S >> T;
    ll ans,now;
    ans = INF;
    rep(i,S.size() - T.size() + 1){
        now = 0;
        rep(j,T.size()){
            if(T[j] != S[i+j]) now++;
        }
        chmin(ans,now);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()



int main() {
    ll n, m, dmax[2505], pena;
    vector<P3> es;
    cin >> n >> m >> pena;
    fill(dmax,dmax+n,-LLINF/3);
    REP(i,m){
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        es.push_back({c-pena,{a,b}});
    }
    dmax[0] = 0;
    REP(i,n){
        for(auto &e : es){
            ll from = e.second.first, to = e.second.second, cost = e.first;
            if(dmax[to] < dmax[from] + cost){
                dmax[to] = dmax[from] + cost;
            }
        }
    }
    ll memo = dmax[n-1];
    REP(i,n){
        for(auto &e : es){
            ll from = e.second.first, to = e.second.second, cost = e.first;
            if(dmax[to] < dmax[from] + cost){
                dmax[to] = dmax[from] + cost;
            }
        }
    }
    if(memo < dmax[n-1]){
        cout << -1 << endl;
    }
    else{
        cout << abs(max(dmax[n-1], 0LL)) << endl;
    }
    return 0;
}


Measured memory_bytes: 576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;


int H, W;
int N;
int a[10010];

int main(void) {
	cin >> H >> W;
	cin >> N;
	rep(i, N) cin >> a[i];

	vector<int> ans;
	rep(i, N) {
		rep(j, a[i])ans.push_back(i + 1);		
	}

	rep(i, H) {
		int l = W * i, r = l + W;
		if(i % 2) {
			for (int j = r - 1; j >= l; --j){
				cout << ans[j] << " ";
			}
		}else {
			for (int j = l; j < r; ++j){
				cout << ans[j] << " ";
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,l,r) for (int i=l,i##end=r;i<=i##end;++i)
#define per(i,r,l) for (int i=r,i##end=l;i>=i##end;--i)
using namespace std;
const int N=1003;
int a[N][N],b[N],f[N][N];
int main(){
    int n,m,k; cin>>n>>m>>k;
    rep(i,1,n){
        static char s[N]; scanf("%s",s);
        rep(j,1,m) b[i]|=(a[i][j]=s[j-1]=='#');
    }
    int c=1;
    rep(i,1,n){
        if (b[i]){
            int t=0;
            rep(j,1,m){
                if (a[i][j]){
                    if (t) ++c; t=1;
                }
                f[i][j]=c;
            }
            ++c;
        }
        else rep(j,1,m) f[i][j]=f[i-1][j];
    }
    rep(i,1,n)
        if (b[i]){
            per(j,i-1,1)
                rep(k,1,m) f[j][k]=f[j+1][k];
            break;
        }
    rep(i,1,n){
        rep(j,1,m) printf("%d ",f[i][j]);
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 6016
N, M = map(int, input().split())
S = input()
S = S[::-1]
now = 0
ans = []

while now<N:
    for i in range(M, 0, -1):
        if now+i>N:
            continue
    
        if S[now+i]=='0':
            ans.append(i)
            now += i
            break
    else:
        print(-1)
        exit()

print(*ans[::-1])

Measured memory_bytes: 50544
#include<stdio.h>

#define N 10000

//グローバル変数
int n;
int A[N];

//プロトタイプ宣言
int MatrixChainOrder(void);
int Min(int , int );

main() {

  int i, j;//counter

  scanf("%d", &n);

  for(i = 0; i < n ; i++) {
    scanf("%d %d", &A[2*i], &A[2*i+1]);//右と左にいれる
  }

  for(i = 1; i < 2*n; i++) {
    if(A[i] == A[i+1]) {
	
      for(j = i+1; j < 2*n; j++) {
	A[j] = A[j+1];
      }
    }
  }
  
    
  printf("%d\n", MatrixChainOrder());

  /*入れ忘れに注意すること！！！*/
  return 0;

}
  


/*
*   MatrixChainOrder関数...
*/
  int MatrixChainOrder() {

    int i, j, k, l, q;
    int Res[n+1][n+1];

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

    for(l = 2; l <= n; l++) {
      for(i = 1; i <= n-l+1; i++) {

	j = i + l - 1;
	Res[i][j] = 67148;//out9.txt参照

	for(k = i ; k <= j-1; k++) {

	  q = Res[i][k] + Res[k+1][j] + A[i-1] * A[k] * A[j];

	  Res[i][j] = Min(Res[i][j], q);
	}
      }
    }

    return Res[1][n];

  }


/*
*   Min関数...
*/
int Min(int x, int y) {

  if(x > y) {
    return y;
  }

  else {
    return x;
  }

}

Measured memory_bytes: 632
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

long long mod_pow(long long x, long long n, long long _mod){
  long long ret = 1;
  while(0 < n){
    if((n % 2) == 0){
      x = (x * x) % _mod;
      n >>= 1;
    } else {
      ret = (ret * x) % _mod;
      --n;
    }
  }
  return ret;
}

int main(){
  ll N, K, sum1 = 0, sum2 = 0;
  cin >> N >> K;
  for(int i = 1; i <= N; i++){
    sum1 += (i % K == 0);
    sum2 += (i % K == K / 2);
  }
  if(K % 2 == 0){
    cout << mod_pow(sum1, 3, LLONG_MAX) + mod_pow(sum2, 3, LLONG_MAX) << endl;
  } else {
    cout << mod_pow(sum1, 3, LLONG_MAX) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import queue

class Dinic:
    """Implementation of Dinic's Alogorithm"""

    def __init__(self, v, inf = 1000000007):
        self.V = v
        self.inf = inf
        self.G = [[] for _ in range(v)]
        self.level = [0 for _ in range(v)]
        self.iter = [0 for _ in range(v)]

    def add_edge(self, from_, to, cap):
        self.G[from_].append({'to':to, 'cap':cap, 'rev':len(self.G[to])})
        self.G[to].append({'to':from_, 'cap':0, 'rev':len(self.G[from_])-1})

    def bfs(self, s):
        self.level = [-1 for _ in range(self.V)]
        self.level[s] = 0;
        que = queue.Queue()
        que.put(s)
        while not que.empty():
            v = que.get()
            for i in range(len(self.G[v])):
                e = self.G[v][i]
                if e['cap'] > 0 and self.level[e['to']] < 0:
                    self.level[e['to']] = self.level[v] + 1
                    que.put(e['to'])

    def dfs(self, v, t, f):
        if v == t: return f
        for i in range(self.iter[v], len(self.G[v])):
            self.iter[v] = i
            e = self.G[v][i]
            if e['cap'] > 0 and self.level[v] < self.level[e['to']]:
                d = self.dfs(e['to'], t, min(f, e['cap']))
                if d > 0:
                    e['cap'] -= d
                    self.G[e['to']][e['rev']]['cap'] += d
                    return d

        return 0

    def max_flow(self, s, t):
        flow = 0
        while True:
            self.bfs(s)
            if self.level[t] < 0 : return flow
            self.iter = [0 for _ in range(self.V)]
            f = self.dfs(s, t, self.inf)
            while f > 0:
                flow += f
                f = self.dfs(s,t, self.inf)


N, = [int(x) for x in input().strip().split(" ")]
dinic = Dinic(2 * N + 2)

import sys
rs = []
bs = []
for i in range(N):
    rs.append([int(x) for x in input().strip().split(" ")])
for i in range(N):
    bs.append([int(x) for x in input().strip().split(" ")])

for i in range(N):
    rx, ry = rs[i]
    for j, b in enumerate(bs):
        bx, by = b
        if rx < bx and ry < by:
            dinic.add_edge(i, N+j, 1)
for i in range(N):
    dinic.add_edge(2*N, i, 1)
    dinic.add_edge(N+i, 2*N+1, 1)
print(dinic.max_flow(2*N, 2*N+1))


Measured memory_bytes: 5872
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string.h>
#include <vector>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <queue>
using namespace std;
typedef unsigned long long ui64;
typedef long long i64;
void StringRotation() {
	string S, T;
	cin >> S;
	cin >> T;
	int si = S.size();
	for (size_t i = 0; i < si; i++)
	{
		string s = "";
		for (size_t j = i; j < si; j++)
		{
			s += S[j];
		}
		for (size_t j = 0; j < i; j++)
		{
			s += S[j];
		}
		if (s == T) {
			cout << "Yes" << "\n";
			return;
		}
	}
	cout << "No" << "\n";

}
int main() {
	StringRotation();
	return 0;
}

Measured memory_bytes: 256
S = input()
K = "keyence"
for i in range(len(K)):
  if (K[:i] == S[:i]) and (K[(i-(len(K))):] == S[(i-(len(K))):]):
    print("YES")
    exit()
if K == S[:len(K)] or K == S[(-len(K)):]:
  print("YES")
  exit()
print("NO")


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

int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  rep(i, n) cout << s.at(i) << t.at(i);
  cout << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, k;
int ans = 0;
int main()
{
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		if (x >= k) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
h,w = map(int, input().split())
smap = []
for _ in range(h):
  smap.append(input().strip())

L = [[0 for _ in range(w)] for _ in range(h)]
R = [[0 for _ in range(w)] for _ in range(h)]
U = [[0 for _ in range(w)] for _ in range(h)]
D = [[0 for _ in range(w)] for _ in range(h)]

for y in range(h):
  for x in range(w):
    if smap[y][x] == '#':
      L[y][x] = 0
      D[y][x] = 0
    else:
      if 0 < x <= w-1:
        L[y][x] = L[y][x-1] + 1
      else:
        L[y][x] = 1
      if 0 < y <= h-1:
        D[y][x] = D[y-1][x] + 1
      else:
        D[y][x] = 1

for y in range(h-1, -1, -1):
  for x in range(w-1, -1, -1):
    if smap[y][x] == '#':
      R[y][x] = 0
      U[y][x] = 0
    else:
      if 0 <= x < w-1:
        R[y][x] = R[y][x+1] + 1
      else:
        R[y][x] = 1
      if 0 <= y < h-1:
        U[y][x] = U[y+1][x] + 1
      else:
        U[y][x] = 1

ans = 0
for y in range(h):
  for x in range(w):
    tmp = L[y][x] + R[y][x] + U[y][x] + D[y][x] - 3
    if ans < tmp:
      ans = tmp

print(ans)


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

int x[15][15];

int main(){
  int N;
  cin >>N;
  rep(i,N)rep(j,N) x[i][j] = -1;
  rep(i,N){
    int A;
    cin >>A;
    rep(j,A){
      int p,q;
      cin >>p>>q;
      p --;
      x[i][p] = q;
    }
  }
  int ans = 0;
  rep(i,1<<N){
    int sum = 0;
    vector<int> d(N);
    rep(j,N) if (i>>j&1) d[j] = 1;
    bool ok = 1;
    rep(j,N){
      if(d[j]){
        rep(k,N){
          if(x[j][k] == -1) continue;
          if(x[j][k] != d[k]) ok = false;
        }
      }
    }
    rep(j,N) sum += i>>j&1;
    if (ok) ans = max(ans,sum);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import collections

N = int(input())
num_list = [int(input()) for i in range(N)]

CTR_num = collections.Counter(num_list)
summ = 0

for i in CTR_num.keys():
    n = CTR_num[i]
    
    if (n % 2 != 0):
        summ += 1

print(summ)

Measured memory_bytes: 16636
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n)
	fmt.Scan(&k)

	ans := 1
	for i := 0; i < n; i++ {
		if ans >= k {
			ans += k
		} else {
			ans *= 2
		}
	}
	fmt.Println(ans)
}

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

int main()
{
	int N, n, sum, largest, smallest;
	
	while(cin >> N && N>0){
		sum  = 0; largest = 0; smallest = 1000;
		for(int i = 0; i<N; i++)
		{
			cin >> n;
			sum += n;
			
			if(smallest > n){ smallest = n;}
			if(largest < n){ largest = n;}
		}
	
		cout << (sum-smallest-largest)/(N-2) << endl;
	}
}


Measured memory_bytes: 3084
import sys
from bisect import bisect_left, bisect_right
inout = sys.stdin.readline

def main():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    B = sorted(list(map(int, input().split())))
    C = sorted(list(map(int, input().split())))
    
    ans = 0
    for Bi in B:
        Ai = bisect_left(A, Bi)
        Ci = N - bisect_right(C, Bi)
        ans += (Ai*Ci)

    print(ans)


if __name__ == '__main__': main()

Measured memory_bytes: 22720
import java.util.*;

public class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        int sum = 0;
        int mx = -1;
        for (int i : arr) {
            sum += i;
            mx = Math.max(mx, i);
        }
        System.out.println((sum - mx > mx) ? "Yes" : "No");
        sc.close();
    }
}

Measured memory_bytes: 35852
#include<stdio.h>
#include<stdlib.h>

#define MAX(A, B) (((A) > (B)) ? (A) : (B))

int main() {
  int N;
  scanf("%d", &N);
  
  char* c = malloc(N * sizeof(char));
  scanf("%s", c);
  
  int r=0;
  int b=0;
  for (int i=0; i<N; i++) {
    if (*(c + i) == 'R') {
      r++;
      if (r > N/2) {break;}
    }
    else if (*(c + i) == 'B') {
      b++;
    }
  }
  
  if (r > b) {
    printf("Yes\n");
  }
  else {
    printf("No\n");
  }
  
  return 0;
}

    

Measured memory_bytes: 128
n,p=gets.chomp.split(" ").map(&:to_i)
number = 2
if(n==1)
 puts p
else
  divisionNumber = 1
  loop do
     temp_number_n = number ** n
     divisionNumber = number if(p % temp_number_n == 0 )
     if((p % temp_number_n == 0 ||(p % temp_number_n  !=  0 && p > temp_number_n )))
        number += 1
     else
        break
     end
  end
  puts divisionNumber
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  string t="ATCG";
  cin>>s;
  int ans=0;
  int now=0;
  for(int i=0; i<s.size(); i++){
    bool isATCG =false;
    for(int j=0; j<t.size(); j++){
      if(s.at(i) == t.at(j) )isATCG= true;
    }

    if(!isATCG){
      now=0;
    }
    else{
      now++;
      ans=max(now,ans);
    }
  }
  cout<<ans<<endl;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = {"AC":0, "WA":0, "TLE":0, "RE":0}
for i in range(N):
    S[input()] += 1

print("AC x",S["AC"])
print("WA x",S["WA"])
print("TLE x",S["TLE"])
print("RE x",S["RE"])

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

int main() {
  string s;
  cin >> s;
  vector<int> v(4);
  for (int i = 0; i < 4; i++) v[i] = s[i] - '0';

  // 本編
  for (int i = 0; i < (1 << 3); i++) {
    int ans = v[0];
    for (int j = 0; j < 3; j++) {
      if (i & (1 << j)) {  // プラスなら
        ans += v[j + 1];
      } else {  // マイナスなら
        ans -= v[j + 1];
      }
    }

    // 合ってたら答えを出力して終了
    if (ans == 7) {
      cout << v[0];
      for (int j = 0; j < 3; j++)
        cout << ((i & (1 << j)) ? "+" : "-") << v[j + 1];
      cout << "=7" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
c = [list(map(int, input().split())) for i in [0,1,2]]
if (
(c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1]) and
(c[0][1] - c[0][1] == c[1][1] - c[1][1] == c[2][1] - c[2][1]) and
(c[0][2] - c[0][1] == c[1][2] - c[1][1] == c[2][2] - c[2][1])
   ) == True:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
using namespace std;

int main(){
  string left,right;
  int rev,N,t,f;
  char c;
  rev=0;
  left="";
  cin >> right;
  cin >> N;
  
  REP(int,i,0,N){
    cin >> t;
    if(t==1){
      swap(left,right);
      rev = !rev;
    }else{
      cin >> f >> c;
      if(f==1){
        left += c;
      }else{
        right += c;
      }
    }
  }

  reverse(left.begin(), left.end());
  cout << left << right;
}

Measured memory_bytes: 960
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main()
{
    int f=0,cont=0,i=0;
    char W[10],T[1000];
    scanf("%s",W);
    while(1){
        scanf("%s",T);
        i = 0;
        if(strcmp(T,"END_OF_TEXT")==0)
           break;
        while(T[i]!=' '){
            T[i] = tolower(T[i]);
            i++;
        }
        if(strcmp(T,W)==0)
            cont++;
    }
    printf("%d\n",cont);
    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define int long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1e15
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define pb push_back

using namespace std;
const int N = 100005;
int n, m;
vector<int>v[N];
int vis[N] = {};


int dx[] = { -1, 1, 0, 0};
int dy[] = {0, 0, 1, -1};
int func(int n, int a[])
{
	int l = 0;
	int sum = a[0];
	for (int i = 1; i < n; i++)
	{
		if (a[i] < sum)
		{
			int diff = abs(a[i] - sum);
			l += diff;
			sum = a[i] + diff;
		}
		else {
			sum = a[i];
		}
	}
	return l;
}


int32_t main()
{
	std::ios::sync_with_stdio(false);

// #ifndef ONLINE_JUDGE
// 	freopen("inputf.txt", "r", stdin);
// 	freopen("outputf.txt", "w", stdout);
// #endif

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

	int dp[n] = {};

	dp[0] = 0;
	dp[1] = abs(a[0] - a[1]);
	for (int i = 2; i < n; i++)
	{
		dp[i] += min(abs(a[i] - a[i - 1]) + dp[i - 1], abs(a[i] - a[i - 2]) + dp[i - 2]);
	}
	cout << dp[n - 1] << endl;
	return 0;

}

Measured memory_bytes: 7428
#include <iostream>
#include <vector>
#include <algorithm>
#define SIZE 30
using std::vector;
using namespace std;
 
 
int main() {
	std::cin.tie(0);std::ios::sync_with_stdio(false);
	int64_t a,b,c;
	int64_t n,k;
	cin >> n >> k;
	int64_t nums[100041] = {};
	for(int64_t i=0;i<n;++i){
		cin >> a >> b;

		nums[a]+=b;
	}
	int64_t s=0;
	
	for(int64_t i=0;i<=100000;++i){
		s+=nums[i];

		if(s>=k){
			cout << i;
			return 0;
		}
	}
return 0;

 
}

Measured memory_bytes: 1024
package main

import "fmt"

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)

	black_counter := make([]int, n)
	cnt := 0
	for i := range black_counter {
		if s[i] == '#' {
			cnt++
		}
		black_counter[i] = cnt
	}

	cnt = 0
	white_counter := make([]int, n)
	for j := range white_counter {
		i := len(s) - j - 1
		if s[i] == '.' {
			cnt++
		}
		white_counter[i] = cnt
	}

	ans := n
	for i := range black_counter {
		v := 0
		v += white_counter[i]
		if i >= 1 {
			v += black_counter[i-1]
		}
		if ans > v {
			ans = v
		}
	}
	if v := black_counter[len(s)-1]; ans > v {
		ans = v
	}
	fmt.Println(ans)
}


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

#define Debug(x) x
typedef int regular_int;
// #define int ll
typedef long long ll;
vector<int > G[300];
bool visited[300], visited2[300];
int cnt[300];
bool valid = true;
vector<int > active1;

void magic1(int x, int y) {
	cnt[x] = y;
	visited[x] = true;
	active1.push_back(x);

	//  cout << "x: " << x << ", y: " << y << endl;

	for(int z : G[x]) {
		if(visited[z] && cnt[x] == cnt[z]) {
			//              cout << x << " " << z << endl;

			valid = false;
			return;
		}
		if(!visited[z]) {
			magic1(z, 1 - y);

		}
	}

}

int  magic2(vector<int > active) {
	vector<int > active2;
	for(int z : active) {
		for(int y : G[z]) {
			if(!visited2[y]) {
				visited2[y] = true;
				active2.push_back(y);
			}
		}
	}
	if(active2.empty())return 1;
	return magic2(active2) + 1;



}

regular_int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(12) << fixed;

	int N;
	cin >> N;
	char x;

	for(int i = 0; i < N; ++i) {

		for(int j = 0; j < N; ++j) {
			cin >> x;
			if(x == '1') {
				G[i].push_back(j);

			}
		}
	}
	int res = 0;

	for(int i = 0; valid && i < N; ++i) {
		if(!visited[i]) {
			active1.clear();

			magic1(i, 0);
			if(!valid) {
				break;
			}
			int res2 = 0;

			for(int z : active1) {
				for(int y : active1) {
					visited2[y] = false;
				}
				visited2[z] = true;
				res2 = max(res2, magic2(vector<int> (1, z)));

			}
			res += res2;
		}
	}
	if(valid)
		cout << res << endl;
	else {
		cout <<  - 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009

int main(void){
	char a[100000];
	f(i, 100000)a[i] = 0;
	int k, s;
	int n, m;
	bool v = true;
	int x, y, z;
	int ans = 0;


	scanf("%d", &x);

	printf("%d\n", 48 - x);


	return 0;
}



Measured memory_bytes: 128
package main

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

func main() {
	var N, D int
	fmt.Scan(&N, &D)

	X := make([][]int, N)
	for i := 0; i < N; i++ {
		X[i] = make([]int, D)
	}

	stdin := bufio.NewScanner(os.Stdin)
	for i := 0; i < N; i++ {
		stdin.Scan()
		text := stdin.Text()
		strs := strings.Split(text, " ")
		for j, s := range strs {
			X[i][j], _ = strconv.Atoi(s)
		}
	}

	ret := 0
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			if isSquare(d2(X[i], X[j])) {
				ret++
			}
		}
	}
	fmt.Println(ret)
}

func d2(x1, x2 []int) int {
	ret := 0
	for i := 0; i < len(x1); i++ {
		ret += (x1[i] - x2[i]) * (x1[i] - x2[i])
	}
	return ret
}

func isSquare(x int) bool {
	if x < 0 {
		return false
	}

	for i := 1; i*i <= x; i++ {
		if x == i*i {
			return true
		}
	}
	return false
}


Measured memory_bytes: 640
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var N string
	fmt.Scan(&N)
	sum := 0
	for _, v := range N {
		w, _ := strconv.Atoi(string(v))
		sum += w
	}
	n, _ := strconv.Atoi(N)
	if n%sum == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 512
#include<stdio.h>

int com(int *a,int *b)
{
  int tmp;
  if(b>a){
    tmp=*a;
    *a=*b;
    *b=tmp;
  }
}
int sk(int a, int b)
{
  int i;
  com(&a,&b);
  i=a%b;
  while(i!=0){
    a=b;
    b=i;
    i=a%b;
  }
  return b;
}
int gcd(int a,int b,int c)
{
  int d;
  com(&a,&b);
  d=sk(a,b);
  com(&d,&c);
  return sk(d,c);
}
int main()
{
  int k,a,b,c,sam=0;
  scanf("%d",&k);
  for(a=1;a<=k;a++){
    for(b=1;b<=k;b++){
      for(c=1;c<=k;c++){
        sam+=gcd(a,b,c);
      }
    }
  }
  printf("%d",sam);
        
  return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int 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;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
    int h,w;
    string map[1000];
    int mas[200][205]={};
    cin >> h >> w;
    FOR(i,h) cin >> map[i];
    FOR(i,h){
        FOR(j,w){
            if(map[i][j]=='#')
                cout <<'#';
            else{
                FOR(k,8){
                    int y = i+dy[k];
                    int x = j+dx[k];
                    if(inside(x,y,w,h) && map[y][x]=='#')
                        mas[i][j]++;
                }
                cout << mas[i][j];
            }
        }
        cout fin;
            
    }
    

  
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 640
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
# pragma GCC optimize "-O3"
# define int long long
  
using namespace std;
  
const int N = 1e4 + 7;
const int mod = 1e9 + 7;

void solve() {
	int n, k;
	cin >> n >> k;
	vector < int > cnt(n + 1);
	for ( int i = 0; i < k; i++ ) {
		int x;
		cin >> x;
		for ( int j = 0; j < x; j++ ) {
			int y;
			cin >> y;
			cnt[y]++;
		}
	}
	int ans = 0;
	for ( int i = 1; i <= n; i++ ) {
		if ( cnt[i] == 0 ) {
			ans++;
		}
	}
	cout << ans;
}

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

Measured memory_bytes: 3660