akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	static int[] MASK = { 1, 2, 4 };

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String str = in.readLine();
		int[] vals = new int[4];
		for (int i = 0; i < str.length(); ++i) {
			vals[i] = Integer.parseInt(str.substring(i, i + 1));
		}
		boolean[] pattern = search(vals);
		System.out.println(toStr(vals, pattern));
	}

	static String toStr(int[] vals, boolean[] pattern) {
		StringBuilder strBuilder = new StringBuilder();
		strBuilder.append(vals[0]);
		for (int i = 1; i < 4; ++i) {
			if (pattern[i]) {
				strBuilder.append("+" + vals[i]);
			} else {
				strBuilder.append("-" + vals[i]);
			}
		}
		strBuilder.append("=7");
		return strBuilder.toString();
	}

	static boolean[] search(int[] vals) {
		for (int i = 0; i < 8; ++i) {
			boolean[] pattern = conv(i);
			int v = calc(vals, pattern);
			if (v == 7) {
				return pattern;
			}
		}
		return null;
	}

	static int calc(int[] vals, boolean[] pattern) {
		int result = 0;
		for (int i = 0; i < vals.length; ++i) {
			if (pattern[i]) {
				result += vals[i];
			} else {
				result -= vals[i];
			}
		}
		return result;
	}

	static boolean[] conv(int v) {
		boolean[] result = new boolean[4];
		result[0] = true;
		for (int i = 0; i < MASK.length; ++i) {
			if ((MASK[i] & v) > 0) {
				result[i + 1] = true;
			} else {
				result[i + 1] = false;
			}
		}
		return result;
	}
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    

    int k;
    cin>>k;

    int ans = 0;
    for(int i = 1;i<=k;i++){
        for(int j = 1;j<=k;j++){
            for(int p = 1;p<=k;p++)
                ans += __gcd(i,__gcd(j,p));
        }
    }
    cout<<ans;
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

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

int a[200005] , b[200005];

int main()
{

    int n;

    cin >> n;

    for(int i = 1 ; i<=n ; i++)
    {

        cin>> a[i];
    }

    int  l = 1;
    int r = n;
    int ll = n;
    int rr = n-1;

    while(l<=r)
    {
        b[r] = a[rr];
        b[l] = a[ll];
        l++;
        r--;
        ll-=2;
        rr-=2;
    }
    for(int i = 1 ; i<=n ; i++)
    {
        cout << b[i] << " ";
    }
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6,black=1,white=2;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a[ohara],b[ohara],c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool bvisited[ohara],wvisited[ohara],fl;
struct edge{int to,cost;};
unordered_map<ll,ll> bmp;
unordered_map<ll,ll> wmp;
vector<ll> graph[ohara];

//-------------------------↓↓↓↓↓↓------------------------

void dfs1(ll now,ll depth){
    if(bvisited[now])return;
    bvisited[now]=true;
    bmp[now]=depth;
    rep(i,Size(graph[now])){
        dfs1(graph[now][i],depth+1);
    }
}

void dfs2(ll now,ll depth){
    if(wvisited[now])return;
    wvisited[now]=true;
    wmp[now]=depth;
    rep(i,Size(graph[now])){
        dfs2(graph[now][i],depth+1);
    }
}

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

    cin>>n;
    rep(i,n-1)cin>>a[i]>>b[i],a[i]--,b[i]--;
    rep(i,n-1){
        graph[a[i]].push_back(b[i]);
        graph[b[i]].push_back(a[i]);
    }
    dfs1(0LL,0LL);
    dfs2(n-1,0LL);
    ll wp=0,bp=0;
    rep(i,n){
        if(bmp[i]<=wmp[i])bp++;
        else wp++;
    }
    if(wp>=bp)Cout("Snuke");
    else Cout("Fennec");
    return 0;
}


Measured memory_bytes: 44964
#include <stdio.h>

