akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan=new Scanner(System.in);
    int i=scan.nextInt();
    int j=scan.nextInt();
    if (i!=j){
      System.out.println("No");
    }else
      System.out.println("Yes");
    scan.close();
  }
}


Measured memory_bytes: 22996
parseInt(x) = parse(Int,x)
function tfs(x)
	if x == 0
		0
	elseif x == 1
		3
	elseif x == 2
		5
	else
		7
	end
end

function main()
	n = parseInt(readline())
	r = 0
	a = zeros(Int, 9)
	for i in 0:3
		a[1] = i
		for j in 0:3
			a[2] = j
			for k in 0:3
				a[3] = k
				for l in 0:3
					a[4] = l
					for m in 0:3
						a[5] = m
						for o in 0:3
							a[6] = o
							for p in 0:3
								a[7] = p
								for q in 0:3
									a[8] = q
									for s in 0:3
										a[9] = s
										b = 0
										for i in 1:9
											if a[i] != 0
												b = i
												break
											end
										end
										flg = 0
										for i in b+1:9
											if a[i] == 0
												flg =1
											end
										end
										x = tfs(a[1])*10^8+tfs(a[2])*10^7+tfs(a[3])*10^6+tfs(a[4])*10^5+tfs(a[5])*10^4+tfs(a[6])*10^3+tfs(a[7])*10^2+tfs(a[8])*10+tfs(a[9])
										if 1 in a && 2 in a && 3 in a && x <= n && flg == 0
											r += 1
										end
									end
								end
							end
						end
					end
				end
			end
		end
	end
	print(r)
end
main()

Measured memory_bytes: 183308
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<bitset>
#include<deque>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define ri register int
#define il inline
#define fi first
#define se second
#define mp make_pair
#define pi pair<int,int>
#define mem0(x) memset((x),0,sizeof (x))
#define mem1(x) memset((x),0x3f,sizeof (x))
il char gc() {
	static const int BS = 1 << 22;
	static unsigned char buf[BS], *st, *ed;
	if (st == ed) ed = buf + fread(st = buf, 1, BS, stdin);
	return st == ed ? EOF : *st++;
}
#define gc getchar
template<class T>void in(T &x) {
	x = 0;
	bool f = 0;
	char c = gc();
	while (c < '0' || c > '9') {
		if (c == '-') f = 1;
		c = gc();
	}
	while ('0' <= c && c <= '9') {
		x = (x << 3) + (x << 1) + (c ^ 48);
		c = gc();
	}
	if (f) x = -x;
}
#undef gc
#define pb push_back
// 1743
#define N 1010
#define M 5010
int n;
vector<int>sn[N];
int w[N];
int f[N], g[2][M];
void dfs(int x) {
	for (ri i = 0; i < sn[x].size(); ++i) {
		dfs(sn[x][i]);
	}
	mem1(g);
	int op = 0;
	g[0][0] = 0;
	for (ri i = 0; i < sn[x].size(); ++i) {
		int v = sn[x][i];
		op ^= 1;
		mem1(g[op]);
		for (ri j = 0; j <= w[x]; ++j) {
			if (j - w[v] >= 0) g[op][j] = min(g[op][j], g[op ^ 1][j - w[v]] + f[v]);
			if (j - f[v] >= 0) g[op][j] = min(g[op][j], g[op ^ 1][j - f[v]] + w[v]);
		}
	}
	for (ri i = 0; i <= w[x]; ++i) {
		f[x] = min(f[x], g[op][i]);
	}
}
signed main() {
	in(n);
	mem1(f);
	for (ri i = 2, p; i <= n; ++i) {
		in(p);
		sn[p].pb(i);
	}
	for (ri i = 1; i <= n; ++i) {
		in(w[i]);
	}
	dfs(1);
	puts(f[1] < f[0] ? "POSSIBLE" : "IMPOSSIBLE");
	return 0;
}

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

int gcm(int a,int b);

int main(){
  int a;
  cin >> a;
  vint A(a);
  rep(i,a) cin >> A[i];
  vint L(a-1);
  L[0] = A[0];
  rep(i,a-1) L[i+1] = gcm(L[i],A[i + 1]);
  //rep(i,a)  cout << L[i] << endl;
  //cout << "A" << endl;
  vint R(a-1);
  R[a-1] = A[a-1];
  for(int i = a-2;i>=0;i--) R[i] = gcm(R[i+1],A[i]);
  //rep(i,a)  cout << R[i] << endl;
  //cout << "B" << endl;
  int ans = 1;
  rep(i,a){
    if(i == 0) ans = max(ans,R[1]);
    else if(i == a-1) ans = max(ans,L[a-2]);
    else ans = max(ans,gcm(L[i-1],R[i+1]));
   // cout << ans << endl;
  }
  cout << ans << endl;
}

int gcm(int a,int b){
  if(a < b) swap(a,b);
  if(b == 0) return a;
  return gcm(a%b,b);
}

