akhauriyash/Code-Regression huggingface dataset:
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;

ll n,y;

int main() {
    std::cin >> n>>y;
    y/=1000;
    for (int i = 0; i <= n; i++) {
        if(10*i + (n-i) <= y && y <= 10*i + 5*(n-i) ){
            ll tmp_y = y- 10*i;
            ll tmp_n = n- i;
            ll tmp_b = (tmp_y-tmp_n)/4;
            ll tmp_c = tmp_n - tmp_b;
            
            if(i + tmp_b + tmp_c == n && 10*i + 5*tmp_b + tmp_c == y && tmp_b>=0 && tmp_c >=0){
                std::cout << i<<" "<<tmp_b<<" "<<tmp_c << std::endl;
                return 0;
            }
        }
    }
    std::cout << -1<<" "<<-1<<" "<<-1 << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

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

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

int main(){
    int A,B,C,X,cnt=0;
    cin>>A>>B>>C>>X;
    for(int i=0;i<=A;i++){
        for(int j=0;j<=B;j++){
            for(int k=0;k<=C;k++){
                if(i*500+j*100+k*50==X)
                    cnt++;
            }
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i;
  double a, s;

  while(scanf("%lf", &a) != EOF){
    s = a;
    for(i = 0; i < 9; i++){
      if(i % 2 == 0){
	a *= 2.0;
      }else{
	a /= 3.0;
      }
      s += a;
    }
    printf("%f\n", s);
  }
  return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string T;
    cin >> T;
    int k=0;
    while(1){
        k=T.find("?");
        if(k==string::npos){
            break;
        }
        else{
            T.replace(k, 1, "D");
        }
    }
    cout << T <<endl;
    return 0;
}

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

using namespace std;

const int MX = 300000, md = 1000000007;

void add(int& a, int b) {
	a += b;
	if (a >= md) a -= md;
}

char s[MX];
int f[2][4][4], g[2][4][4];

int main() {
	ignore = scanf("%s", s);
	
	int n = strlen(s);
	
	if (s[0] == '0' || s[0] == '?') f[0][1][0] = 1;
	if (s[0] == '1' || s[0] == '?') g[0][1][0] = 1;
	
	int ci = 0, li = 1;
	for (int i = 1; i < n; i++) {
		ci ^= 1;
		li ^= 1;
		
		memset(f[ci], 0, sizeof f[0]);
		memset(g[ci], 0, sizeof g[0]);
		
		if (s[i] == '0' || s[i] == '?') {
			for (int i = 0; i < 4; i++)
				for (int j = 0; j < 4; j++) {
					if (i + j == 0) {
						add(f[ci][1][0], f[li][0][0]);
						add(f[ci][1][0], g[li][0][0]);
						
						continue;
					}
					
					add(g[ci][i][j + 1 - (j > 1 ? 2 : 0)], g[li][i][j]);
					if (j == 0) add(f[ci][i + 1 - (i > 1 ? 2 : 0)][j], f[li][i][j]);
					else add(f[ci][i][j - 1], f[li][i][j]);
				}
		}
		
		if (s[i] == '1' || s[i] == '?') {
			for (int i = 0; i < 4; i++)
				for (int j = 0; j < 4; j++) {
					if (i + j == 0) {
						// TODO
						
						continue;
					}
					
					if (j == 0) add(g[ci][i + 1 - (i == 3 ? 2 : 0)][j], g[li][i][j]);
					else add(g[ci][i][j - 1], g[li][i][j]);
					
					if (i == 1 && j == 1) {
						add(g[ci][1][0], f[li][i][j]);
						
						continue;
					}
					
					if (j == 0) add(f[ci][i][1], f[li][i][j]);
					else add(f[ci][i - 1][j], f[li][i][j]);
				}
		}
	}
	
	int ans = 0;
	for (int i = 0; i < 4; i++)
		for (int j = 0; j < i; j++)
			ans = (ans + (long long)f[ci][j][i] + g[ci][i][j]) % md;
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<pair<ll, ll>> p(n);
    for(int i = 0; i < n; ++i){
        ll pi;
        cin >> pi;
        p.at(i) = make_pair(pi, i);
    }
    sort(p.begin(), p.end(), greater<pair<ll, ll>>());

    multiset<ll> s;
    s.insert(n); s.insert(n);
    s.insert(-1); s.insert(-1);
    ll ans = 0;
    for(int i = 0; i < n; ++i){
        const ll idx = p.at(i).second;
        const ll val = p.at(i).first;
        cerr << val << ' ' << idx << endl;

        const auto rmaxit = s.lower_bound(idx);

        // 1 番大きい値を左側に置く場合
        {
            auto lmaxit = rmaxit; lmaxit--;
            const ll lmaxidx = *lmaxit;
            const ll lmaxidx2 = *(--lmaxit);
            // cerr << "  " << lmaxidx << ' ' << lmaxidx2 << ' ' << *rmaxit << ' ' << idx << endl;
            ans += val * (lmaxidx - lmaxidx2) * (*rmaxit - idx);
        }

        // 1 番大きい値を右側に置く場合
        {
            auto rmaxit2 = rmaxit; rmaxit2++;
            auto lmaxit = rmaxit; lmaxit--;
            // cerr << "  " << idx << ' ' << *lmaxit << ' ' << *rmaxit2 << ' ' << *rmaxit << endl;
            ans += val * (idx - *lmaxit) * (*rmaxit2 - *rmaxit);
        }

        s.insert(idx);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
import sys
import math
import itertools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


n = ni()
a = na()

ans = a[0]

for ai in a[1:]:
    ans = gcd(ans, ai)
print(ans)

Measured memory_bytes: 14168
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	map<ll, int> mp;
	bool flag = true;
	rep(i, n) {
		cin >> a[i];
		mp[a[i]]++;
		if (mp[a[i]] != 1) flag = false;
	}
	if (flag) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

typedef long long ll;

int n, m, u, v;
int a[100050], fa[100050];

int find(int X) {
  if (fa[X] == X) {
    return X;
  } else {
    return fa[X] = find(fa[X]);
  }
}

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

  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    fa[find(u)] = find(v);
  }

  int res = 0;
  for (int i = 1; i <= n; i++) {
    if (find(i) == find(a[i])) {
      res++;
    }
  }

  cout << res << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define INF (1LL << 60)
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 16;

int a[MAX_N][MAX_N];
ll cost[1 << MAX_N];
ll dp[1 << MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n){
        rep(j,n){
            cin >> a[i][j];
        }
    }
    rep(i,1 << n){
        vi vec;
        rep(j,n){
            if(i >> j & 1){
                vec.pb(j);
            }
        }
        rep(j,len(vec)){
            srep(k,j+1,len(vec)){
                cost[i] += a[vec[j]][vec[k]];
            }
        }
    }
    rep(i,(1 << n)){
        dp[i] = -INF;
    }
    dp[(1 << n)-1] = 0;
    rrep(i,1 << n){
        for(int j=i;j>0;j=(j-1)&i){
            cmx(dp[i^j], dp[i]+cost[j]);
        }
    }
    cout << dp[0] << "\n";
    return 0;
}

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

using namespace std;

double EPS = 1e-10;
const double PI = acos(-1);

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }

  point operator / (double d){
    return point(x/d,y/d);
  }
  
  bool operator == ( const point &p ) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

struct segment{
  point a,b;
};

bool cmp_x(const point& p, const point& q){
  if(p.x != q.x)return p.x<q.x;
  return p.y < q.y;
}

double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}

double cross(point a, point b) {
  return (a.x * b.y - a.y * b.x);
}

double vec_abs(point a){
  return sqrt(a.x*a.x+a.y*a.y);
}

double dist(point a,point b){
  return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}

int ccw(point p0, point p1, point p2){
  point a = p1 - p0;
  point b = p2 - p0;
  if(cross(a,b)>EPS)return +1;
  if(cross(a,b)<EPS)return -1;
  if(dot(a,b)<-EPS)return +2;
  if(a.x*a.x+a.y*a.y<b.x*b.x+b.y*b.y)return -2;
  return 0;
}

vector<point>convex_hull(point* ps, int n){
  sort(ps,ps+n,cmp_x);
  int k=0;
  vector<point>qs(n*2);
  
  for(int i=0;i<n;i++){
    while(k>1&&cross(qs[k-1]-qs[k-2],ps[i]-qs[k-1])<0)k--;
    qs[k++]=ps[i];
  }
  
  for(int i=n-2,t=k;i>=0;i--){
    while(k>t&&cross(qs[k-1]-qs[k-2],ps[i]-qs[k-1])<0)k--;
    qs[k++]=ps[i];
  }
  qs.resize(k-1);
  return qs;
}

double areaPol(point* ps, int n){
  vector<point>t=convex_hull(ps,n);
  t.push_back(t[0]);
  int tsz=t.size();
  double area=0;
  for(int i=0;i<tsz-1;i++){
    area+=(t[i].x-t[i+1].x)*(t[i].y+t[i+1].y);
  }
  return abs(area)/2.0;
}


int main(void){
  point p[21];
  int n=0;
  double x,y;
  char k;

  while(cin>>x>>k>>y){
if(cin.eof())break;
    p[n].x = x;
    p[n].y = y;
    n++;
 }

  printf("%.6f\n",areaPol(p,n));

  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        String s = sc.next();

        if (s.length() <= k) {
            System.out.println(s);
        } else {
            String sub = s.substring(0,k);
            System.out.println(sub + "...");
        }

    }
}