int main(){
    int angka1;
    int angka2;

    scanf("%d",&angka1);
    scanf("%d",&angka2);

    int hasil=angka1+angka2;

    if(hasil>=24){
        hasil=hasil-24;
        }
        printf("%d",hasil);







    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

using ll = long long int;

ll arr[200010] = {};

ll k = 0, res = 0;

bool check() {
	for (int i = 0; i < k; i++) {
		if (arr[i] >= k) return true;
	}
	return false;
}

int main(void) {

	cin >> k;

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

	//k*k = 50*50 * 100000;
	for(ll l = 0; l <= k; l++)
	for (ll i = 0; i < k ; i++) {

		ll t = (arr[i]*k / (k+1))/k;
		res += t;
		arr[i] -= t*(k+1);

		if (t != 0) {

			for (ll j = 0; j < k; j++)
				arr[j] += (t);

			if (t > k) {
				res += (t - k)*k;

				for (ll j = 0; j < k; j++)
					arr[j] -= (t-k);
			}

		}

		/*
		for (int l = 0; l < k; l++) {
			cout << arr[l] << (l == k - 1 ? '\n' : ' ');
		}
		cout << res << endl;
		*/

	}

	while (check()) {
		res++;
		int tmp = 0;
		for (int i = 0; i < k; i++) {
			if (arr[tmp] < arr[i]) tmp = i;
		}
		for (int i = 0; i < k; i++) {
			arr[i]++;
		}
		arr[tmp] -= k+1;

	}
	/*
	for (int i = 0; i < k; i++) {
		cout << arr[i] << (i == k-1 ? '\n' : ' ');
	}*/
	
	cout << res << endl;


}


//
//int main(void) {
//
//	ll k = 0;
//
//	cin >> k;
//
//	for (int i = 0; i < 50; i++) {
//		arr[i] += 49;
//		arr[i] += k / 50;
//	}
//
//	for (ll i = 0; i < k%50; i++) {
//		arr[i%50] += 51;
//
//		for (ll j = 0; j < 50; j++) {
//			arr[j] -= 1;
//		}
//	}
//
//	cout << 50 << endl;
//
//	for (int i = 0; i < 50; i++) {
//		cout << arr[i] << (i == 49?'\n' : ' ');
//	}
//
//
//}


Measured memory_bytes: 256
if __name__ == '__main__':
    N, M, K = list(map(int, input().split()))

    ans = "No"
    for kn in range(0, N + 1):
        for km in range(0, M + 1):
            # print(M * kn + N * km - (km * kn))
            if M * kn + N * km - 2 * (km * kn) == K:
                ans = "Yes"

    print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

vector<int> primes;
void init(int n) {
  primes.push_back(2);
  bool is_prime[n + 1];
  fill(is_prime, is_prime + n + 1, true);
  for (long long p = 3; p <= n; p += 2)
    if (is_prime[p]) {
      primes.push_back(p);
      for (long long i = p * p; i <= n; i += p) is_prime[i] = false;
    }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  init(1e6);
  int X;
  cin >> X;
  cout << *lower_bound(primes.begin(), primes.end(), X) << '\n';
  return 0;
}


Measured memory_bytes: 4744
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int h,w,n;  

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> h >> w >> n;
  int cur = 0, ans = 0;
  int mx = max(h,w);
  while(cur<n){
    cur+=mx;
    ans++;
  }
  cout << ans << endl;


return 0;
}
///....


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