Measured memory_bytes: 1408
S = str(input())
ans = 0
for i in range(len(S)):
    if i%2 == 0:
        if S[i] != 'R' and S[i] !='U' and S[i] !='D':
            print('No')
            exit()
    else:
        if S[i] !='L' and S[i] !='U' and S[i] !='D':
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3060
#include <cstdio>
using namespace std;

int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a>b?a:b;}
int ar[200][2],n;
int m[4][2]={{0,-1},{1,0},{0,1},{-1,0}};
int main(){
    ar[0][0]=225;
    ar[0][1]=225;
    while(scanf("%d",&n),n){
        int minx=225,miny=225,maxx=225,maxy=225;
        for(int i=1;i<n;i++){
            int x,y,a,b;
            scanf("%d%d",&a,&b);
            x=ar[a][0]+m[b][0];
            y=ar[a][1]+m[b][1];
            ar[i][0]=x;
            ar[i][1]=y;
            minx=min(x,minx);
            miny=min(y,miny);
            maxx=max(x,maxx);
            maxy=max(y,maxy);
        }
        printf("%d %d\n",maxy-miny+1,maxx-minx+1);
    }
    return 0;
}

Measured memory_bytes: 1028
#include<iostream>
using namespace std;
int main(){
	bool num[1000000] = {0};
	for(int i=2; i<1000000; i++){
		if(!num[i]){
			for(int j=i*2; j<1000000; j+=i){num[j] = true;}
		}
	}
	int n;
	while(cin >>n){
		int f = 0;
		for(int i=2; i<=n; i++){
			if(!num[i]){f++;}
		}
		cout <<f<<endl;
	}
}

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

Measured memory_bytes: 1708
let scan_int () = Scanf.scanf " %d" (fun x -> x)
let scan_array len read_func = Array.init len (fun _ -> read_func())
let print_int n = Printf.printf "%d\n" n

let judge (a : int array) (d: int) (k : int) =
  let a = Array.map (fun x -> x mod d) a in
  let _ = Array.fast_sort (fun x y -> y - x) a in  (* 降順 *)
  let sum = Array.fold_left (+) 0 a in
  let rec calc_cost a i count =
    if (sum - (i * d - count)) == count then count
    else calc_cost a (i+1) (count + (d - a.(i))) in
  if calc_cost a 0 0 <= k then true
  else false

let () =
  let n = scan_int() and k = scan_int() in
  let a = scan_array n scan_int in
  let sum = Array.fold_left (+) 0 a in
  let rec for_loop i ret =
    if i * i > sum then ret
    else 
      if sum mod i == 0 then
        let ret = if (judge a i k) then max i ret else ret in
        let ret = if judge a (sum/i) k then max (sum/i) ret else ret in
        for_loop (i+1) ret
      else for_loop (i+1) ret in
  print_int (for_loop 1 0)

Measured memory_bytes: 6400
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mp make_pair
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
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 main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<int> ans(n+1, 0);
  int m = 0;
  vector<int> b;
  rreps(i, n){
    int sum = 0;
    for(int j = i * 2; j <= n; j += i){
      sum += ans[j];
    }
    if(sum %2 != a[i-1]) {
      ans[i] = 1;
      ++m;
      b.pb(i);
    }
  }

  cout << m << endl;
  rep(i, m) cout << b[i] << endl;
}


Measured memory_bytes: 5356
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, c[30], s[400][30];
int d[30];
int ans[400];

int score() {
	int res = 0;
	int dd[30];
    fill(dd,dd+30,0);
	for (int i = 1; i <= n; i++) {
		res += s[i][ans[i]];
		d[ans[i]] = i;
		for (int j = 1; j <= 26; j++)res -= c[j] * (i - d[j]);
	}
	return res;
}

signed main() {
	std::random_device rnd;
	cin >> n;
	for (int i = 1; i <= 26; i++)cin >> c[i];
	for (int i = 1; i <= n; i++)for (int j = 1; j <= 26; j++)cin >> s[i][j];
	for (int i = 1; i <= n; i++) {
		int ma = -1000000000, p = 0;
		for (int j = 1; j <= 26; j++) {
			int cnt = 0;
			for (int k = 1; k <= 26; k++)if (j != k)cnt -= c[k] * (i - d[k]);
			cnt += s[i][j];
			if (ma < cnt) {
				ma = cnt;
				p = j;
			}
		}
		ans[i] = p;
		d[p] = i;
	}
	int q = 140000;
	while (q) {
		int x = rnd() % 365 + 1, y = rnd() % 26 + 1;
		int g = ans[x];
		int f = score();
		ans[x] = y;
		if (score() < f) ans[x] = g;
        q--;
	}
	for (int i = 1; i <= n; i++)cout << ans[i] << endl;
    //cout << score() << endl;
}

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