Measured memory_bytes: 38724
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, k;
    cin >> n >> k;
    int a[n];
    int dp[n];
    for (int i = 0; i != n; ++i)
    {
        dp[i] = 1000000000;
        cin>>a[i];
    }
    dp[0] = 0;
    for (int i = 1; i < n; i++)
        for (int j = max(0, i - k); j != i; j++)
        dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
    cout << dp[n - 1];
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}


int main(){
	ll n;
	cin >> n;
	for(ll i=1;i<=3500;i++){
		for(ll j=1;j<=3500;j++){
			if(4*i*j-(n*i+n*j)==0)continue;
			if((n*i*j)%(4*i*j-(n*i+n*j))==0){
				if((n*i*j)/(4*i*j-(n*i+n*j))>0){
				cout << i << " " << j << " "  << (n*i*j)/(4*i*j-(n*i+n*j)) << endl;
				return 0;
				}
			}
		}
	}

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=a-1;i>=b;i--)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.14159265358979323
#define sz(a) (int)((a).size())
#define FOR(i,j,k,l) for(ll i=j;i<k;i+=l)


void Fast_IO() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   #ifndef ONLINE_JUDGE
   freopen("in.txt","r",stdin);
   freopen("out.txt","w",stdout); 
   #endif
} 

int main(){
   Fast_IO();
   ll x,y;
   cin>>x>>y;
   ll yes=0;
   f(i,0,x+1){
      if(2*i +4*(x-i)==y) yes=1;
   }
   if(yes==1) cout<<"Yes";
   else cout<<"No";
   
}