bool match(char x, char y){
  if(x == y)return true;
  if(x == '?' || y == '?')return true;
  return false;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a,b,c;
  cin >> a >> b >> c;
  int32 an = a.size();
  int32 bn = b.size();
  int32 cn = c.size();
  vector<bool> ab(20000,true);  //ab[i-j+10000] = aの左端がi,bの左端がjのとき重ねられるか
  vector<bool> bc(20000,true);
  vector<bool> ac(20000,true);
  REP(i,an)REP(j,bn){
    if(!match(a[i],b[j])) ab[j-i+10000] = false;
  }
  REP(i,bn)REP(j,cn){
    if(!match(b[i],c[j])) bc[j-i+10000] = false;
  }
  REP(i,an)REP(j,cn){
    if(!match(a[i],c[j])) ac[j-i+10000] = false;
  }
  int32 ans = 6000;
  FOR(bi,-5000,5000)FOR(ci,-5000,5000){
    if(ab[-bi+10000] && bc[bi-ci+10000] && ac[-ci+10000]){
      int32 l = min<int64>({0,bi,ci});
      int32 r = max<int64>({an, bi + bn, ci + cn});
      ans = min(ans, r - l);
    }
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
   string a,b,c;
   cin >> a >> b >> c;
   cout<<(char)(a[0]-(char)32)<<(char)(b[0]-32)<<(char)(c[0]-32)<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep1n(i, n) for(int i=1;i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int main() {

	int n;
	cin >> n;
	string s;
	cin >> s;
	int x = 0;
	int ma = 0;
	rep(i, n) {
		x = (s[i] == 'I' ? x + 1 : x - 1);
		ma = max(ma, x);
	}
	cout << ma;

	return 0;
}

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

int main() {
  int d, g;
  cin >> d >> g;
  vector<int> p(d), c(d);
  rep(i, d) cin >> p[i] >> c[i];

  int res = 1e9;
  rep(bit, (1<<d)) {
    int sum = 0;
    int num = 0;
    int pmax = 0;
    rep(i, d) {
      if (bit & (1<<i)) {
        sum += p[i] * 100 * (i + 1) + c[i];
        num += p[i];
      } 
      else pmax = i;
    }
    if (sum < g) {
      int add = 100 * (pmax + 1);
      int addnum = (g - sum + add - 1) / add;
      if (addnum >= p[pmax]) continue;
      num += addnum;
    }
    res = min(res, num);
  }
  cout << res << endl;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  
  const int NMMAX=50;
  int A[NMMAX], B[NMMAX];
  for(int i=0; i<M; ++i)cin >> A[i] >> B[i];
  
  int road[NMMAX];
  for(int i=0; i<N; ++i) road[i]=0;
  
  for(int i=0; i<M; ++i){
    road[A[i] -1] += 1;
    road[B[i] -1] += 1;
  }
  for(int i=0; i<N; i++) cout << road[i] << endl;
}

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

using namespace std; 

int main(){

	int n,q,l,r;
	
	string s;
	
	vector<int> container(100007);
	
	cin >> n >> q;
	
	cin >> s;
	
	for(int i=1;i<n;i++){
		container[i]=s[i]=='C'&&s[i-1]=='A'?container[i-1]+1:container[i-1];
	}
		 
	
	for(int i=0;i<q;i++){
		
		 cin >> l >> r;
		 
		 l--;
		 r--;
		 
		 cout << container[r] - container[l] << endl;
		 
		 
	 } 
	
	
	
    return 0;
}


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

int main() {
    ll N;
    cin >> N;
    vector<ll> h(N+1,0);
    REP(i,N){
        cin >> h[i];}
    vector<ll> dp(N+1,0);
    dp[1] = abs(h[1]-h[0]);
    for (int i = 2; i < N; i++) {
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[N-1] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int x, a; cin >> x >> a;
    cout << (x < a ? 0 : 10) << endl;
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int MAX = 1e9;

int n, k;

int main() {

	FAST;

	cin >> n >> k;
	vector <int> a(n + 1);
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	// changed max_element to MAX
	int ans = MAX;
	int l = 1, r = MAX;
	while (l <= r) {
		int midd = (l + r) / 2;
		int cnts = 0;
		for (int i = 1; i <= n; i ++) {
			cnts += (a[i] + midd - 1) / midd - 1;
		}
		if (cnts <= k) {
			ans = midd;
			r = midd - 1;
		}
		else {
			l = midd + 1;
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3904
#include <stdio.h>
#include <algorithm>
using namespace std;

#define INF 1e8

int a[222][222], r[11], R, ans = INF;

void update(void)
{
    int i, sum = 0;

    for (i = 1; i < R; i++)
		sum += a[r[i]][r[i + 1]];

    ans = min(ans, sum);
}

int main(void)
{
	// freopen("input.txt", "r", stdin);

    int N, M, i, j, k;

    scanf("%d %d %d" ,&N, &M, &R);
	for (i = 1; i <= R; i++)
		scanf("%d" ,&r[i]);

    for (i = 1; i <= N; i++)
		for (j = 1; j <= N; j++)
            if (i != j)
				a[i][j] = INF;

    while (M--)
	{
		int x, y, z;

		scanf("%d %d %d" ,&x, &y, &z);

        a[x][y] = a[y][x] = min(a[x][y], z);
	}

    for (k = 1; k <= N; k++)
		for (i = 1; i <= N; i++)
			for (j = 1; j <= N; j++)
                a[i][j] = min(a[i][j], a[i][k] + a[k][j]);

	sort(r + 1, r + R + 1);
	do {
		update();
	} while (next_permutation(r + 1, r + R + 1));

	printf("%d" ,ans);
	return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

int main() {
  int n;
  while (cin >> n, n) {
    string s[100];
    pair<int, string> par[100];
    for (int i = 0; i < n; i++) {
      cin >> s[i];
    }
    for (int i = 0; i < n; i++) {
      int cnt = 0;
      for (int j = 0; j < s[i].size(); j++) {
        if (s[i][j] == '.')
          cnt++;
        else
          par[i] = make_pair(cnt, s[i][j]);
      }
    }

    stack<pair<int, string>> st;

    for (int i = n - 1; 0 <= i; i--) {
      if (par[i].second != "+" && par[i].second != "*") {
        st.push(par[i]);  //数字ならスタックに積む
        continue;
      }

      if (par[i].second == "+") {
        int ret = 0;
        while (!st.empty()) {
          if (par[i].first + 1 != st.top().first) break;
          ret += toInt(st.top().second);
          st.pop();
        }
        st.push(make_pair(par[i].first, to_string(ret)));
      } else {
        int ret = 1;
        while (!st.empty()) {
          if (par[i].first + 1 != st.top().first) break;
          ret *= toInt(st.top().second);
          st.pop();
        }
        st.push(make_pair(par[i].first, to_string(ret)));
      }
    }

    int ans = toInt(st.top().second);
    cout << ans << "\n";
  }

  return 0;
}


Measured memory_bytes: 3256
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef complex<double> P;

int n;

int main(){
	while(cin>>n){
		if(n==-1)return 0;
		P p(1.0,0);
		for(int i=0;i<n-1;i++){
			p+=p*P(0,1)/abs(p);
		}
		cout<<p.real()<<" "<<p.imag()<<endl;
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
 
const ll C_MAX = (ll)1e18;
 
int main()
{
	ll A, ret, ib;
	long double B;
 
	cin >> A >> B;
	ib = B * 100 + 0.5;
	A *= ib;
	A /= 100;
 
	cout << A << endl;
	return 0;
}

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
reps(i,1000,1){
    if(n<=1000*i){
        cout<<1000*i-n<<endl;
        break;
    }
}
return 0;
}

Measured memory_bytes: 3644
package main

import (
	"fmt"
)

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

	var can bool
	for i := 0; i <= n; i++ {
		for j := 0; j <= m; j++ {
			if i*(m-j)+(n-i)*j == k {
				can = true
			}
		}
	}

	if can {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 512
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (lli)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

lli po(lli a,lli n)
{
    dbg(a,n);
    a%=mod;
    if(n==0)
        return 1;
    if(n&1)
        return (a*po(a,n-1))%mod;
    return po(a*a%mod,n/2);
}

lli nCr(lli n,lli r)
{
    lli num=1,den=1,i;

    repA(i,1,r)
    {
        den=den*i%mod;
        num=num*(n-i+1)%mod;
    }

    den=po(den,mod-2);
    return num*den%mod;
}

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;
    lli ans=0;
    ans=po(2,n)-1;

    cin>>m;
    ans-=nCr(n,m);
    cin>>m;
    ans-=nCr(n,m);

    ans%=mod;
    ans+=mod;
    ans%=mod;
    cout<<ans<<endl;

}   aryanc403();
    return 0;
}


Measured memory_bytes: 256
n = int(input())
h_list = [int(h) for h in input().split()]
ans = True

for i in range(n-1, 0, -1):
    if h_list[i] >= h_list[i-1]:
        continue

    else:
        h_list[i - 1] -= 1

        if h_list[i] >= h_list[i-1]:
            continue
        else:
            ans = False
            break

if ans is True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14228
n,m = gets.split.map(&:to_i)
num = Array.new(2019,0)
if m-n >= 2018
  puts 0
  exit
end
count = n % 2019
num[count] = 1
while count != m % 2019
  count += 1
  count %= 2019
  num[count] = 1
end
ans = 10**10
for i in 0..2018
  if num[i] == 1
    for j in 0..2018
      if num[j] == 1 && i != j
        if ans > (i*j)%2019
          ans = (i*j)%2019
        end
      end
    end
  end
end
puts ans


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

// --- バケット法を用いた解法 ---
// int main()
// {
//   int n;
//   int d[110];
//   cin >> n;
//   for (int i = 0; i < n; ++i)
//     cin >> d[i];

//   int num[110] = {0}; // バケット法
//   for (int i = 0; i < n; ++i)
//   {
//     num[d[i]]++;
//   }

//   int res = 0;
//   for (int i = 1; i <= 100; ++i)
//   {
//     if (num[i])
//     {
//       ++res;
//     }
//   }
//   cout << res << endl;
// }

// --- std::set を用いた解法 ---
int main()
{
  int n;
  int d[110];
  cin >> n;
  for (int i = 0; i < n; ++i)
    cin >> d[i];

  set<int> values; // insert時に重複を取り除く
  for (int i = 0; i < n; ++i)
  {
    values.insert(d[i]); // 挿入
  }

  // set のサイズを出力する
  cout << values.size() << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt(),b = scn.nextInt(),c = scn.nextInt(),n = 0;
		for(int i = a;i <=b;i++ ) {
			if(c % i == 0)n++;
		}
		System.out.println(n);
	}
}



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

using namespace std;

int main() {
    int N, T;
    cin >> N >> T;

    const int cost_max = 1000;
    int min_cost = cost_max + 1;
    for (int i = 0; i < N; ++i) {
        int c, t;
        cin >> c >> t;
        if (t <= T && min_cost > c)
            min_cost = c;
    }

    if (min_cost <= cost_max)
        cout << min_cost << '\n';
    else
        cout << "TLE\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  string S;
  cin >> S;
  string yy;
  yy += S[0];
  yy += S[1];
  string mm;
  mm += S[2];
  mm += S[3];
  if (mm <= "12" && mm > "00") {
    if (yy <= "12" && yy > "00") {
      cout << "AMBIGUOUS" << endl;
    } else {
      cout << "YYMM";
    }
  } else {
    if (yy <= "12" && yy > "00") {
      cout << "MMYY";
    } else {
      cout << "NA" << endl;
    }
  }
  return 0;
}  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

LL N, K;
vector<vector<int> > road;

LL func(int place, int num, int lu){
    LL res = K-num;
    REP(i, road[place].size()){
        if(road[place][i]==lu){
            swap(road[place][i], road[place].front());
            break;
        }
    }
    REP(i, road[place].size()){
        if(lu == road[place][i])continue;
        res = res * func(road[place][i], i+1, place) % MOD;
    }
    return res;
}

int main(){
    cin >> N >> K;
    road.assign(N+1, vector<int>());
    REP(i, N-1){
        int a, b;
        cin >> a >> b;
        road[a].push_back(b);
        road[b].push_back(a);
    }
    cout << func(1, 0, -1) << endl;
    return 0;
}



Measured memory_bytes: 10368
def f():
    S = input()
    K = int(input())
    S = list(S)
    if K == 1 and len(S) == 1:
        print(0)
        return
    
    if K == 1 and len(S) != 1:
        ans = 0
        for i in range(len(S)-1):
            if S[i] == S[i+1]:
                S[i+1] = '1'
                ans += 1
        print(ans)
        return
    
    if K != 1 and len(S) == 1:
        ans = K // 2
        print(ans)
        return
    
    if K != 1 and len(S) != 1:
        ORG_S = S[:]
        a = S[0]
        for s in S[1:]:
            if a[0] == s:
                a += s
            else:
                break
        b = S[-1]
        for s in reversed(S[:-1]):
            if b[0] == s:
                b += s
            else:
                break
        a = list(a)
        b = list(b)
        if len(a) == len(S):
            ans = len(S)*K//2
        else:
            c = list(a + b)
            S = S[len(a):-1*len(b)]
        
            ans_a = 0
            for i in range(len(S)-1):
                if S[i] == S[i+1]:
                    S[i+1] = str(i)
                    ans_a += 1
            ans_b = 0
            for i in range(len(c)-1):
                if c[i] == c[i+1]:
                    c[i+1] = str(i)
                    ans_b += 1
            ans_c = 0
            if len(a) > 1:
                for i in range(len(a)-1):
                    if a[i] == a[i+1]:
                        a[i+1] = str(i)
                        ans_c += 1
            ans_d = 0
            if len(b) > 1:
                for i in range(len(b)-1):
                    if b[i] == b[i+1]:
                        b[i+1] = str(i)
                        ans_d += 1 
            ans = ans_a*K + ans_b*(K-1)+ans_c+ans_d
        print(ans)
        return

f()

    

Measured memory_bytes: 38256
#include "stdio.h"

void main(void){
  long H,W;
  scanf("%ld %ld",&H,&W);
  if(H==1||W==1){
    printf("1\n");
  }
  else if(H*W%2){
    printf("%ld\n",H*W/2+1);
  }
  else
    printf("%ld\n",H*W/2);
}


Measured memory_bytes: 1668
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	str s, t;
	cin >> s >> t;
	int ans = INT_MAX;
	for (int i = 0; i < s.size() - t.size() + 1; i++)
	{
		int diff = 0;
		for (int j = 0; j < t.size(); j++)
		{
			if (t[j] != s[j + i])
			{
				diff++;
			}
		}
		ans = min(ans, diff);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

const int N = 1e5 + 10;

int n, k;
int a[N];

int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  int g = a[0];
  for (int i = 1; i < n; ++i) {
    g = __gcd(g, a[i]);
  }
  int mx = *max_element(a, a + n);
  bool ok = 0;
  if (k <= mx && k >= g) {
    if ((mx - k) % g == 0) ok = 1;
  }
  puts(ok ? "POSSIBLE" : "IMPOSSIBLE");
  return 0;
}


Measured memory_bytes: 640
N = int(input())

C = list(input())

res = 0
j = N - 1
for i in range(N):
    if C[i] == "W":
        while i < j:
            if C[j] == "R":
                res += 1
                C[i] = "R"
                C[j] = "W"
                break
            j -= 1
    if i >= j:
        break

print(res)


Measured memory_bytes: 10708
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main(int argc, char* argv[]) {
  int a, b, c;
  cin >> a >> b >> c;

  cout << std::max(0, c - (a - b));

  return 0;
}


Measured memory_bytes: 256
package main

import (
        "fmt"
)

func solution(a, b, c int) int {

        count := 0
        for a&1 == 0 && b&1 == 0 && c&1 == 0 {
                at := a / 2
                bt := b / 2
                ct := c / 2
                a = bt + ct
                b = at + ct
                c = at + bt
                count++
                if a == b && b == c && c == a {
                        return -1
                }
        }
        return count
}

func main() {
        var a, b, c int
        fmt.Scan(&a, &b, &c)
        fmt.Println(solution(a, b, c))
}

Measured memory_bytes: 512
// Problem : D - Banned K
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()
using namespace std;
using namespace __gnu_pbds;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
template<class T>
T abst(T a)
{return a<0?-a:a;}
template<class T> using ordered_set=tree<
T,
null_type,
less_equal<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;cin>>n;
vi v(n);cin>>v;
int count=0;
int arr[200001]={0};
for(int i=0;i<n;i++){
	arr[v[i]]++;
}
for(int i=0;i<=200000;i++){
	count+=(arr[i]*(arr[i]-1))/2;
}
for(int i=0;i<n;i++){
	if(arr[v[i]]==1)cout<<count<<"\n";
	else
	cout<<count-(arr[v[i]]-1)<<"\n";
}
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
}


Measured memory_bytes: 5760
#define _USE_MATH_DEFINES

#include <iostream>
#include <math.h> 
#include <vector>
#include <algorithm>
#include <iomanip>      // std::setprecision
#include <map>
#include <unordered_map>
#include <string>
#include <set>
#include <unordered_set>

using namespace std;

int main()
{
	int N,sol, s_counter = 0;
	char a;
	std::string line;
	std::getline(cin, line);
	N = line.length();
	sol = N;

	for (int i = 0; i < N; i++)
	{
		if (line[i] == 'S')
		{
			s_counter++;
		}
		else
		{
			if (s_counter > 0)
			{
				s_counter--;
				sol -= 2;
			}
		}
	}
	std::cout << sol;
}

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

typedef long long lli;

int main() {
  lli N;
  while(cin >> N && N) {
    lli sq = ceil(sqrt(N*2)/2.0);
    lli sum = 0;
    for(lli x = 1; x < sq; ++x) {
      sum += (lli)ceil((double)N/(2.0*x));
    }
    cout << N*8 + (sum*8 - sq*sq*4 + 4 + N*4-4)*2 << endl;;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const ll INF = numeric_limits<ll>::max();
int main()
{
    int n; cin >> n;
    ll ans = 0;
    FOR(i, 1, n) {
        ans += (n-1)/i;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    char input[11];
    while (cin >> input) {
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9 - i; j++) {
                input[j] = (input[j] - '0'+ input[j + 1] - '0') % 10 + '0';
            }
            input[10 - i] = '\0';
        }
        cout << input[0] << endl;
    }
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
int Array[10];
bool Selected[10];
int Final = 1000000;

void Permutations( int count , int Ans ){
    if( count == 5 ){
        Final = min( Final , Ans );
        return;
    }

    int i , Temp;

    for( i = 1 ; i <= 5 ; ++i ){
        if( Selected[i] == false ){
            Selected[i] = true;
            if( Ans % 10 == 0 ) Temp = 0;
            else Temp = 10 - ( Ans % 10 );
            Permutations( count + 1 , Ans + Temp + Array[i] );
            Selected[i] = false;       
        }
    }
}

int main(){
    int i , N = 5;

    for( i = 1 ; i <= N ; ++i )
        scanf( "%d" , Array + i );
    
    fill( Selected , Selected + 6 , false );
    Permutations( 0 , 0 );
    printf( "%d\n" , Final );
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int n;
	cin >> n;
	veci h(n);
	rep(i, n) cin >> h[i];
	reverse(all(h));
	veci dp(n, INT_MAX);
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	for (size_t i = 2; i < n; i++)
	{
		dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  string answer;
  if (abs(c-a) <= d) {
    answer = "Yes";
  }
  else if (abs(b-a)<=d && abs(c-b)<=d) {
    answer = "Yes";
  }
  else {
    answer = "No";
  }
  cout << answer << endl;
}

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

typedef long long LL;

const int N=5000,mod=1000000007;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}

int n;
struct side{
  int y,next;
}e[N*2+9];
int lin[N+9],cs;

void Ins(int x,int y){e[++cs].y=y;e[cs].next=lin[x];lin[x]=cs;}
void Ins2(int x,int y){Ins(x,y);Ins(y,x);}

void into(){
  scanf("%d",&n);
  for (int i=1;i<n;++i){
	int x,y;
	scanf("%d%d",&x,&y);
	Ins2(x,y);
  }
}

int g[N+9];

void Get_g(){
  g[0]=1;
  for (int i=2;i<=n;i+=2) g[i]=mul(g[i-2],i-1);
}

int siz[N+9],dp[N+9][N+9],tmp[N+9];

void Dfs_dp(int k,int fa){
  dp[k][1]=1;
  siz[k]=1;
  for (int i=lin[k];i;i=e[i].next)
	if (e[i].y^fa){
	  int y=e[i].y;
	  Dfs_dp(y,k);
	  for (int i=0;i<=siz[k];++i)
		for (int j=0;j<=siz[y];++j) sadd(tmp[i+j],mul(dp[k][i],dp[y][j]));
	  siz[k]+=siz[e[i].y];
	  for (int i=0;i<=siz[k];++i) dp[k][i]=tmp[i],tmp[i]=0;
	}
  for (int i=2;i<=siz[k];i+=2) ssub(dp[k][0],mul(dp[k][i],g[i]));
}

void work(){
  Get_g();
  Dfs_dp(1,0);
}

void outo(){
  printf("%d\n",sub(0,dp[1][0]));
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 97280
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x,n) rep(__i,n) pri(x,__i);
#define prar(x,b,e) repr(__i,b,e) pri(x,__i);

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;

ll MOD = 1000000007;

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

int main() {
	int N = in();
	vint a(N + 2);
	rep(i,N) a[i] = in();
	a[N] = -INF;
	a[N + 1] = INF;
	sort(a.begin(), a.end());
	
	int left = 0, right = 1;
	int ans = 1;
	repr(i,0,100000) {
		int temp = upper_bound(a.begin(), a.end(), i+1) - lower_bound(a.begin(), a.end(), i-1);
		if (temp > ans) ans = temp;
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5]) puts("Yes");
	else puts("No");
	return 0;
 } 

Measured memory_bytes: 256
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
int main()
{
    fastio;
    string s;
    cin>>s;
    if(s[0]>='A'&&s[0]<='Z')
    {
        cout<<"A"<<endl;
    }
    else
        cout<<"a"<<endl;
}


Measured memory_bytes: 3592
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;

namespace Atcoder
{
	class Program
	{
		/*
			string s = Console.ReadLine();
			string[] ST = Console.ReadLine().Split(' ').ToArray();
			string S = strArray[0];
			string T = strArray[1];

			int[] HWN = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
			int H = intArray[0];
			int W = intArray[1];
			int N = int.Parse(Console.ReadLine());

			List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToList());
			
			double[] R = Console.ReadLine().Split(' ').Select(i => double.Parse(i)).ToArray();

			Boolean ok = false;
			
			List<int> dp = Enumerable.Repeat(値, 個数).ToList();
			
			Console.WriteLine(ans);
			Console.WriteLine("Yes");
			Console.WriteLine("No");
			Console.ReadKey();
			Console.WriteLine(cnt);

			for(int i= 0; i < N; i++)
		*/

		static void Main(string[] args)
		{
			int N = int.Parse(Console.ReadLine());
			string S = Console.ReadLine();
			int cnt = 1;

			for(int i = 1; i < N; i++)
            {
				if(S[i] != S[i - 1])
                {
					cnt++;
                }
            }
			Console.WriteLine(cnt);
		}

		class Item : IComparable
		{
			public string A;
			public int B;
			public Item(string a, int b)
			{
				this.A = a;
				this.B = b;
			}
			public int CompareTo(object obj)
			{
				return B - ((Item)obj).B;
			}
		}

		/// <summary>
		/// 回文
		/// </summary>
		/// <param name="Target"></param>
		/// <param name="len"></param>
		/// <returns></returns>
		static bool Palindrome(string Target , int len)
        {
			bool yes = true;

			for(int i = 0;i < len; i++)
            {
				if(Target[i] != Target[len - 1 - i])
                {
					yes = false;
					break;
                }
            }
			return yes;
        }

		/// <summary>
		/// アナグラム
		/// </summary>
		/// <param name="word1"></param>
		/// <param name="word2"></param>
		/// <returns></returns>
		static bool IsAnagramOf(string word1, string word2)
		{
			char[] val1 = word1.ToCharArray();
			char[] val2 = word2.ToCharArray();
			Array.Sort(val1);
			Array.Sort(val2);
			word1 = new string(val1);
			word2 = new string(val2);

			return word1 == word2;
			//return word1.OrderBy(x => x).SequenceEqual(word2.OrderBy(x => x));
		}

		/// <summary>
		/// 最小公倍数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static BigInteger Lcm(BigInteger a, BigInteger b)
		{
			return a * b / Gcd(a, b);
		}

		/// <summary>
		/// 最大公約数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static BigInteger Gcd(BigInteger a, BigInteger b)
		{
			if (a < b)
				// 引数を入替えて自分を呼び出す
				return Gcd(b, a);
			while (b != 0)
			{
				var remainder = a % b;
				a = b;
				b = remainder;
			}
			return a;
		}
	}
}

Measured memory_bytes: 27364
#include<bits/stdc++.h>
using namespace std; //std::の省略のため
using ll = long long;

int SUM(int n){
    int sum = 0;
    while(n>0){
        sum += n%10;
        n /= 10;
    }

    return sum;
}

int main(){
    int a,b,n;

    cin >> n >> a >> b;

    int sum = 0;
    int num;

    for(int i = 1; i <= n; i++){
        num = SUM(i);
        if(a <= num && num <= b) sum += i;
    }

    cout << sum << endl;
}

Measured memory_bytes: 3600