int main(){
	int N, D1, D2, i, j, k, l, f, g;
	scanf("%d%d%d", &N, &D1, &D2);
	for(k = 0; (D1 & 1) == 0; D1 >>= 1, k++){}
	for(l = 0; (D2 & 1) == 0; D2 >>= 1, l++){}
	int num = 0;
	for(i = 0; i < 2 * N; i++){
		for(j = 0; j < 2 * N; j++){
			if(num == N * N){
				return 0;
			}
			if(((((k&1)|(((i>>(k>>1))^(j>>(k>>1)))&1))&(((k^1)&1)|((i>>(k>>1))&1)))|(((l&1)|(((i>>(l>>1))^(j>>(l>>1)))&1))&(((l^1)&1)|((i>>(l>>1))&1))))==0){
				printf("%d %d\n", i, j);
				num++;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 768
import sys
sys.setrecursionlimit(10**5)
n = int(input())
ab = [list(map(int,input().split()))for _ in range(n-1)]

graph = [[] for _ in range(n+1)]
ans = [0]*(n-1)
for i in range(n-1):
    graph[ab[i][0]].append((ab[i][1],i))
    graph[ab[i][1]].append((ab[i][0],i))

visit = [False]*(n+1)
def dfs(p,c):
    color = 1
    visit[p] = True
    for n,i in graph[p]:
        if visit[n] == False:
            if color == c:
                color += 1
            ans[i] = color
            dfs(n,color)
            color += 1

dfs(1,0)
print(max(ans))
for t in ans:
    print(t)


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

using namespace std;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD 1e9 + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b == 0) return b;
  else gcd(b, a%b);
}

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

struct UnionFind {
  vi par; //par[i] : iの親番号（例）par[3] = 2 : 3の親は2

  UnionFind(int N) : par(N) { //最初は全てが根として初期化
    rep(i,N) par[i] = i;
  }

  int root(int x){ //データxが属する木の根を再帰で得る : root(x) = {xの木の根}
    if(par[x] == x)return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y){ //xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if(rx == ry)return; //xとyの根が同じ
    par[rx] = ry; //xとyの根が同じでない時、xの根rxをyの根にryにつける。
  }

  bool same(int x, int y){//2つのデータx，yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};


int main(){

  int n; cin >> n;
  int sum = 0;
  int nn = n;
  while(1){
    sum += (nn%10);
    if(nn < 10)break;
    nn /= 10;
  }
  if( n % sum == 0)cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            int N = GetInt();
            var A = GetIntArray();
            var ans = A.Where(a => a % 2 == 0).Any(a => a % 3 != 0 && a % 5 != 0) ? "DENIED" : "APPROVED";

            Console.WriteLine(ans);
            Console.ReadKey();
        }

        static void Solve()
        {

        }



        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c, out V d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<V>(ar[3]);
        }
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

struct edge{int to,cost;};
	
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	string s;
	cin >> s;

	int g=0,p=0,win=0,lose=0;
	for(int i=0;i<s.size();i++){
		if(g==p){
			g++;
			if(s[i]=='p') lose++;
		}
		else{
			p++;
			if(s[i]=='g') win++;
		}
	}
	cout << win-lose << "\n";
	
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ll long long
#define rep(i,x,y) for(register int i=(x);i<=(y);++i)
using namespace std;
int n;const int mxn=1e5+5;
int a[mxn],b[mxn];
ll sa,sb;
int main(){
	scanf("%d",&n);
	rep(i,0,n-1) scanf("%d%d",a+i,b+i);
	vector<pii>x;
	rep(i,0,n-1){
		x.emplace_back(a[i],i);
		x.emplace_back(b[i],i);
		sa+=a[i],sb+=b[i];
	}
	sort(x.begin(),x.end());
	vector<ll>pre(x.size()+1);
	pre[0]=0;
	rep(i,0,x.size()-1) pre[i+1]=pre[i]+x[i].first;
	vector<vector<int> >pos(n);
	rep(i,0,x.size()-1) pos[x[i].second].push_back(i);
	ll sum=(ll)(2e18);
	rep(i,0,n-1){
		int j=n;
		while(1){
			int tc=(pos[i][0]<j)+(pos[i][1]<j);
			if(tc==j-n) break;
			++j;
		}
		ll cur=pre[j];
		if(pos[i][0]<j) cur-=x[pos[i][0]].first;
		if(pos[i][1]<j) cur-=x[pos[i][1]].first;
		sum=min(sum,cur);
	}
	sum=min(sum,min(sa,sb));
	printf("%lld\n",sum);
}

Measured memory_bytes: 9584
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

ll n;
ll a[100005];
ll front_gcd[100005];
ll back_gcd[100005];
ll ans = 0;

ll gcd(ll x, ll y);

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

    for (int i = 1; i <= n; i++) {
        front_gcd[i] = gcd(front_gcd[i - 1], a[i]);
    }

    for (int i = n; i >= 1; i--) {
        back_gcd[i] = gcd(back_gcd[i + 1], a[i]);
    }

    for (int i = 1; i <= n; i++) {
        ans = max(ans,
                  gcd(front_gcd[i - 1], back_gcd[i + 1]));
    }

    cout << ans << endl;

    return 0;
}

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

    return __gcd(x, y);
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include <vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	vector<pair<ll, ll>> j(n);
	rep(i, n) {
		ll a, b;
		cin >> a >> b;
		j[i] = make_pair(b, a);
	}
	vsort(j);
	ll t = 0;
	bool flag = true;
	rep(i, n) {
		t += j[i].second;
		if (t > j[i].first) {
			flag = false;
			break;
		}
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

int main(){
  string s;
  int n;
  
  cin >> n >> s;
  
  rep(i,s.size()){
    int m = s.at(i)-'A';
    m = (m+n)%26;
    s.at(i) = m + 'A';
  }
  
  cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long n,a[100005];
	cin>>n;
	for (int i=1;i<=n;i++) 
		cin>>a[i];
	for (int i=2;i<=n;i++)
		a[1]=a[1]^a[i];
	if (a[1]==0) {
		cout<<"Yes";
	}
	else cout<<"No";
	return 0;
}

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

void solve() {
	int N, M; cin >> N >> M;
	
	vector<vector<int>> vec(M);
	rep(i, M) {
		int k; cin >> k;
		vec[i].resize(k);
		rep(j, k) {
			cin >> vec[i][j];
			vec[i][j]--; // 0-indexに変更
		}
	}

	vector<int> p(M);
	rep(i, M) scanf("%d", &p[i]);

	int ans = 0;
	rep(i, (1 << N)) {
		bool ok = true;
		rep(j, M) {
			int c = 0;
			for (int id : vec[j]) {
				if ((i >> id) & 1) c++;
			}
			c %= 2;
			if (c != p[j]) {
				ok = false;
			}
		}
		if (ok) ans++;
	}

	cout << ans << endl;
}

int main(void) {
	solve();

	return 0;
}

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(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int t1 = 60*h1+m1;
    int t2 = 60*h2+m2;
    if(t2<t1)t2+=60*24;
    cout << t2-t1-k << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

  int cnt[N+1] = {};
  for(int i=0;i<M;i++){
    int a,b;
    cin >> a >> b;
    cnt[a]++;
    cnt[b]++;
  }

  for(int i=1;i<=N;i++){
    cout << cnt[i] << endl;
  }

  return 0;
}

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

int main()
{
	int n;
	double w, t;
	while( scanf( "%d,%lf,%lf", &n, &w, &t ) != EOF ){
		if( w / ( t * t ) >= 25.0 ){
			std::cout << n << std::endl;
		}
	}

 	return 0;
}

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


int a,b,h,m;

int main(){
  scanf("%d%d%d%d",&a,&b,&h,&m);
 
  double rad1 = 1.0*2*M_PI*(1.0*h/12+1.0/60/12*m);
  double rad2 =  1.0*2*M_PI*m/60;
  double rad = rad1-rad2;
  /*
  if(rad1>rad2){
    rad = rad1-rad2;}
  else{
    rad = rad2-rad1;}
  */
  double ans = sqrt(1.0*a*a+1.0*b*b-2.0*a*b*cos(rad));

  printf("%.10f\n",ans);
  
  return 0;
}


Measured memory_bytes: 2576
#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 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)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<double> v(n);
    REP(i,n)cin >> v[i];
    sort(ALL(v));
    double ans = v[0];
    REP(i,n-1){
        ans = (ans + v[i+1]) / 2;
    }
    cout << fixed << setprecision(8) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;
    string S;
    cin >> N >> S;

    int memo[N];
    for (int i = 0; i <= N; i++) memo[i] = 0;

    for (int i = 0; i < N; i++) {
      if (S[i] == 'W') {
        memo[i+1] = memo[i] + 1;
      } else {
        memo[i+1] = memo[i];
      }
    }

    int ans = N;
    for (int i = 0; i < N; i++) ans = min(ans, memo[i] + (N - i - 1) - (memo[N] - memo[i+1]));
    cout << ans << endl;
}


Measured memory_bytes: 1796
#include<iostream>
using namespace std;
int main(){
  int i,n;
  string s;
  cin>>n;
  cin>>s;
  int min,buf=0;
  for(i=0;i<n;i++){
    if(s[i]=='.') buf++;
  }
  min=buf;
  for(i=0;i<n;i++){
    if(s[i]=='.') buf--;
    else buf++;
    if(min>buf){
      min=buf;
    }
  }
  cout<<min<<endl;
  return 0;
}

Measured memory_bytes: 640
# coding: utf-8

def solve(*args: str) -> str:
    n = int(args[0])

    n_sqrt = -int(-pow(n, 0.5))
    A = [0]*(n+1)

    for x in range(1, n_sqrt):
        for y in range(1, n_sqrt):
            for z in range(1, n_sqrt):
                i = x*x+y*y+z*z+x*y+y*z+z*x
                if i <= n:
                    A[i] += 1

    return '\n'.join(map(str, A[1:]))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 9768
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int N;
cin >> N;
vector<int> vec(N);
int maxi = -1;
for (int i = 0;i < N;i++) {
    cin >> vec.at(i);
}
sort(vec.begin(),vec.end());
int gou = 0;
for (int i = 0;i < N-1;i++) {
    gou += vec.at(i);
}
if (gou > vec.at(N-1)) cout << "Yes" << endl;
else cout << "No" << endl;


return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

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

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

//	for priority queue
//	priority_queue<ipair, vector<ipair>, greater<ipair>>
using ipair = pair<int, pair<int, int>>;
bool operator>(const ipair a, const ipair b) { return a.first > b.first; };
bool operator<(const ipair a, const ipair b) { return a.first < b.first; };

int main()
{
	int n, m;
	cin >> n >> m;
	struct s { ll x, y, z; };
	vector
 p(n);
	for (int i = 0; i < n; i++)
		cin >> p[i].x >> p[i].y >> p[i].z;

	ll r = 0;

	for (int i = 0; i < 8; i++)
	{
		bool fx = i % 2 == 0;
		bool fy = i % 4 <= 1;
		bool fz = i / 4 == 0;

		sort(p.begin(), p.end(), [&fx, &fy, &fz](const s &l, const s &r) {return (fx ? l.x - r.x : r.x - l.x) + (fy ? l.y - r.y : r.y - l.y) + (fz ? l.z - r.z : r.z - l.z) > 0; });
		ll c = 0;
		for (int j = 0; j < m; j++)
			c += (fx ? p[j].x : -1 * p[j].x) + (fy ? p[j].y : -1 * p[j].y) + (fz ? p[j].z : -1 * p[j].z);
		if (c > r)
			r = c;
	}

	printf("%lld", r);

	return 0;
}


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

#define FOR( i, m, n )	for( int (i) = (m); (i) < (n); i++ )
#define REP( i, n )		FOR( i, 0, n )
#define ALL( x )		(x).begin(), (x).end()

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

	string s; cin >> s;

	int k; cin >> k;
	int tmp = s[k - 1];
	REP( i, n ) {
		if( s[i] != tmp ) s[i] = '*';
	}

	cout << s <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+11;
int a[N],n;
int chk(int m){
	int i;
	if(m==1){
		for(i=1;i<n;++i)if(a[i]>=a[i+1])return 0;
		return 1;
	}
	map<int,int> f;
	for(i=2;i<=n;++i)if(a[i]<=a[i-1]){
		f.erase(f.upper_bound(a[i]),f.end());
		int k=a[i];
		++f[k];
		while(k>0&&f[k]==m)f.erase(k),++f[--k];
		if(!k)return 0;
	}
	return 1;
}
int main(){
	cin>>n;
	int i;
	for(i=1;i<=n;++i)scanf("%d",a+i);
	int l=1,r=n,m;
	while(l<r){
		m=l+r>>1;
		if(chk(m))r=m;
		else l=m+1;
	}
	cout<<l;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

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



int main()
{
	string s;
	const string sun = "Sunny";
	const string clo = "Cloudy";
	const string rai = "Rainy";

	cin >> s;


	if (s == sun)
		cout << clo;
	else if (s == clo)
		cout << rai;
	else
		cout << sun;
	cout << endl;
	

}


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

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();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0, sizeof(a))

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

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; }

ll dp[101][101];
vector<ll> R(101), C(101);

ll rec(int l, int r){
    if(dp[l][r] != -1) return dp[l][r];
    if(r-l == 2) return dp[l][r] = R[l]*R[r-1]*C[r-1];
    if(r-l < 2) return dp[l][r] = 0;

    ll res = LL_INF;
    FOR(i,l+1,r){
        chmin(res, R[l]*R[i]*C[r-1]+(rec(l,i)+rec(i,r)));
    }
    return dp[l][r] = res;
}

int main(void){
    ll n; cin >> n;
    REP(i,n) cin >> R[i] >> C[i];
    REP(i,n+1)REP(j,n+1) dp[i][j] = -1;
    //REP(i,n+1)FOR(j,i+2,n+2) dp[i][j] = LL_INF;
    ll ans = rec(0,n);
    cout << ans << en;
    return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define tam 100010

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <ll, ll> dl;
typedef pair <int, int> ii;
typedef vector <ii> vii;
typedef vector <vii> graph;

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

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

	ll n, w;
	cin >> n >> w;
	ll peso[n + 1];
	ll valor[n + 1];
	ll dp[n + 1][w + 1];
	for (int i = 1; i <= n; ++i)
	{
		cin >> peso[i] >> valor[i];
	}
	for (int i = 0; i < w + 1; ++i)
	{
		dp[0][i] = 0;
	}
	for (int i = 1; i < n + 1; ++i)
	{
		for (int j = 0; j < w + 1; ++j)
		{
			if (peso[i] > j) dp[i][j] = dp[i - 1][j];
			else  dp[i][j] = max(dp[i - 1][j], valor[i] + dp[i - 1][j - peso[i]]);
		}
	}
	cout << dp[n][w] << "\n";
	return 0;
}


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

  cout << min((2*N+M)/4,M/2) << endl;
}