Measured memory_bytes: 3632
def eucly(arr) #[max, min]
   ans = arr[0] % arr[1]
   if ans == 0
	  return arr[1]
   else
	  eucly([arr[1], ans])
   end
end

while line = gets
   num = line.split(' ').map(&:to_i)
   arr=[]
   if num[0] < num[1]
	  arr[0], arr[1] = num[1], num[0]
   else
	  arr = num
   end
   gcd = eucly(arr)
   lcm = num[0]*num[1]/gcd
   print gcd.to_s + " " + lcm.to_s + "\n"
end

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

#define INF 1010101010

int N;
int h[114514];

int satorina[114514];

int asumikana(int pos) {
	int kitaeri, kugyu;
	if (pos == N) return 0;
	if (pos > N) return INF;
	if (satorina[pos]) return ~satorina[pos];

	kitaeri = asumikana(pos + 1) + abs(h[pos] - h[pos + 1]);
	kugyu = asumikana(pos + 2) + abs(h[pos] - h[pos + 2]);
	if (kugyu < kitaeri) kitaeri = kugyu;

	return ~(satorina[pos] = ~kitaeri);
}

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &h[i]) != 1) return 1;
	}
	printf("%d\n", asumikana(1));
	return 0;
}


Measured memory_bytes: 8664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  vector<int> D(N);
  rep(i, N) cin >> D[i];
  
  if(D[0] != 0) {
    cout << 0 << endl;
    return 0;
  }
  
  sort(all(D));
  
  int ans = 1;
  vector<int> num(N, 0);
  
  
  num[D[0]]++;
  rep(i, N) {
    if(i == 0) continue;
    if(D[i] == 0 || num[D[i]-1] == 0) {
      cout << 0 << endl;
      return 0;
    }
    num[D[i]]++;
    ans *= num[D[i]-1];
    ans %= 998244353;
  }
  cout << ans << endl;
    
  
}

Measured memory_bytes: 1792
import sys
N=int(input())
L=list(map(int,input().split()))
L=list(map(int,list(reversed(L))))
for i in range(1,N):
  if L[i]>L[i-1]+1:
    print("No")
    sys.exit()
  elif L[i]==L[i-1]+1:
    L[i]=L[i]-1
print("Yes")

Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ar[200005];
int main()
{
  ll n, a, b,ok=0,sum=0,k;
  cin>>n>>k;
  for(int i=0; i<n; i++)
  {
   cin>>ar[i];
  }
  sort(ar,ar+n);
  for(int i=0; i<n-k; i++)
  {
  sum=sum+ar[i];
  }
 cout<<sum<<endl;

}

Measured memory_bytes: 1024
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

s = ns()
t = ns()

i = 0

while i < 101:
    s = s[-1] + s[:-1]
    if s == t:
        print('Yes')
        exit()
    i += 1
print('No')

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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)
#define SORT(a) sort(ALL(a))
#define RSORT(a, type) sort(ALL(a),greater<type>())
#define MAPIN(a,i,j) (a).insert(make_pair(i,j))
#define PREC(n) setprecision(n)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef unsigned long long lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > Matrix;

