akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main()
{
  int n, m, a[1000000], p = 0, c, t;

  for(int i = 1; i <= 1000000; i++){
    t = i;
    while(t%5 == 0){
      t /= 5;
    }
    while(t%3 == 0){
      t /= 3;
    }
    while(t%2 == 0){
      t /= 2;
    }
    if(t == 1){
      a[p++] = i;
    }
  }

  while(1){
    cin >> m;
    if(m == 0){
      break;
    }
    cin >> n;
    c = 0;
    for(int i = 0; i < p && a[i] <= n; i++){
      if(m <= a[i]){
	c++;
      }
    }
    cout << c << endl;
  }

  return 0;
}

Measured memory_bytes: 0
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
ans = 'War'
for z in range(X+1, Y+1):
    if max(x) < z and min(y) >= z:
        ans = 'No War'
print(ans)


Measured memory_bytes: 2940
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, m = map(int, input().split())
    sum_a = sum(list(map(int, input().split())))
    ans = n - sum_a
    if ans < 0:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 68160
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    static FastIO io = new FastIO("in.txt");

    public static void main(String[] args) throws Exception {
        int N; long[] L;
        N = io.nextInt();
        L = new long[N];
        for(int i=0; i<N; i++){
            L[i] = io.nextInt();
        }
        int ans = 0;
        for(int i=0; i<N; i++){
            for(int j=i+1; j<N; j++){
                for(int k=j+1; k<N; k++){
                    if(L[i] == L[j] || L[j] == L[k] || L[i] == L[k]) continue;
                    long ml = Math.max(Math.max(L[i], L[j]), L[k]);
                    long tl = L[i] + L[j] + L[k];
                    if(ml < tl - ml){
                        ans++;
                    }
                }
            }
        }
        io.println(ans);

        io.flush();
    }

    static class FastIO {
        static StringBuilder sb = new StringBuilder();
        static BufferedReader br;
        static StringTokenizer st;
        static PrintStream ps = new PrintStream(System.out);

        public FastIO(String fname) {
            try {
                File input = new File(fname);
                if (input.exists()) {
                    System.setIn(new FileInputStream(fname));
                }
            }catch (Exception e){
                e.printStackTrace();
            }

            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        void flush(){
            System.out.print(sb.toString());
            sb.setLength(0);
        }

        void print(Object o){
            sb.append(o);
        }

        void println(Object o){
            sb.append(o);
            sb.append('\n');
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 33504
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    
    cin >> a >> b >> c;
    
    if (a<b){
        if (b<c){
            cout << a <<" "<<b <<" " << c << endl;
        }
        else{
            cout << a <<" "<<c <<" " << b << endl;
        }
    }
    else{
            if (a<c){
                cout << b <<" "<<a <<" " << c << endl;
            }
            else{
                if (b<c){
                    cout << b <<" "<<c <<" " << a << endl;
                }
                else {
                    cout << c <<" "<<b <<" " << a << endl;                    
                }
            }
    }
    
    return 0;
}



Measured memory_bytes: 3092
#include<iostream> 
#include<climits> 
#include <bitset>
#include<string>
#include<math.h>
#include <cstdlib>
using namespace std ;
int main(){
    long long int a , b , c , d ;
    cin >> a >> b ;
    c = a%b ;
    d = b - a%b ;
    //cout << c << endl << d <<endl ;
    if(c > d) cout << d ;
    else cout << c ;
     
    return 0 ;
    
    
}

Measured memory_bytes: 256
gets.to_i.times do
  h, m = gets.scan(/\d+/).map(&:to_i)
  a = (h.to_r / 12 + m.to_r / 720 - m.to_r / 60).abs
  a = [a, 1 - a].min
  case
  when a < 1.to_r/12
    puts 'alert'
  when a >= 1.to_r/4
    puts 'safe'
  else
    puts 'warning'
  end
end

Measured memory_bytes: 8780
<?php
  
fscanf(STDIN, "%d", $n);
$rooms = [];
for ($ridge = 1; $ridge <= 4; $ridge++) {
  for ($floor = 1; $floor <= 3; $floor++) {
    for ($room = 1; $room <= 10; $room++) {
      $rooms[$ridge][$floor][$room] = 0;
    }
  }
}
for ($i = 0; $i < $n; $i++) {
  fscanf(STDIN, "%d %d %d %d", $ridge, $floor, $room, $number);
  $rooms[$ridge][$floor][$room] += $number;
}
for ($ridge = 1; $ridge <= 4; $ridge++) {
  for ($floor = 1; $floor <= 3; $floor++) {
    for ($room = 1; $room <= 10; $room++) {
      echo " ".$rooms[$ridge][$floor][$room];
    }
    echo "\n";
  }
  if ($ridge <= 3) {
    echo str_repeat("#", 20)."\n";
  }
}


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

int main(){
  int n,v;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  
  for(int i=0;i<n;i++){
    cout << a[i];
    if(i==n-1)
      cout << endl;
    else
      cout << " ";
  }
  
  for(int i=1;i<n;i++){
    int j;
    v = a[i];
    j = i-1;
    while(j>=0&&a[j]>v){
      a[j+1] = a[j];
      j--;
    }
    a[j+1]=v;
    
    for(int i=0;i<n;i++){
      cout << a[i];
      if(i==n-1)
      cout << endl;
    else
      cout << " ";
    }
  }
  
  return 0;
}



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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

int main(){
    fcin;
    ll n, k;
    cin >> n >> k;

    if(n > k) n %= k;

    ll ans = n;
    for(int i = 0; i <= 100000; i++){
        n = abs(k-n);
        ans = min(ans, n);
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
	int m;	scanf("%d",&m);
	while(m--){
		int ini,y,n;	scanf("%d%d%d",&ini,&y,&n);

		int ans=0;
		while(n--){
			int val=ini,type,due;
			double rate;
			scanf("%d%lf%d\n",&type,&rate,&due);
			if(type==0){
				int interest=0;
				for(int i=0;i<y;i++)	interest+=rate*val,val-=due;
				val+=interest;
			}
			else{
				for(int i=0;i<y;i++)	val*=1+rate,val-=due;
			}
			ans=max(ans,val);
		}

		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long int lo;
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define inf (lo)1e9;
#define FOR for(lo i = 0 ; i < n ; i++)
#define FORV for(lo i = 0 ; i < (lo)v.size() ; i++)
#define ii pair<lo,lo>
#define iii pair<lo, pair<lo,lo> >
lo d,e,n,m,k,t,h,x,y,a1[100005],a2[100005];
char c1,c2,c3,c4;
string s1,s2,s3,s4;
double d1,d2,d3;
vector <lo> v;
// map <lo,lo> mp1;
// map <string,lo> mp2;
// set <lo> stt;
// queue <lo> q;
// priority_queue <lo> pq;
// lo vis [10000];
int main() {
    // freopen("gir.gir", "r", stdin);
    // freopen("cik.cik", "w", stdout);
    lo a, b, c;
    cin >> a >> b >> c;
    // cout << sqrt(a) << " " << sqrt(b)<<" " << sqrt(c) << endl;
    if(a + b > c){
        cout << "No\n";
        return 0;
    }
    if((4 * a * b ) < (c - a - b) * (c - a - b)){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
#define all(x) (x).begin(),(x).end()
using namespace std;
int x[100010];
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a*b/gcd(a,b);
}
signed main(){
	int a;
	double ans;
	cin>>a;
	f(i,a){
		cin>>x[i];
	}
	sort(x,x+a);
	f(i,a){
		if(i)ans=(ans+x[i])/2.0;
		else ans=x[i];
	}
	printf("%.100lf\n",ans);
	
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    string t = "RGB";

    vector<vector<int>> cnt_from_back(n + 1, vector<int>(3));
    revrep(i, n) {
        rep(j, 3) cnt_from_back[i][j] = cnt_from_back[i + 1][j];
        rep(j, 3) if (s[i] == t[j]) cnt_from_back[i][j]++;
    }
    //print(cnt_from_back, " ");
    
    ll ans = 0;

    vector<int> cnt(3);
    rep(i, 3) if (s[0] == t[i]) cnt[i]++;

    repr(mid, 1, n - 1) {
        int i = -1;
        rep(j, 3) if (s[mid] == t[j]) i = j;
        assert(i != -1);
        int a = (i + 1) % 3, b = (i + 2) % 3;
        //cout << i << " " << a << " " << b << endl;
        
        ans += cnt[a] * cnt_from_back[mid + 1][b];
        ans += cnt[b] * cnt_from_back[mid + 1][a];

        int l = mid - 1, r = mid + 1;
        while (0 <= l && r < n) {
            if (s[l] != s[mid] && s[r] != s[mid] && s[l] != s[r]) ans--;
            l--;
            r++;
        }
        
        cnt[i]++;
        //cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3784
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        while (scanner.hasNext()) {
            String input = scanner.nextLine();
            String[] dataset = input.split(",");
            
            int[] sectionLen  = new int[10];
            double totalLen = 0;

            for (int i = 0; i < sectionLen.length; i++) {
                sectionLen[i] = Integer.parseInt(dataset[i]);
                totalLen += (double) sectionLen[i];
            }
            int v1 = Integer.parseInt(dataset[10]);
            int v2 = Integer.parseInt(dataset[11]);
            
            double time = totalLen / (v1 + v2);
            
            double distance = v1 * time;
            int meetSectionIdx = 0;
            
            for (int i = 0; i < sectionLen.length; i++) {
                distance -= sectionLen[i];
                if (distance > 0) {
                    meetSectionIdx = i+1;
                } else {
                    break;
                }
            }
            System.out.println(meetSectionIdx+1);
        }
        
    }   
}

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

void solve(int N,vector<vector<int>> &x,vector<vector<int>> &y,vector<vector<int>> &hito,int &ans){
	for(int i=0;i<hito.size();i++){
		bool pro =true;
		for(int k=0;k<N;k++){
			if(hito.at(i).at(k)==1)
        for(int j=0;j<x.at(k).size();j++)
          if(hito.at(i).at(x.at(k).at(j)) != y.at(k).at(j) ){pro =false;break;}
			if(!pro)break;
		}
		if(pro){
			int cu=0;
			for(int j=0;j<N;j++)if(hito.at(i).at(j)==1)cu++;
			ans=max(ans,cu);
		}
	}
}

int main(){
	int N; cin >> N;
	vector<vector<int>> x(N);
	vector<vector<int>> y(N);
	int a;
	int x1,y1;
	for(int i=0;i<N;i++){
		cin >> a;
		for(int j=0;j<a;j++){
			cin >> x1>> y1;
			x.at(i).push_back(x1-1);
			y.at(i).push_back(y1);
		}
	}
	int p =(1<<16);
	vector <vector<int>> hito(p,vector<int>(16,0));
	
	for(int t=0;t<(1<<16);t++){
		bitset<16> s(t);
		for(int i=0;i<N;i++){
			if(s.test(i)){
				hito.at(t).at(i)=1;
			}
		}
	}
	
	int ans=0;
	solve(N,x,y,hito,ans);

	cout<<ans<<endl;
}






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

int main(){
    int H,W;
    while(1){
        cin>>H>>W;
        if(H==0 && W==0)break;
        for(int a=0;a<W;a++){
                cout<<"#";
            }
            cout<<endl;
        for(int b=1;b<H-1;b++){
            cout<<"#";
            for(int c=1;c<W-1;c++){
                cout<<".";
            }
            cout<<"#"<<endl;
        }
        for(int d=0;d<W;d++){
                cout<<"#";
            }
            cout<<endl;
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<double,double> Pdouble;

const int INF = 2000000000;
const int MOD = 1000000007;

// a^n mod を計算する

int main(){
  ll n;
  cin >> n;
  cout << pow(n,3) << endl;
  
  
}


Measured memory_bytes: 892
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()

class Heap(object):
    def __init__(self, A):
        self._heap = A[:]
        for i in range((len(A))//2-1,-1,-1): # heapify in linear time
            self._descend(i)

    def __len__(self):
        return len(self._heap)

    def __bool__(self):
        return bool(self._heap)

    def _descend(self, i):
        heap = self._heap
        # i の子は 2i+1, 2i+2
        while(1):
            if i*2+1 >= len(self): break # 子が存在しない
            # 子がひとつだけのとき、必要なら入れ替えて終わり
            if i*2+1 == len(self)-1:
                if heap[i] > heap[i*2+1]:
                    heap[i], heap[i*2+1] = heap[i*2+1], heap[i]
                break
            # 子が複数のとき
            else:
                # 親、子1、子2のうち、親が最小であれば終わり
                if min(heap[i], heap[2*i+1], heap[2*i+2]) == heap[i]: break
                # そうでないとき、子のうち小さい方を親と入れ替える
                next = min((heap[2*i+1],2*i+1), (heap[2*i+2],2*i+2))[1]
                heap[i], heap[next] = heap[next], heap[i]
                i = next

    def front(self):
        assert self
        return self._heap[0]

    def append(self, x):
        self._heap.append(x)
        now = len(self)-1
        heap = self._heap
        # i の親は (i-1)//2
        while now!=0 and heap[now] < heap[(now-1)//2]:
            heap[now], heap[(now-1)//2] = heap[(now-1)//2], heap[now]
            now = (now-1)//2

    def pop(self):
        assert self
        if len(self)==1: return self._heap.pop()
        res, self._heap[0] = self._heap[0], self._heap.pop()
        self._descend(0)
        return res

def resolve():
    n, m = map(int,input().split())
    A = list(map(lambda x:-int(x),input().split()))
    heap = Heap(A)
    for _ in range(m):
        x = -heap.pop()
        x //= 2
        heap.append(-x)

    print(-sum(heap._heap))
resolve()

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

using namespace std;

#define sp(x) cout<<setprecision(x);
#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()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m; cin>>n>>m;
    vector<string> a(n);
    vector<string> b(n);
    REP(i,n) cin>>a[i];
    REP(i,m) cin>>b[i];
    bool flag = false;
    string ans = "No";
    REP(i,n-m+1){
        REP(j,n-m+1){
            if(a[i][j] == b[0][0]){
                flag = true;
                REP(k,m){
                    if(flag)
                    REP(l,m){
                        if(a[i+k][j+l] != b[k][l]){
                            flag = false;
                        }
                    }
                }
                if(flag) ans = "Yes";
            }
        }
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
int a[1010], b[1010], c[1010];
vector<int>s, t;
signed main() {	
	int x, y, z, k;
	cin >> x >> y >> z >> k;
	rep(i, x)cin >> a[i];
	rep(i, y)cin >> b[i];
	rep(i, z)cin >> c[i];
	rep(i, x) {
		rep(j, y) {
			s.push_back(a[i] + b[j]);
		}
	}
	sort(s.begin(), s.end(), greater<int>());
	rep(i, min(k, (int)s.size())) {
		rep(j, z) {
			t.push_back(s[i] + c[j]);
		}
	}
	sort(t.begin(), t.end(), greater<int>());
	rep(i, k) {
		cout << t[i] << endl;
	}
}

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

int vac(int n, int a[], int b[], int c[])
{
	int dp[n][3];
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	for(int i=1; i<n; i++)
	{
		dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = c[i] + max(dp[i-1][0],dp[i-1][1]);
	}
	return max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
}

int main()
{
	int n;
	cin >> n;
	int a[n], b[n], c[n];
	for(int i=0; i<n; i++)
		cin >> a[i] >> b[i] >> c[i];
	int ans = vac(n, a, b, c);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5964
#include<iostream>
using namespace std;
int main(){
	int a, b, c, i,k=0;
	cin >> a >> b >> c;
	for (i = a; i <= b; i++){
		
		if (i <= b){ if (c % i == 0){ k++; } }
		else{ break; }
	

	}cout << k << endl; return 0;
}


Measured memory_bytes: 3100
N, K = map(int, input().split())
store = N
x = N % K
if N == 0:
    print(0)
else:
    while x < store:
        store = x
        x = abs(x - K)

    if store > abs(N - K):
        print(abs(N - K))
    else:
        print(store)


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int count = 1;
    for(int i = 1; i < 4; i++)
    {
        bool appear = 0;
        for(int j = 0; j < i; j++)
        {
            if(s[i] == s[j])
            {
                appear = 1;
            }
        }
        if(!appear)
        {
            count++;
        }
    }
    if(count != 2)
    {
        cout << "No";
    }
    else
    {
        char char1, char2;
        int count1 = 0;
        int count2 = 0;
        for(int i = 0; i < 3; i++)
        {
            if(s[i] != s[i + 1])
            {
                char1 = s[i];
                char2 = s[i + 1];
            }
        }
        for(int i = 0; i < 4; i++)
        {
            if(s[i] == char1)
            {
                count1++;
            }
            else
            {
                count2++;
            }
        }
        if(count1 == count2)
        {
            cout << "Yes";
            return 0;
        }
        cout << "No";
        return 0;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N;
  vector<long> data(201);
  cin >> N;
  int a;
  for(int i = 0; i < N; i++) {
    cin >> a;
    data.at(a + 100)++;
  }
  long sub, ans = 1000000000;
  for(int i = 0; i < 201; i++) {
    sub = 0;
    for(int j = 0; j < 201; j++) {
      sub += data.at(j) * pow(abs(j - i), 2);
    }
    ans = min(ans, sub);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<string.h>

using namespace std;

#define INF 2<<29;

int n,a,b,c;
int l[8];

int func(int now,int aa,int bb,int cc){
  if(now==n){
    if(a==aa||b==bb||c==cc){
      return INF;
    }else return abs(aa)+abs(bb)+abs(cc)-30;
  }else{
    return
      min(func(now+1,aa,bb,cc),
	  min(func(now+1,aa-l[now],bb,cc)+10,
	      min(func(now+1,aa,bb-l[now],cc)+10,func(now+1,aa,bb,cc-l[now])+10)));
  }
}

int main(){
  scanf("%d %d %d %d",&n,&a,&b,&c);
  for(int i=0;i<n;i++){
    scanf("%d",&l[i]);
  }

  printf("%d\n",func(0,a,b,c));
  
  return (0);
}


Measured memory_bytes: 256
n=str(input())
a=len(n)
if n[a-1] =="3":
  print("bon")
if n[a-1] == "0"or n[a-1] == "1"or n[a-1] == "6"or n[a-1] == "8":
  print("pon")
if n[a-1] == "2" or n[a-1] == "4" or n[a-1] == "5" or n[a-1] == "7" or n[a-1] == "9":
  print("hon")

Measured memory_bytes: 61860
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String strArray[] = str.split(" ");

		int a = Integer.parseInt(strArray[0]);
		int b = Integer.parseInt(strArray[1]);
		for(int i = 0; i<3000; i++){
			if(a==0 && b==0){
				break;
			}else{
		if(a<b){
			System.out.println(a + " " + b);
		}else{
			System.out.println(b + " " + a);
		}
		strArray[0] = null;
		strArray[1] = null;
		str = br.readLine();
		strArray = str.split(" ");
		 a = Integer.parseInt(strArray[0]);
		b = Integer.parseInt(strArray[1]);
			}
		}
	}
}

Measured memory_bytes: 26888
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int main() {
  int n,m;
  cin >> n >> m;
  int a[m],b[m];
  REP(i,m) {
    cin >> a[i] >> b[i];
  }
  int right = 1;
  int ans = 0;
  while(1) {
    int ma = -1;
    REP(i,m) {
      if (a[i]<=right && b[i]>=right) {
        ma = max(ma, b[i]);
      }
    }
    //cout << ma << " " << right << endl;
    if (ma == -1) break;
    right = ma+1;
    ans++;
  }
  if (right != n+1) {
    cout << "Impossible" << endl;
  } else
    cout << ans << endl;
  
}

Measured memory_bytes: 0
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////

int main(){fastio
    ll n,k;cin>>n>>k;
    ll ans=0;
    rep(i,k,n+1){
        ll mi=(i-1)*i/2;
        ll mx=(n+(n-i+1))*i/2;
        Add(ans,mx-mi+1);
    }
    cout<<ans<<endl;
    
    return 0;
}


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

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

template <class T, class U, class V>
inline T clamp(const T& x, const U& lo, const V& hi) { return x < lo ? lo : x > hi ? hi : x; }

bool solve(int W, int H, const vector<string>& RoomL, const vector<string>& RoomR) {
    int sxL, syL, sxR, syR;
    rep(i, H) rep(j, W) {
        if (RoomL[i][j] == 'L') sxL = i, syL = j;
        if (RoomR[i][j] == 'R') sxR = i, syR = j;
    }
    bool vis[H][W][H][W]; memset(vis, 0, W * H * W * H); vis[sxL][syL][sxR][syR] = true;
    queue<tuple<int, int, int, int>> Q;
    for (Q.emplace(sxL, syL, sxR, syR); !Q.empty();) {
        int xL, yL, xR, yR; tie(xL, yL, xR, yR) = Q.front(); Q.pop();
        rep(k, 4) {
            int nxL = clamp(xL + dx[k], 0, H - 1), nyL = clamp(yL + dy[k], 0, W - 1),
                nxR = clamp(xR + dx[k], 0, H - 1), nyR = clamp(yR - dy[k], 0, W - 1);
            if (RoomL[nxL][nyL] == '#' and RoomR[nxR][nyR] == '#') continue;
            if (RoomL[nxL][nyL] == '#') nxL -= dx[k], nyL -= dy[k];
            if (RoomR[nxR][nyR] == '#') nxR -= dx[k], nyR += dy[k];
            if (RoomL[nxL][nyL] == '%' and RoomR[nxR][nyR] == '%') return true;
            if (RoomL[nxL][nyL] == '%' or RoomR[nxR][nyR] == '%' or vis[nxL][nyL][nxR][nyR]) continue;
            vis[nxL][nyL][nxR][nyR] = true;
            Q.emplace(nxL, nyL, nxR, nyR);
        }
    }
    return false;
}

int main() {
    for (int W, H; cin >> W >> H, W | H;) {
        vector<string> RoomL(H), RoomR(H);
        rep(i, H) cin >> RoomL[i] >> RoomR[i];
        cout << (solve(W, H, RoomL, RoomR) ? "Yes" : "No") << endl;
    }
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
vector<int> E[606];
double dp[606],dp2[606];
int in[606];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
	}
	
	in[0]=1;
	FOR(i,N) if(in[i]) {
		FORR(e,E[i]) in[e]=1;
	}
	
	for(i=N-2;i>=0;i--) {
		FORR(e,E[i]) dp[i]+=1+dp[e];
		dp[i]/=E[i].size();
	}
	
	FOR(i,N) dp2[i]=dp[i];
	
	double ret=dp[0];
	for(i=N-2;i>=0;i--) if(in[i] && E[i].size()>=2) {
		vector<double> V;
		FORR(e,E[i]) V.push_back(dp[e]);
		sort(ALL(V));
		V.pop_back();
		
		dp2[i]=0;
		FORR(v,V) dp2[i]+=1+v;
		dp2[i]/=V.size();
		
		for(j=i-1;j>=0;j--) {
			dp2[j]=0;
			FORR(e,E[j]) dp2[j]+=1+dp2[e];
			dp2[j]/=E[j].size();
		}
		ret=min(ret,dp2[0]);
		

		
		for(j=i;j>=0;j--) dp2[j]=dp[j];
	}
	
	_P("%.12lf\n",ret);
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main(){
  int n;
  while(cin >> n){
    int cnt = 0;
    bool f = false;
    for(int i=0;i<n;i++){
      char c;
      int x;
      cin >> c >> x;
      if(c == '(') cnt += x;
      else{
        cnt -= x;
        if(cnt < 0) f = true;
      }
    }
    if(!f && cnt == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

Measured memory_bytes: 1152
# https://atcoder.jp/contests/abc058/tasks/arc071_a
# C - 怪文書 / Dubious Document
import collections

n = int(input().split()[0])
s_list = []

for _ in range(n):
    s = input().split()[0]
    s_list.append(s)

# 何の文字が最低何個必要か
c_list = []
c_dict = {}

for s in s_list:
    c = collections.Counter(s)
    c_list.append(c)

common_k_list = list(c_list[0].keys())

for c in c_list[1:]:
    for c_k in common_k_list:
        if c_k not in c.keys():
            common_k_list.remove(c_k)

c_dict = {k: float('inf') for k in common_k_list}

for c in c_list:
    for k in common_k_list:
        c_dict[k] = min(c_dict[k], c[k])

ans = ''.join([k * v for k, v in c_dict.items()])

# 辞書順最小を作る
ans = ''.join(sorted([k * v for k, v in c_dict.items()]))
print(ans)


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

int main() {
    string s;
    cin >> s;
    while(true){
        s.pop_back();
        if(s.size() % 2 == 0){
            if(s.size() == 1 or s.substr(0, s.size() / 2) == s.substr(s.size() / 2)){
                cout << s.size() << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    x=int(input())
    ans=2*(x//11)
    x%=11
    if(x==0):
        print(ans)
    elif(x<7):
        print(ans+1)
    else:
        print(ans+2)
resolve()

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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;

int main(){
	string s;
	cin >> s;
	if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]) cout <<"Bad";
	else cout << "Good";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <string>

using namespace std;

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

#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 FORR(i, m, n) for (int i = m; i >= n; i--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;

// nCr
ll po[POW_MAX + 2];
ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
ll mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}
ll comb(int n, int r) {
  return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}
// greatest common divisor
ll gcd(ll a, ll b) {
  while (a % b != 0) {
    ll tmp = a;
    a = b;
    b = tmp % b;
  }
  return b;
}

char const U = 'U';
char const L = 'L';
char const R = 'R';
char const D = 'D';

ll H, W, N;
ll sr, sc;
string S;
string T;

int main() {
  scanf("%lld %lld %lld", &H, &W, &N);
  scanf("%lld %lld", &sr, &sc);
  cin >> S;
  cin >> T;

  map<char, ll> moves{
    {R, sc}, {L, W - sc + 1}, {D, sr}, {U, H - sr + 1}
  };
  map<char, ll> max_map;
  map<char, char> rev{
    {R, L}, {L, R}, {U, D}, {D, U}
  };
  for(ll i = 0; i < N; i++) {
    char s = S[i];
    char t = T[i];
    moves[s]++;
    max_map[s] = max(max_map[s], moves[s]);

    moves[rev[t]]--;
    moves[rev[t]] = max(moves[rev[t]], 1ll);
  }
  bool alive = true;
  if (max_map[R] > W) alive = false;
  if (max_map[L] > W) alive = false;
  if (max_map[D] > H) alive = false;
  if (max_map[U] > H) alive = false;

  if (alive) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
}


Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

int foo(vector<int>& h,int k)
{
    int n = h.size();
    vector<int> dp(n);

    dp[n-1]=0;
    for (int i=n-2;i>=0;--i)
    {
        int best = INT_MAX;
        int step=1;
        while (step<=k && i+step<n)
        {
            best = min(best,abs(h[i]-h[i+step])+dp[i+step]);
            ++step;
        }
        dp[i] =best;
    }

    return dp[0];
}

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> h(n);

    for (int i=0;i<n;++i) cin>>h[i];

    cout<<foo(h,k)<<endl;

    return 0;
}


Measured memory_bytes: 1024
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   : combinatorics NCR
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define rw freopen("graphs_as_a_service.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 1e5 + 10, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
int dp[55][4][4] = { }, n;
string s[3];
int solve(int idx, int up, int down) {
	if (idx >= n)
		return 1;
	int &ret = dp[idx][up][down];
	if (ret != -1)
		return (ret % mod);
	ret = 0;
	if (s[1][idx] == s[2][idx]) {
		lp(i,1,3)
		{
			if (i != up && i != down)
				ret += solve(idx + 1, i, i);
			if (ret >= mod)
				ret %= mod;
		}
	} else {
		lp(i,1,3)
		{
			lp(j,1,3)
			{
				if (i != up && j != down && i != j)
					ret += solve(idx + 2, i, j);
				if (ret >= mod)
					ret %= mod;
			}
		}
	}
	return ret;
}
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	cin >> n >> s[1] >> s[2];
	clr(dp, -1);
	cout << solve(0, 0, 0) << "\n";
	return 0;
}

Measured memory_bytes: 384
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii;
import std.typecons, std.functional;
import std.algorithm, std.container;

void main()
{
    long N = scanElem;
    long[] list = scanArray;
    long res;
    long m=-1;
    foreach(e; list)
    {
        if(m<=e){
            res++;
        }
        m = max(e, m);
    }
    writeln(res);
}

class UnionFind{
    UnionFind parent = null;

    void merge(UnionFind a)
    {
        if(same(a)) return;
        a.root.parent = this.root;
    }
    UnionFind root()
    {
        if(parent is null)return this;
        return parent = parent.root;
    }
    bool same(UnionFind a)
    {
        return this.root == a.root;
    }
}

void scanValues(TList...)(ref TList list)
{
    auto lit = readln.splitter;
    foreach (ref e; list)
    {
        e = lit.fornt.to!(typeof(e));
        lit.popFront;
    }
}

T[] scanArray(T = long)()
{
    return readln.split.to!(long[]);
}

void scanStructs(T)(ref T[] t, size_t n)
{
    t.length = n;
    foreach (ref e; t)
    {
        auto line = readln.split;
        foreach (i, ref v; e.tupleof)
        {
            v = line[i].to!(typeof(v));
        }
    }
}

T scanElem(T = long)()
{
    char[] res;
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        res ~= cast(char) c;
        c = getchar;
    }
    return res.strip.to!T;
}

template fold(fun...) if (fun.length >= 1)
{
    auto fold(R, S...)(R r, S seed)
    {
        static if (S.length < 2)
        {
            return reduce!fun(seed, r);
        }
        else
        {
            import std.typecons : tuple;

            return reduce!fun(tuple(seed), r);
        }
    }
}

struct Factor
{
    long n;
    long c;
}

Factor[] factors(long n)
{
    Factor[] res;
    for (long i = 2; i ^^ 2 <= n; i++)
    {
        if (n % i != 0)
            continue;

        int c;
        while (n % i == 0)
        {
            n = n / i;
            c++;
        }
        res ~= Factor(i, c);
    }
    if (n != 1)
        res ~= Factor(n, 1);

    return res;
}
long[] primes(long n)
{
    if(n<2)return [];
    auto table = new long[n+1];
    long[] res;
    for(int i = 2;i<=n;i++)
    {
        if(table[i]==-1) continue;
        for(int a = i;a<table.length;a+=i)
        {
            table[a] = -1;
        }
        res ~= i;
    }
    return res;
}
bool isPrime(long n)
{
    if (n <= 1)
        return false;
    if (n == 2)
        return true;
    if (n % 2 == 0)
        return false;
    for (long i = 3; i ^^ 2 <= n; i += 2)
        if (n % i == 0)
            return false;
    return true;
}

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


 
int main(){
	int n,k;
	cin>>n>>k;
	vector<int> snuke(n,0);
	rep(i,k){
		int d;
		cin>>d;
		int a;
		rep(j,d){
			cin>>a;
			snuke.at(a-1)++;
		}
	}
	int ans=0;
	rep(i,n){
		if(snuke.at(i)==0){
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3632
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = [0 for i in range(N*M+1)]
b = [0 for i in range(N*M+1)]
da = [0 for i in range(N*M+1)]
db = [0 for i in range(N*M+1)]
mod = 10**9+7
for i in range(N):
    a[A[i]] += 1
    if da[A[i]] == 1:
        print(0)
        quit()
    da[A[i]] += 1
for i in range(M):
    b[B[i]] += 1
    if db[B[i]] == 1:
        print(0)
        quit()
    db[B[i]] += 1
for i in range(1,N*M+1):
    a[-i-1] += a[-i]
    b[-i-1] += b[-i]
ans = 1
for i in range(N*M):
    f = 0
    g = 0
    x = N*M - i
    y = i
    if da[x] == 1:
        f = 1
    if db[x] == 1:
        g = 1
    z = 1
    if f == 0:
        z = z*a[x]%mod
    if g == 0:
        z = z*b[x]%mod
    if f+g == 0:
        z -= i
    if z <= 0:
        print(0)
        quit()
    else:
        ans = ans*z%mod
print(ans%mod)


Measured memory_bytes: 99296
#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define SORT(A) sort(A.begin(), A.end())
#define SORTG(A) sort(A.begin(), A.end(), greater<int>())
#define INF 1000000000
using namespace std;
typedef long long ll;

int main()
{
    string S;
    cin >> S;
    ll n = S.size() - 1;
    ll ans = 0;
    vector<ll> N(n+1);
    rep(i, n+1) N.at(i) = S.at(i) - '0';
    ll dig;
    for (ll bit = 0; bit < (1<<n); ++bit)
    {
        dig = 1;
        rep(i, n + 1)
        {
            ans += dig * N.at(n-i);
            if ((bit>>i) & 1) dig = 1;
            else dig *= 10;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int tra,bus;
  if(a<b) tra=a;
  else tra=b;
  if(c<d) bus=c;
  else bus=d;
  cout << tra+bus <<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
//#define int long long
#define rep(i,start,end) for(i=start;i<end;i++)
#define Q 1000000007
#define F first
#define S second
#define pb push_back
#define fast_io ios_base::sync_with_stdio(false)
using namespace std;

int main() {
    fast_io;
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b and a>c){
        cout<<(b*c)/2;
    }
    else if(b>a and b>c){
        cout<<(a*c)/2;
    }
    else{
        cout<<(a*b)/2;
    }


}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<vector<ll>>> vvvll;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================





int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================


	ll N, K;
	cin >> N >> K;

	if (2 * (K - 1) + 1 <= N)
	{
		cout << "YES";
	}
	else
	{
		cout << "NO";
	}





}





Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N+2];
        for (int i = 1; i <= N; i++) {
            A[i] = sc.nextInt();
        }

        int S = 0;
        for (int i = 1; i <= N + 1; i++) {
            S += Math.abs(A[i] - A[i - 1]);
        }

        String[] R = new String[N];
        for (int i = 1; i <= N; i++) {
            R[i - 1] = String.valueOf(
                    S - (Math.abs(A[i] - A[i - 1]) + Math.abs(A[i + 1] - A[i])) +
                    Math.abs(A[i + 1] - A[i - 1]));
        }

        System.out.println(String.join("\n", R));
    }

}


Measured memory_bytes: 57480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m,q;
string s,t;
P p;

int main(){
	cin>>n>>m>>q;
	cin>>p.fi>>p.sc;
	cin>>s>>t;
	string X="UD";
	string Y="LR";
	
	rep(i,2) rep(j,2){
	    //if(i == 0 && j == 1)
		int cx = p.fi, cy = p.sc;
		bool fail = 0;
		rep(a,q){
			if(s[a] == X[i]){
				if(i == 0) cx--; else cx++;
			}
			if(s[a] == Y[j]){
				if(j == 0) cy--; else cy++;
			}
			//if(i==0 && j==1) cout<<cx<<" "<<cy<<endl;
			if(1<=cx&&cx<=n&&1<=cy&&cy<=m); else fail = 1;
			if(t[a] == X[1-i]){
				if(i == 1 && cx > 1) cx--;
				else if(i == 0 && cx < n) cx++;
			}
			if(t[a] == Y[1-j]){
				if(j == 1 && cy > 1) cy--;
				else if(j == 0 && cy < m) cy++;
			}
			//if(i==0 && j==1) cout<<cx<<" "<<cy<<endl;
			//if(1<=cx&&cx<=n&&1<=cy&&cy<=m); else fail = 1;
		}
		if(fail){
			puts("NO");
			return 0;
		}
	}
	puts("YES");
}

Measured memory_bytes: 776
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
ll a[200010], b[200010];
vector<ll> tree[200010];
ll p[200010], x[200010];
ll cnt[200010] = {};

void dfs(ll cur, ll par, ll d){
    cnt[cur] += d;
    for(auto &e: tree[cur]){
        if(e == par) continue;
        dfs(e, cur, cnt[cur]);
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll Q;
    cin >> Q;
    rep(i,0,N-1){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        tree[a[i]].push_back(b[i]);
        tree[b[i]].push_back(a[i]);
    }
    rep(i,0,Q){
        cin >> p[i] >> x[i];
        p[i]--;
        cnt[p[i]] += x[i];
    }
    dfs(0, -1, 0);
    rep(i,0,N){
        cout << cnt[i] << " \n"[i==N-1];
    }
    




}

Measured memory_bytes: 30592