Measured memory_bytes: 256
var
  n,k,t,i:longint;
  a,sum:array[0..300000] of real;
  ans:real;
begin
  readln(n,k);
  for i:=1 to n do
  begin
    read(t);
    a[i]:=(1+t)*t div 2/t;
    sum[i]:=sum[i-1]+a[i];
  end;
  for i:=k to n do
  if sum[i]-sum[i-k]>ans then ans:=sum[i]-sum[i-k];
  writeln(ans:0:12);
end.

Measured memory_bytes: 3712
from collections import deque

n,m=map(int,input().split())

heya=[[]for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    heya[a].append(b)
    heya[b].append(a)

#print(heya)

queue=deque()
queue.append(0)

mada=[True]*n
mada[0]=False

ans=[-1]*n

for i in range(10*n):
    #print(queue)
    if(len(queue)==0):
        break
    gen=queue.popleft()
    for h in heya[gen]:
        #print(h)
        if(mada[h]):
            mada[h]=False
            queue.append(h)
            ans[h]=gen+1

print("Yes")
for i in range(1,n):
    print(ans[i])



Measured memory_bytes: 37692
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

ans = 0

def biSearch(A, key):
  left = 0
  right = n
  while left < right:
    mid = int((left + right) / 2)
    if A[mid] == key:
      return 1
    if A[mid] > key:
      right = mid
    if A[mid] < key:
      left = mid + 1
  return 0
for t in T:
  ans += biSearch(S, t)
print(ans)


Measured memory_bytes: 16716
N = tuple(input())
N = tuple(map(int, N))

ans = 0
flag = False
flag5 = False
i = len(N)-1


for x in reversed(N):
    if flag or (flag5 and x >= 5):
        x += 1
    flag5 = False
    flag = False
    if x > 5:
        ans += (10 - x)
        flag = True
        if i == 0:
            ans += 1
    else:

        ans += x
    if x == 5:
        flag5 = True
    i -= 1

print(ans)

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


int main() {
 int N;
  cin >>N;
vector< pair<pair<string,int>,int>> s(N);
 for(int i=0;i<N;i++)  {
 string S;
  int P;
  cin >>S >>P;
 s[i] = make_pair( make_pair(S,-P),i+1);
 }
  sort(s.begin(),s.end());
  for(int i=0;i<N;i++){
  cout << s[i].second  <<endl;
  }
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=1000010;
int n,m,i,j,k,a[N],f[N],ans,g[N],tim,cnt;
int minx(int x,int y,int z){
	if (x>y) x=y;if (x>z) x=z;return x;
}
int main(){
	scanf("%d%d",&n,&k);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	for (i=1;i<=n;i++) if (a[i]>0) f[++cnt]=a[i];
	for (i=n;i>=1;i--) if (a[i]<0) g[++tim]=-a[i];
	for (i=1;i<=n;i++) if (a[i]==0) k--;ans=f[cnt]*2+g[tim];
	for (i=max(0,k-cnt);i<=min(tim,k);i++) ans=minx(ans,f[k-i]*2+g[i],f[k-i]+g[i]*2);printf("%d\n",ans);return 0;
}

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

using namespace std;
using ll = long long;
#define N 1000000007
ll mypower(ll a, ll b, ll mod)
{
    ll ans = 1;
    while(b > 0)
    {
        if(b%2 == 1)
            ans = (ans*a)%mod;
        a = (a*a)%mod;
        b = b/2;
    }
    return ans;
}
int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = mypower(2, n, N);
    ans = (ans - 1 + N)%N;
    ll ans2 = 0;
    ll prod = 1;
    ll i;
    for(i=0;i<a;i++)
    {
        prod = (prod*(n-i))%N;
        prod = (prod*mypower(a-i, N-2, N))%N;
    }
    ans2 = prod;
    prod = 1;
    for(i=0;i<b;i++)
    {
        prod = (prod*(n-i))%N;
        prod = (prod*mypower(b-i, N-2, N))%N;
    }
    ans2 = (ans2 + prod)%N;
    ans = (ans - ans2)%N;
    ans = (ans+N)%N;
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#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
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

ll C[55][55];
void comb_table(int n){
rep(i,n+1){
        rep(j,n+1){
            if(j==0||j==i)C[i][j]=(ll)1;
            else C[i][j]=C[i-1][j-1]+C[i-1][j];
            // if(j < 10)cout << C[i][j] << " ";
        }
        // cout << endl;
    }
}

int main(){
    comb_table(53);
    int n, a, b;
    ll v[55];
    cin >> n >> a >> b;
    rep(i ,n){
        cin >> v[i];
    }
    sort(v, v + n, greater<ll>());
    ll sum = 0, cnt = 0;
    rep(i, a) sum += v[i];
    printf("%.8lf\n",(double)sum / a);
    REP(i, a, b) if(v[0] == v[i]) cnt++;
    if(cnt == 0){
        int left = 1, right = 0;
        for(int i = a - 2; i >= 0; i--) if(v[i] == v[a - 1])left++;
        for(int i = a; i < n; i++) if(v[i] == v[a - 1])right++;
        // cout << "left: " << left << "    right: " << right << endl;
        cout << C[left + right][left] << endl;
    }else{
        ll ans = 0, max_cnt = 0;
        rep(i, n) if(v[0] == v[i]) max_cnt++;
        // cout << b << " " << max_cnt << endl;
        REP(i, a, min(max_cnt, (ll)b) + 1){ 
            ans += C[max_cnt][i];
            // cout << ans << endl;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a, b, c;
	int max, min, mid;
	cin >> a >> b >> c;

	int x = 10 * a + b + c;
	int y = 10 * b + a + c;
	int z = 10 * c + a + b;
	int ans;
	if (x >= y) {
		if (x >= z) {
			ans = x;
		}
		else {
			ans = z;
		}
	}
	else {
		if (y >= z) {
			ans = y;
		}
		else {
			ans = z;
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 3560
#include<stdio.h>
int main(void){
  long long N;
  scanf("%lld",&N);
  int A[N];
  for(int i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  long long sum=0;
  for(int k=0;k<N-1;k++){
    if(A[k]>A[k+1]){
      sum = sum + A[k] - A[k+1];
      A[k+1]=A[k];
    }
  }
  printf("%lld",sum);
}

Measured memory_bytes: 2508
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   int a,b,x;
           cin>>a>>b>>x;
           
           YES(a<=x&&x<=a+b);
}

Measured memory_bytes: 3576
MOD=10**9+7
def facinv(N):
    fac,finv,inv=[0]*(N+1),[0]*(N+1),[0]*(N+1)
    fac[0]=1;fac[1]=1;finv[0]=1;finv[1]=1;inv[1]=1
    for i in range(2,N+1):
        fac[i]=fac[i-1]*i%MOD
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        finv[i]=finv[i-1]*inv[i]%MOD
    return fac,finv,inv

N=int(input())
x=list(map(int,input().split()))

fac,finv,inv=facinv(N)

Inv=0
ans=0
for k in range(N-1):
    Inv=Inv+inv[k+1]
    res=Inv*(x[k+1]-x[k])
    ans=(ans+res)%MOD
print(ans*fac[N-1]%MOD)

Measured memory_bytes: 86968
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        //入力
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        sc.close();

        //分割
        char[] str1 = new char[str.length()];
        for(int i=0; i<str.length(); i++){
            str1[i] = str.charAt(i);
            //System.out.println(str1[i]);
        }


        int count = -1;
        //雨が0連続で降った場合
        if(str1[0] != 'R' && str1[1] != 'R' && str1[2] != 'R'){
            count = 0;
        }
        else if((str1[0] == 'S' && str1[1] == 'S') || (str1[1] == 'S' && str1[2] == 'S') || (str1[2] == 'S' && str1[0] == 'S') || (str1[0] == 'R' && str1[1] == 'S' && str1[2] == 'R')){
            count = 1;
        }
        else if((str1[0] == 'R' && str1[1] == 'R' && str1[2] == 'S') || (str1[0] == 'S' && str1[1] == 'R' && str1[2] == 'R')){
            count = 2;
        }
        else if(str1[0] == 'R' && str1[1] == 'R' && str1[2] == 'R'){
            count = 3;
        }

        System.out.println(count);

    }
}

Measured memory_bytes: 35740
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  int n,t,i,j;
  string s;
  int c[26],m[26];
  cin >> n;
  fill(m,m+26,50);
  for(i=0;i<n;i++){
    cin >> s;
    fill(c,c+26,0);
    for(j=0;j<s.size();j++)
      c[(int)(s[j]-'a')]++;
    for(j=0;j<26;j++)
      m[j]=min(m[j],c[j]);
  }
  for(i=0;i<26;i++)
    for(j=0;j<m[i];j++)
      cout << (char)('a'+i);
  cout << endl;
  return 0;
}

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

#define int long long
#define double long double
#define INF 9223372036854775807
#define mod 1000000007

double money[3009];

double memo[3009][3009];

int n;

double dp(int index, int last){
    if(index == n){
        if(last == 0) return 1;
        else return 1;
    }
    if(memo[index][last] != -1) return memo[index][last];
    if(last == 0){
        return memo[index][last] = dp(index+1, last)*money[index];
    }
    else{
        memo[index][last]= dp(index+1, last)*money[index]+dp(index+1,last-1)*((double)1-money[index]);
        //cout << index << ' ' << last << ' ' << memo[index][last] << endl;
        return memo[index][last];
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i< n; i++){
        cin >> money[i];
    }
    for(int i = 0; i < 3009; i++){
        for(int j = 0; j < 3009; j++){
            memo[i][j] = -1;
        }
    }
    cout << setprecision(16) << fixed << (double)dp(0,n-(n/2+n%2)) << endl;
}


Measured memory_bytes: 142080
def ten_decision(n,count):
  tmp = count
  if n >= 10 and n<100:
    count = count + 1
    n = n%10
    if n == 1:
      count = count + 1
  if tmp == count:
    return 0
  return count

n=int(input())
count = 0
if n == 0:
  print(0)
elif n == 1:
  print(1)
elif ten_decision(n,count):
  print(ten_decision(n,count))
elif n >= 100:
  count = count + 1
  n = n%100
  if ten_decision(n,count):
    print(ten_decision(n,count))
  else :
    if n ==1:
      count = count + 1
    print(count)


Measured memory_bytes: 3064
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

vector<int> v[100001];
vector<int> result;
int visited[100001];
int ans[100001];
void tsort(int x){
  if(visited[x]) return;
  visited[x] = 1;
  for(auto y: v[x]){
    tsort(y);
  }
  result.push_back(x);
}

int main(){
  int N, M;
  cin >> N >> M;
  rep(i, N + M - 1){
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
  }
  rep(i, N) tsort(i + 1);
  reverse(result.begin(), result.end());
  for(auto x: result){
    for(auto y: v[x]){
      ans[y] = x;
    }
  }
  rep(i, N) cout << ans[i + 1] << endl;
  return 0;
}


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

int main(){
    vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << v[k-1] << endl;

    return 0;
}

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

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

using namespace std;
using ll = long long;
const ll INF = 100000000;


int main() {
    ll n, k;
    ll a[200000];
    cin >> n >> k;
    rep(i, n) cin >> a[i];

    ll old_it = 0;
    ll old = a[0];

    for (ll i = k + 1; i <= n; ++i) {
        ll latest = a[i - 1];
        if (old < latest) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        old_it++;
        old = a[old_it];
    }

    return 0;
}

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

int main () {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  ll sum = 0;
  rep(i,n) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a.begin(), a.end());

  int l = -1;
  int r = n;
  while(r - l > 1) {
    int i = (l + r) / 2;

    if(k - a[i] <= 0) {
      r = i;
      continue;
    }

    vector<int> can(k,0);
    can[0] = 1;

    for(int j = 0; j < n; j++) {
      if(j == i) continue;
      for(int l = k - 1; l >= 0; l--) {
        if(can[l] && l + a[j] < k) can[l+a[j]] = 1;
      }
    }

    bool nec = false;
    for(int j = k - a[i]; j < k; j++) {
      if(can[j]) nec = true;
    }
    if(nec) {
      r = i;
    } else {
      l = i;
    }
  }

  cout << r << endl;
  return 0;
}


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

int main()
{
  int N,X,Y;
  cin >> N >> X >> Y;

  vector<int> cnt(N,0);
  FOR(i,1,N+1){
    FOR(j,i+1,N+1){
      if(i<=X&&j<=X){
        cnt[j-i]++;
      }else if(i<=X&&j>X&&j<Y){
        cnt[min(X-i+j-X,X-i+1+Y-j)]++;
      }else if(i<=X&&j>=Y){
        cnt[X-i+1+j-Y]++;
      }else if(i>X&&i<Y&&j<Y){
        cnt[min(j-i,i-X+1+Y-j)]++;
      }else if(i>X&&i<Y&&j>=Y){
        cnt[min(j-Y+Y-i,j-Y+1+i-X)]++;
      }else if(i>=Y){
        cnt[j-i]++;
      }
    }
  }

  FOR(i,1,N){
    cout << cnt[i] << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

#define LL long long
const int maxn = 100000 + 100;
int n;
int t[maxn], x[maxn], y[maxn];

int main() {
    #ifdef LOCAL
        freopen("test.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    #endif // LOCAL
    ios::sync_with_stdio(false);

    while(scanf("%d", &n) != EOF) {
        bool flag = true;
        x[0] = y[0] = t[0] = 0;
        for(int i = 1; i <= n; ++i) {
            scanf("%d%d%d", &t[i], &x[i], &y[i]);
        }
        for(int i = 1; i <= n; ++i) {
            int tmp = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
            int tt = t[i] - t[i - 1];
            if(tmp > tt || tmp % 2 != tt % 2) {
                flag = false;
                break;
            }
        }
        if(flag) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }

    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int a[100005]; 
int main(int argc, char** argv) {
	int num;
	cin>>num;
	for(int i=1;i<=num;i++){
		int  x;
		cin>>x;
		a[x]=i;
	}
	for(int i=1;i<num;i++){
		cout<<a[i]<<" ";
	}
	cout<<a[num]<<endl;
	return 0;
}

Measured memory_bytes: 1152