int main() {
    vll p,q;
    ll i,j,k,n,ans;

    cin>>n;

    SIZE(p,n);
    SIZE(q,n);
    rep(i,n){
        cin>>p[i];
    }
    rep(i,n-1){
        q[i+1]=p[i+1]-p[i];
    }
    ans=1;
    q[0]=0;
    rep(i,n-1){
        q[i+1]=q[i+1]+q[i];
    }
    k=0;
    repj(i,1,n){
        if(q[i]<k){
            ans++;
            k=q[i];
        }
    }
    cout<<ans;
    
	return 0;
}


Measured memory_bytes: 3328
/*Lower_Rating*/
/*AGC036 F Square Constraints*/
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;

#define LL long long
#define MAXN 500
#define Pr pair<int,int>
#define X first
#define Y second
#define INF 1000000000
#define mem(x,p) memset(x,p,sizeof(x))

LL read(){
  LL x=0,F=1;char c=getchar();
  while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
  while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
  return x*F;
}
LL MOD;
int add(int x,int y){return (x+y>=MOD)?x+y-MOD:x+y;}
int dec(int x,int y){return (x-y<0)?x-y+MOD:x-y;}
int mul(int x,int y){return 1LL*x*y%MOD;}

LL S;
LL a,b,c,d;
int main()
{
    //freopen("triangle.in","r",stdin);
    //freopen("triangle.out","w",stdout);
    S=read();
    c=INF,a=S/c+(S%c!=0),b=1LL*a*c-S,d=1;
    printf("%lld %lld %lld %lld %lld %lld\n",0,0,a,b,d,c);
}


Measured memory_bytes: 128
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

	in := func() int {
		sc.Scan()
		i, _ := strconv.Atoi(sc.Text())
		return i
	}

	n, k := in(), in()
	a := make([]int, n)

	for i := range a {
		a[i] = in()
	}

	sort.Slice(a, func(i, j int) bool {
		return a[i] < a[j]
	})

	cst := 0
	for i := 0; i < k; i++ {
		cst += a[i]
	}

	fmt.Println(cst)
}


Measured memory_bytes: 1820
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n, k;
    cin >> n >> k;
    vint b(n);
    rep(i, k)
    {
        int d;
        cin >> d;
        rep(j, d)
        {
            int a;
            cin >> a;
            b[a - 1]++;
        }
    }
    int ans = 0;
    rep(i, n)
    {
        if (b[i] == 0)
            ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vpll> vvpll;
typedef unordered_map<ll, ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ts ll t; in(t) while (t--) solve();
#define ks ll t; in(t) FOR(i, 1, t+1) out("Case #" << i << ": " << solve());
#define endl '\n'
#define ln cout << endl;
#define in(x) cin >> x;
#define out(x) cout << x << endl;
#define flush cout << flush;
#define reset(a, b) memset(a, b, sizeof(a));
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define FORI(i, a, b, c) for (ll i = a; i < b; i += c)
#define FORD(i, a, b) for (ll i = a; i > b; --i)
#define FOREACH(it, v, r) for (auto it = v.begin() + r; it != v.end(); it++)
#define FORALL(it, v) for (auto it : v)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define vin(v, x) vll v(x); FOR(i, 0, x) in(v[i])
#define all(v) v.begin(), v.end()
#define allr(v, r) v.begin(), v.begin() + r
#define showv(v) FORALL(it, v) cout << it << ' '; ln
#define printv(v) FORALL(it, v) out(it)
#define show2d(v) FORALL(it, v) { FORALL(j, it) cout << j << ' '; ln}
#define showm(v) FORALL(it, v) cout << it.F << ": " << it.S << ' '; ln
#define sortv(v) sort(all(v));
#define revv(v) reverse(all(v));
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define gcd __gcd
#define checkbit(n, i) (n >> i) & 1               // check ith bit
#define bitcount __builtin_popcount               // count set bits
#define firstbitindex __builtin_ctz               // count trailing zeros
#define lastbitindex __builtin_clz                // count leading zeros
#define bitparity __builtin_parity                // check set bits are even or odd
#define findv(v, x) (find(all(v), x) != v.end())  // find in a vector
#define findsm(u, x) (u.find(x) != u.end())       // find in a set / map
#define findstr(s, x) (s.find(x) != string::npos) // find in a string
#define sz(a) a.size()
#define precise(x) cout << fixed << setprecision(x);

const ll MAXN = 2e5, MOD = 998244353, SIZE = 2e7;//, INF = 0x7f7f7f7f7f7f7f7f;
const double EPS = 1e-9, PI = acos(-1);
const int INFi = 0x7f7f7f7f;

//<<------Declare Variables Here----->>//
ll n, x;

//<<-----Implement Functions Here---->>//
void solve()
{
    in(n)
    vin(a, n)
    FOR(i, 0, n)
        x ^= a[i];
    FOR(i, 0, n)
        a[i] ^= x;
    showv(a)
}

//<<----------Start of Main---------->>//
int main()
{
    fastio
    //ts
    solve();
    return 0;
}

Measured memory_bytes: 4768
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;
	public static final long HUGE_NUM = 99999999999999999L;
	public static final double EPS = 0.000000001;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
				int N = Integer.parseInt(br.readLine());
				String input_str[] = br.readLine().split("\\s+");

				StringBuilder ans = new StringBuilder();
				ans.append(input_str[0]);

				String pre = input_str[0];

				for(int i = 1; i < input_str.length; i++){

					if(input_str[i].equals(pre))continue;

					ans.append(" ").append(input_str[i]);
					pre = input_str[i];
				}

				System.out.println(ans.toString());

			} catch (NumberFormatException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
		}
}

class UTIL{

	//文字が半角数字か判定する関数
	public static boolean isNumber(String tmp_str){

		if(tmp_str == null || tmp_str.length() == 0){

			return false;
		}

		Pattern pattern = Pattern.compile("\\A[0-9]+\\z");
		Matcher matcher = pattern.matcher(tmp_str);
		return matcher.matches();
	}
}


Measured memory_bytes: 49952
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;
 
//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;
 
//少数点表示
//cout << std::fixed << std::setprecision(14) << 値
 
int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );

    string n;
    cin >> n;
    int len = n.length();
    int count = 0;
    rep(i,len){
        count += n[i]-'0';
    }
    
    if(count%9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3736
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M = map(int, input().split())
uf = UnionFind(N)

#H = list(map(int, input().split()))

#AB = [tuple(map(int, input().split())) for i in range(M)]

#丸暗記。隣接リストの初期化
graph = [[] for _ in range(N)]

for _ in range(M):
  a, b = map(int, input().split())
  uf.union(a-1, b-1)

print(uf.group_count()-1)



Measured memory_bytes: 18868
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    lm = []
    mp = dict()
    c = 0
    for i in range(n):
        s, t = rl()
        lm.append((s, int(t)))
    x = input()
    c = 0
    for i in range(n):
        if lm[i][0] == x:
            c = i
            break
    ans = 0
    for i in range(c+1, n):
        ans += lm[i][1]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.Scanner;

/**
 * @author author
 *
 */
public class Main {

  /**
   * @param args
   */
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    Double w = Double.parseDouble(sc.next());
    Double h = Double.parseDouble(sc.next());
    Double x = Double.parseDouble(sc.next());
    Double y = Double.parseDouble(sc.next());

    int numberOfLine = 0;
    Double area = (w * h) / 2;

    if (x * 2 == w && y * 2 == h) {
      numberOfLine = 1;
    }
    System.out.println(area + " " + numberOfLine);

  }

}


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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
#define PI 3.1415926536
typedef long long ll;
typedef pair<int, int> P;

int main() {
	int N;
	cin >> N;
	vector<int> A(N), B(N);
	rep(i, N) {
		cin >> A[i] >> B[i];
	}
	ll ans = 0;
	reprev(i, N) {
		ans += (B[i] - (((ll)A[i] + ans) % B[i])) % B[i];
	}
	cout << ans << endl;

	return 0;
}

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

int ar[200005];
map<ll,ll>cnt;

int main()
{
    ll n, q, r, x , i, sum=0, nw=0;

    cin>>n;

    for(i=0; i<n; i++)
    {
        cin>>ar[i];
        sum+=ar[i];
        cnt[ar[i]]++;
    }

    cin>>q;

    while(q--)
    {
        cin>>r>>x;
        nw=cnt[r]*(x-r);
        sum+=nw;
        cnt[x]+=cnt[r];
        //cout<<x<<" "<<cnt[x]<<endl;
        cnt[r]=0;
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 9744
#include <iostream>

using namespace std;

int tominutes(const int h) { return h * 60; }

int main(const int argc, const char **argv)
{
  int h1, m1, h2, m2, k;

  cin >> h1 >> m1 >> h2 >> m2 >> k;

  cout << (tominutes(h2) + m2) - (tominutes(h1) + m1) - k << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 998244353;


int main() {
    string t;
    cin >> t;
    int n = t.size();
    int ans = 0;
    rep(i, n) {
        if (t[i] == '?') t[i] = 'D';
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3732
def lmn(a,b):
    ans=a*b
    while b>0:
        tmp=b
        b=a%b
        a=tmp
    return ans//a

A,B,C,D=map(int,input().split())
print((B-A+1)-(B//C+B//D-B//lmn(C,D))+((A-1)//C+(A-1)//D-(A-1)//lmn(C,D)))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=100005;
int read(){
	int x=0;
	char ch=getchar();
	while (!isdigit(ch))
		ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x;
}
int n,m;
vector <int> e[N];
int vis[N];
LL ans=0;
int cnt[3],cnte=0;
bool dfs(int x,int c){
	cnt[vis[x]=c]++;
	bool res=1;
	for (auto t : e[x]){
		int y=t>>1,z=t&1;
		if (!z)
			cnte++;
		int _c=(c+(z?1:-1)+3)%3;
		if (~vis[y])
			res&=vis[y]==_c;
		else
			res&=dfs(y,_c);
	}
	return res;
}
LL solve(int x){
	cnte=0;
	memset(cnt,0,sizeof cnt);
	if (!dfs(x,0)){
		int s=cnt[0]+cnt[1]+cnt[2];
		return 1LL*s*s;
	}
	if (!cnt[0]||!cnt[1]||!cnt[2])
		return cnte;
	return 1LL*cnt[0]*cnt[1]+1LL*cnt[1]*cnt[2]+1LL*cnt[2]*cnt[0];
}
int main(){
	n=read(),m=read();
	for (int i=1;i<=n;i++)
		e[i].clear();
	for (int i=1;i<=m;i++){
		int a=read(),b=read();
		e[a].push_back(b<<1|1);
		e[b].push_back(a<<1);
	}
	memset(vis,-1,sizeof vis);
	for (int i=1;i<=n;i++)
		if (!~vis[i])
			ans+=solve(i);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 10752
#include <stdio.h>

int main()
{
  int N;
  
  scanf("%d",&N);
  
  while(N>=10)
    N%=10;
  
  if(N==3)
    printf("bon");
  else if(N==0 || N==1 || N==6 ||N==8)
    printf("pon");
  else
    printf("hon");
}

Measured memory_bytes: 1732
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>

int main() {
  int A, B;
  scanf("%d %d", &A, &B);

  printf("%d\n", std::max({A+B, A-B, A*B}));
}


Measured memory_bytes: 128
// Justice will be served
// شهید حاج قاسم سلیمانی

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

#define all(x) x.begin() , x.end()

#define PB push_back
#define F first
#define S second
#define _sz(x) (int)x.size()

#define debug(x) cerr << #x << " = " << x << endl

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

const int MAX_N = -1 ;
const int inf = 2e9 + 19 ;

int main() {
        ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;
        ll a ;
        cin >> a ;
        cout << a * a ;
        return (0) ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;

int main(){
    int n;cin>>n;
    double sum=0,ave;
    double x[n],ans=0;
    for (int i = 0; i < n; i++)
    {
        cin >>x[i];
        sum += x[i];
    }
    ave = round(sum/n);
    
    for (int i = 0; i < n; i++)
    {
        ans += (x[i]-ave)*(x[i]-ave);
    }
    cout<<ans<<endl;
    
    
    return 0;
}

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

using namespace std;

int main()
{
    long long int n;
    cin>>n;
    string s;
    cin>>s;
    long long int c=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')
            c++;
    }
    if(c==n)
        cout<<"0";
    else
    {
        long long int d=0;
        for(int i=0;i<c;i++)
        {
            if(s[i]=='R')
                d++;
        }
        cout<<c-d;

    }
    return 0;
}


Measured memory_bytes: 3748
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	cin >> s;
	bool ans = true;
	if (s[2] != s[3]) ans = false;
	if (s[4] != s[5]) ans = false;
	cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
N = int(input())
dp = [[0 for i in range(3)] for j in range(N+1)]

for i in range(1, N+1):
    hapiness = list(map(int, input().split()))
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i][j] = max(dp[i][j], dp[i-1][k] + hapiness[k])

print(max(dp[N][0], dp[N][1], dp[N][2]))

Measured memory_bytes: 59484
#include <iostream>
#include <iomanip>
#include <set>

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

using namespace std;

int main(void)
{
	int N, K, T, U, V, L;
	int time = 0;
	int carrot = 0;
	int v_run = 0;
	double result;
	cin >> N >> K >> T >> U >> V >> L;
	set<int> D;
	rep(i, N){
		int d;
		cin >> d;
		D.insert(d);
	}
	//毎ループ地点iにおいて振る舞いを考える
	rep(i, L){
		if (time > 0){
			if (D.find(i) != D.end()){
				if (carrot == K){
					time = V*T;
				}else{
					carrot++;
				}
			}
			v_run++;
			time--;
		}else if(time == 0){
			if (D.find(i) != D.end()){
				v_run++;
				time = V*T - 1;
			}else if(carrot > 0){
				carrot--;
				v_run++;
				time = V*T - 1;
			}
		}
	}
	result = (double)v_run / V + (double)(L - v_run) / U;
	cout << fixed << setprecision(9) << result << endl;
	return 0;
}


Measured memory_bytes: 3296
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin>>n;
    string s[n];
    int t[n];
    for(int i=0;i<n;i++){
        cin>>s[i]>>t[i];
    }
    string x;
    cin>>x;
    ll ans=0;
    for(int i=0;i<n;i++){
        if(s[i]==x){
            for(int j=i+1;j<n;j++){
                ans+=t[j];
            }
            break;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main()
{
 	string a,b;
  cin>>a>>b;
  int res=0;
  if(a[0]==b[0])res++;
  
  if(a[1]==b[1])res++;
  
  if(a[2]==b[2])res++;
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ii pair<ll, ll>
#define vi vector<ll>
#define vs vector<string>
#define si set<ll>
#define endl "\n"
#define pb(a) push_back(a)
#define x first
#define y second
//g++-9 -std=c++11 -Wall -Wextra -pedantic-errors main.cpp -o main
const ll ms = 1e4 + 5, base = 31, mod = 1e9 + 9;
using namespace std;

int main(){
	ios::sync_with_stdio(false), cin.tie(0);
	
	int N, M;
	cin >> N >> M;
	
	if (M == N)
		cout << "Yes";
	else
		cout << "No";
	
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.Char
import Data.Function
import Data.List
import Text.Read
import Text.ParserCombinators.ReadPrec

newtype Pair a b = Pair { getPair :: (a, b) }

instance (Read a, Read b) => Read (Pair a b) where
  readPrec = Pair `dot` (,) <$> readPrec <* get <*> readPrec

instance (Show a, Show b) => Show (Pair a b) where
  show (Pair (a, b)) = show a ++ " " ++ show b

dot :: (c -> d) -> (a -> b -> c) -> a -> b -> d
dot = ((.).(.))

main :: IO ()
main = do
  n <- readLn
  print $ solve n

solve :: Int -> Int
solve n
  | r == 0    = 0
  | otherwise = 1000 - r
 where 
  r = n `rem` 1000


Measured memory_bytes: 3912
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>

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

	std::cin >> n >> a >> b;

	bool turn = false;

	while (true) {
		if (a + 1 == b) {
			break;
		}
		if (!turn) {
			a++;
			turn = true;
		}
		else {
			b--;
			turn = false;
		}
	}
	//std::cout << a << " " << b << std::endl;
	if (!turn) {
		std::cout << "Borys" << std::endl;
	}
	else {
		std::cout << "Alice" << std::endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include<iomanip>
using namespace std;

int main()
{
    int N;cin>>N;
    vector<long long>L(N);
    for(int i=0;i<N;i++)cin>>L[i];
    sort(L.begin(),L.end());

    long long sum=0;


    for(int i=0;i<N-2;i++)
    {
        for(int j=i+1;j<N-1;j++)
        {
            int k = lower_bound(L.begin(),L.end(),L[i]+L[j])-L.begin();
            sum+=k -(j+1);
        }
    }
    
    cout<<sum<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  string s;
  cin>>s;
  vecint cnt(26);
  REP(i,4) {
    ++cnt[s[i] - 'A'];
  }
  int ok=0;
  REP(i,26) {
    if (cnt[i]==2) ++ok;
  }
  if (ok==2) {
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
icase=0
if icase==0:
    x,y,z,k=map(int,input().split())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    c=list(map(int,input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

kk=1

ix=0
iy=0
iz=0
ss=[]
s=a[ix]+b[iy]+c[iz]

xyz=[]
xyz.append((ix+1,iy,iz))
xyz.append((ix,iy+1,iz))
xyz.append((ix,iy,iz+1))

#print(ix,iy,iz,s)
#print(xyz)
ss.append(s)
while kk<k:
    kk+=1
    s1=0
    for ix,iy,iz in xyz:
        s2=a[ix]+b[iy]+c[iz]
        if s2>s1:
            s1=s2
            ixx,iyy,izz=ix,iy,iz
#    print("1:",ixx,iyy,izz,s2)
    xyz.remove((ixx,iyy,izz))
    if ixx<x-1 and ((ixx+1,iyy,izz) not in xyz): 
        xyz.append((ixx+1,iyy,izz))
    if iyy<y-1 and ((ixx,iyy+1,izz) not in xyz): 
        xyz.append((ixx,iyy+1,izz))
    if izz<z-1 and ((ixx,iyy,izz+1) not in xyz): 
        xyz.append((ixx,iyy,izz+1))
#    print(ixx,iyy,izz,s1)
#    print(xyz)
    ss.append(s1)

for kk in range(k):
    print(ss[kk])        


Measured memory_bytes: 70372
import sys
input = sys.stdin.readline


def main():
    S = input()[:-1]

    ans = 0
    cnt = 0
    for i in range(len(S)):
        if S[i:i+1] in 'ACGT':
            cnt += 1
        else:
            ans = max(ans, cnt)
            cnt = 0
    ans = max(ans, cnt)
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
def main():
    import sys

    input = sys.stdin.readline
    a, b, c, d = map(int, input().split())
    f = -1
    for i in range(1000):
        if c - b <= 0:
            f = "T"
            break
        else:
            c = (c - b)
        if a - d <= 0:
            f = "A"
            break
        else:
            a = (a - d)
    if f == "T":
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9200
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
sa = sum(A)
sb = sum(B)
if sa > sb:
    print('No')
    exit()
z = sb - sa

c = d = 0
for a,b in zip(A,B):
    if a > b:
        d += a-b
    elif a < b:
        c += (b-a+1)//2
        if (b-a)%2:
            d += 1

if c > z or d > z:
    print('No')
else:
    print('Yes' if (z-c)*2 == z-d else 'No')


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

#define         ull             unsigned long long
#define         ll              long long
#define         pi              acos(-1.0)
#define         asort(arr,n)    sort(arr,arr+n);
#define         dsort(arr,n)    sort(arr, arr+n, greater<int>());
#define         faster()        ios::sync_with_stdio(false);cin.tie(0);


#define         min3(a,b,c)     min(a,min(b,c))
#define         max3(a,b,c)     max(a,max(b,c))
#define         min4(a,b,c,d)   min(min(a,b),min(c,d))
#define         max4(a,b,c,d)   max(max(a,b),max(c,d))
#define         max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define         min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))


using namespace std;
int main()
{
    faster()
    int n,ans,ans1;
    while(scanf("%d",&n)==1)
    {
        ans = 0;
        ans1 = 0;
        ans = sqrt(n);
        ans1 = int(ans);
        if(ans = ans1)
        {
            cout<<ans*ans<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	std::vector<int> a(4);
	for(int i = 0; i < 4; i++) scanf("%d", &a[i]);
	sort(begin(a), end(a));
	
	if(a == std::vector<int>{1, 4, 7, 9}) printf("YES\n");
	else printf("NO\n");	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int x;
	ll ans = 0;
	cin >> x;
	ans += x/500 * 1000;
	x = x % 500;
	ans += x/5 * 5;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
    string s;
    cin>> s;
    int cnt = 0, mx = 0;
    rep(i, 0, s.size()){
        if(s[i] == 'R')
            cnt++;
        else{
            mx = max(mx, cnt);
            cnt = 0;
        }
    }
    mx = max(mx, cnt);
    cout<< mx<< "\n";
    return 0;
}
//Counting problems: Sometimes easier to find complement of the answer
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


Measured memory_bytes: 3636
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  bool flag=false;
  bool flag2=false;
  cin>>str;
  for(int i=0;i<str.size();i++){
    if(str[i]=='C')flag=true;
    if(str[i]=='F'&&flag){flag2=true;break;}
  }
  if(flag2)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
#define int long long
signed main(signed argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,q;
    cin>>n>>q;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    rep(i,q){
        int l,r;
        cin>>l>>r;
        cout<<upper_bound(a.begin(),a.end(),r)-lower_bound(a.begin(),a.end(),l)<<endl;
    }
}



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

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 ***/

int main(){
    double pai=3.141592653589;
    int a;
    long long s=0;
    scanf("%d",&a);
    vector<long>ar(a);
    for(auto&e:ar){
        scanf("%ld",&e);
    }
    sort(ar.begin(),ar.end());
    //s=accumulate(ar.begin(),ar.end(),0);
    for(int i=0;i<a;i++){
        s+=ar[i];
    }
    printf("%ld %ld %lld\n",ar[0],ar[a-1],s);
    return 0;
}

Measured memory_bytes: 1264
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
output = 0
tmp = -10
for i in range(N):
    output += B[A[i] - 1]
    if A[i] - tmp == 1:
        output += C[A[i] - 2]
    tmp = A[i]

print(output)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define all(a) (a.begin(),a.end())

using ll = long long;
using namespace std;
template<typename... Args>
void read(Args&... args)
{((cin >> args), ...);}

template<typename... Args>
void write(Args... args)
{((cout << args << " "), ...);}

template<typename... Args>
void writeln(Args... args)
{((cout << args << " "), ...); cout << "\n";}

template<typename T>
void read(vector<T> &a)
{for (auto &ele : a) cin >> ele;}

template<typename T>
void writeln(vector<T> &a)
{for (auto &ele : a) cout << ele << ' '; cout << "\n";}

const pii dxy[] = {{ -1, 0}, {1, 0}, {0, -1}, {0, 1}};
const pii fxy[] = {{ -1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, { -1, -1}, { -1, 1}, {1, -1}};

int dp[100005];

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0);
	ios::sync_with_stdio(false);
//	int t;cin >> t;while(t--) solve();
	int n, k;
	read(n, k);
	vector<int> a(n);
	read(a);


	for (int i = 1; i < n; ++i) {
		dp[i] += dp[i - 1] + abs(a[i] - a[i - 1]);


	}

	for (int i = 1; i < n; ++i) {
		for (int j = i - 1; j >= max(i - k, 0); --j) {
			dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
		}
	}
	writeln(dp[n - 1]);
	return 0;
}



Measured memory_bytes: 4020