akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

int main(){

  vector<int> v;

  int a;

  cin >> a;

  v.push_back(a);

  bool flag = false;

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

    //次の項の代入
    if(v[i-1]%2 == 0)
      v.push_back(v[i-1]/2);
    else
      v.push_back(3 * v[i-1] + 1);

    for(int j = 0;j < i-1;j++){//隣接した項は同じ数にならないので,比較はv[0]~v[i-2]まででよい.
      if(v[i] == v[j]){

        cout << i + 1 << endl;
        flag = true;
        break;

      }
    }

    if(flag) break;

  }

}

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

using ll = long long;

ll t[100010] = {};

int main(void){
    // Here your code !
    
    ll n,c,k,res = 0;
    cin >> n >> c >> k;
    
    ll befor = 0;
    ll man = 0;
    
    for(int i = 0; i < n; i++){
        cin >> t[i];
    }
    
    sort(t,t+n);
    
    befor = t[0] + k;
    man = 1;
    res++;
    
    for(int i = 1; i < n; i++){
        //cout << res << " " << befor << endl;
        if(befor < t[i]){
            res++;
            man = 1;
            befor = t[i] + k;
        }else{
            
            if(man == c){
                res++;
                man = 0;
                befor = t[i] + k;
            }
            
            man++;
        }
        
    }
    
    cout << res << endl;
    
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n,k;cin>>n>>k;
  vector<ll> a(n), aa, ca;
  rep(i, n)cin>>a[i];
  ca.push_back(0);
  rep(i, n) ca.push_back( ca.back() + a[i] );

  rep(i, n)for(int j=i+1; j<=n; j++) aa.push_back(ca[j]-ca[i]);

  sort(aa.begin(), aa.end());

  // search biggest bit satisfying numbers
  vector<ll>na;
  rrep(bit, 40){
    rrep(i, aa.size()) if( aa[i]>>bit & 1 )na.push_back(aa[i]);

    if(na.size()>=k)swap(aa, na);
    na.clear();
  }

  ll result=aa[0];
  rep(i, k)result = result&aa[i];
  cout<<result<<endl;

  return 0;
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int r,g,b,n;
	cin >>r >>g>>b>>n;
	int ans=0;
	for (int i=0;i<3001;i++){
		for (int j=0;j<3001;j++){
			if ((n-(r*i+g*j))%b==0 and n-r*i-g*j>=0){
				ans+=1;
			}
		}}
		cout <<ans <<endl;}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] l = new String[n];
        int[][] m = new int[n][11];
        for (int i = 0; i < n; i++) {
            StringBuilder sb = new StringBuilder();
            for (int j = 0; j < 10; j++) {
                sb.append(sc.next());
            }
            l[i] = sb.toString();
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 11; j++) {
                m[i][j] = sc.nextInt();
            }
        }

        long profit = Long.MIN_VALUE;

        for (int i = 1; i < 1024; i++) {
            long tmp = 0;
            String s = fillZero(Integer.toBinaryString(i));
            for (int j = 0; j < n; j++) {
                int count = 0;
                String z = Integer.toBinaryString(Integer.parseInt(l[j], 2) & i);
                for (int k = 0; k < z.length(); k++) {
                    if (z.charAt(k) == '1') {
                        count++;
                    }
                }
                tmp += m[j][count];
            }
            profit = Math.max(profit, tmp);
        }
        System.out.println(profit);
    }

    static String fillZero(String s) {
        StringBuilder sb = new StringBuilder(s);
        while (sb.length() < 10) {
            sb.insert(0, "0");
        }
        return sb.toString();
    }
}


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

int k, n, ans;

int main(){
  cin >> k >> n;
  vector<int> A(n);
  rep(i,n){
	cin >> A[i];
  }
  
  vector <int> d(n);
  rep(i,n-1){
    d[i] = A[i+1] - A[i];
  }
  d[n-1] = A[0] - A[n-1] + k;
  
  ans = k - *max_element(begin(d), end(d));
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N;
  long long int A=1;
  bool haszero = false;
  cin >> N;  
  vector<long long int> vec(N);
  for (int i = 0; i < N; i++){
    cin >> vec.at(i);
    if (vec.at(i) == 0){
      haszero = true;
    }
  }

    
  
  long long int B = 1000000000000000000;

  if (haszero) {
    cout << 0 << endl;
  }
  else{
    for (int i = 0; i < N; i++){
            if(vec[i] > (B/A)){
                cout << -1 << endl;
                return 0;
            }
            A *= vec[i];
        }
        cout << A << endl;
  }
  
}


Measured memory_bytes: 4024
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int N;
int d[101];

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

    cin >> N;
    set<int> s;

    rep(i, N){
      int a;
      cin >> a;
      s.insert(a);
    }

    cout <<  s.size() << endl;

    return 0;
}

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

#define int long long

#define MOD 1000000007

int n;
string s1, s2;

int memo[300][10][10];

int dp(int i, int a, int b){
    if(i == n) return 1;
    if(memo[i][a][b] != -1) return memo[i][a][b];

    int ans = 0;
    if(s1[i] == s2[i]){
        for(int x = 1;x <= 3;x++){
            if(x != a && x != b){
                ans += dp(i+1, x, x);
                ans %= MOD;
            }
        }
    }else{
        for(int x = 1;x <= 3;x++){
            for(int y = 1;y <= 3;y++){
                if(x != y && x != a && y != b){
                    ans += dp(i+2, x, y);
                    ans %= MOD;
                }
            }
        }
    }

    return memo[i][a][b] = ans;
}

signed main(){
    cin >> n;
    cin >> s1 >> s2;

    memset(memo, -1, sizeof(memo));

    cout << dp(0, 0, 0) << endl;

    return 0;
}



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

using namespace std;

int main() {
	int X;
	cin >> X;
	int b_max = 32;
	int p_max = 9;
	vector<int> candidates(1,1);
	for (int b=1; b<=b_max; ++b) {
		int prev = pow(b,2);
		if (prev > X) break;
		//cout << "b, p, prev: " << b << "," << 2 << "," << prev << endl;
		for (int p=3; p<=p_max; ++p) {
			int temp = pow(b, p);
			if (temp > X) {
				candidates.push_back(prev);
				break;
			}
			prev = temp;
			//cout << "b, p, prev: " << b << "," << 2 << "," << prev << endl;
		}
	}
	cout << *std::max_element(candidates.begin(), candidates.end()) << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define arep(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int k = 1;
    while (true) {
        if (2 * N < k * (k - 1)) {
            cout << "No" << endl;
            return 0;
        }
        else if (2 * N == k * (k - 1)) break;
        ++k;
    }
    vector<vector<int>> s(k);
    int now = 1;
    rep(i, 0, k) {
        rep(j, i + 1, k) {
            s[i].push_back(now);
            s[j].push_back(now);
            ++now;
        }
    }
    cout << "Yes" << endl;
    cout << k << endl;
    rep(i, 0, k) {
        cout << s[i].size() << ' ';
        rep(j, 0, s[i].size()) {
            cout << s[i][j] << ' ';
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 2304
import java.util.*;

public class Main {
	
	static int[] divisors;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		ArrayList<Integer> primeNumbersArray = getPrimes(N);
		int[][] primeNumbers = new int[primeNumbersArray.size()][N+1];
		
		for (int i = 0; i < primeNumbers.length; i++) {
			primeNumbers[i] = occurrences(primeNumbersArray.get(i), N);
		}
		
		
		
		int two = 0;
		int four = 0;
		int fourteen = 0;
		int twentyfour = 0;
		int seventyfour = 0;
		
		for (int i = 0; i < primeNumbers.length; i++) {
			if (primeNumbers[i][N] >= 2) {
				two++;
			}
			if (primeNumbers[i][N] >= 4) {
				four++;
			}
			if (primeNumbers[i][N] >= 14) {
				fourteen++;
			}
			if (primeNumbers[i][N] >= 24) {
				twentyfour++;
			}
			if (primeNumbers[i][N] >= 74) {
				seventyfour++;
			}
		}
		/*
		System.out.println(two+" "+four+" "+fourteen+" "+twentyfour+" "+seventyfour);
		for (int i = 0; i < primeNumbers.length; i++) {
			for (int j = 0; j < primeNumbers[0].length; j++) {
				System.out.print(primeNumbers[i][j] + " ");
			}
			System.out.println();
		}
		*/
		int t1 = twentyfour * (two-1);
		int t2 = nCr(four, 2) * (two-2);
		int t3 = seventyfour;
		int t4 = fourteen * (four-1);
		System.out.println(t1+t2+t3+t4);
	}
	
	static int nCr(int n, int r) {
		if (r > n) {
			return 0;
		}
		return factorial(n, r)/factorial(n-r, 1);
	}
	
	static int factorial(int n, int m) {
		int product = 1;
		while (n > m) {
			product *= n;
			n--;
		}
		return product;
	}
	
	static int[] occurrences(int prime, int N) {
		int[] occurrence = new int[N+1];
		occurrence[0] = prime;
		for (int i = 2; i <= N; i++) {
			int power = 0;
			int temp = i;
			while (temp > 0 && temp%prime == 0) {
				power++;
				temp /= prime;
			}
			occurrence[i] += occurrence[i-1] + power;
		}
		return occurrence;
	}
	
	static ArrayList<Integer> getPrimes(int N) {
		ArrayList<Integer> primeNumbers = new ArrayList<Integer>();
		
		for (int i = 2; i <= N; i++) {
			boolean isPrime = true;
			for (int j = 2; j <= Math.sqrt(i); j++) {
				if (i%j == 0) {
					isPrime = false;
					break;
				}
			}
			if (isPrime) {
				primeNumbers.add(i);
			}
		}
		
		return primeNumbers;
	}
}


Measured memory_bytes: 21844
package main
import "fmt"

func main() {
  var (
    A int
    B int
    C int
    D int
  )
  fmt.Scan(&A)
  fmt.Scan(&B)
  fmt.Scan(&C)
  fmt.Scan(&D)

  left := A + B
  right := C + D

  if left > right {
    fmt.Println("Left")
  } else if left < right {
    fmt.Println("Right")
  } else {
    fmt.Println("Balanced")
  }
}


Measured memory_bytes: 512
import math

N, M = map(int, input().split())
wa_list = [0] * N
ac_list = [False] * N
for i in range(M):
    p, s = map(str, input().split())
    p = int(p) - 1
    if s == 'AC':
        ac_list[p] = True
    else:
        if not ac_list[p]:
            wa_list[p] += 1
for i in range(N):
    if not (ac_list[i]):
        wa_list[i] = 0

print(sum(i == True for i in ac_list), sum(wa_list))


Measured memory_bytes: 4596
def sumup(l):
  k=[0]
  y=0
  for x in l:
    y+=x
    k.append(y)
  return k


ans=[]
n,m,k=map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))

al=sumup(al)
bl=sumup(bl)

for i in range(n+1):
  x=al[i]

  while True:
    if not bl:
      break
    
    else:
      b=bl[-1]
      if x+b>k : 
        bl.pop()

      else: 
        ans.append(i+len(bl)-1)
        break
print(max(ans))

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

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

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

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

void solve(){    

    int n;
    cin>>n;

    string s;
    cin>>s;
    vec(set<int>)v (26);

    fo(i,n){
        v[s[i]-'a'].insert(i+1);
    }
    auto change = [&](int m, char c){
        char present = s[m-1];
        s[m-1] = c;
        v[present-'a'].erase(m);
        v[c-'a'].insert(m);
    };
    auto find = [&](int l, int r){
        int cnt = 0;
        fo(i,26){
            auto it = v[i].lower_bound(l);
            if(it != v[i].end() && *it<=r) cnt++;
        }
        return cnt;
    };

    w(q){
        int Case; cin>>Case;
        if(Case==1){
            int id;
            char c;
            cin>>id>>c;
            change(id,c);
        }
        else{
            int l,r;
            cin>>l>>r;
            cout<<find(l,r)<<"\n";
        }
    }
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

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

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

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0;i < N;++i) {
		cin >> A[i];
	}
	string judge = "DENIED";
	for (int i = 0;i < N;++i) {
		judge = "APPROVED";
		if (A[i] % 2 == 0) {
			if (A[i] % 3 != 0 && A[i] % 5 != 0) {
				judge = "DENIED";
				break;
			}
		}
	}
	cout << judge << endl;
	return 0;
}

Measured memory_bytes: 256
h,w,k = map(int, input().split())
grid = []
cake = []
for i in range(h):
    s = input()
    grid.append(s)
    cake.append(s.count('#'))
num = 0

ans = [[0 for j in range(w)] for i in range(h)]
first = []

for i in range(h):
    if cake[i] == 0 and first == []:
        continue
    if cake[i]:
        num += 1
        cnt = 0
        for j in range(w):
            ans[i][j] = num
            if grid[i][j] == '#':
                cnt += 1
                if cnt < cake[i]:
                    num += 1
        if first == []:
            for j in range(w):
                first.append(ans[i][j])
    else:
        for j in range(w):
            ans[i][j] = ans[i-1][j]

for i in range(h):
    if ans[i][0] != 0:
        continue
    for j in range(w):
        ans[i][j] = first[j]
[print(*i) for i in ans]


Measured memory_bytes: 7580
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
 
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


int main()
{
	double r1, r2;

	cin >> r1 >> r2;

	printf("%.7lf\n", r1 * r2 / (r1 + r2));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin>>a.at(i);
  int64_t c=0;
  int x=0;
  bool f=1;
  for(int i=n-1;i>=0;i--){
    x=max(x-1,0);
    if(a.at(i)>x){
      c+=a.at(i);
      x=a.at(i);
    }else if(a.at(i)<x){
      f=0;
      break;
    }
  }
  cout<<(f&&x==0?c:-1)<<endl;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = int(1e9) + 1;
const LL LLINF   = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

template <class T> inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}

inline int toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}

void solve()
{
    int N, M;
    cin >> N >> M;
    vector<pii> cond;
    REP0 (i, M)
    {
        int s, c;
        cin >> s >> c;
        cond.push_back(make_pair(s, c));
    }

    int r = 1;
    REP0 (i, N)
    {
        r *= 10;
    }
    int l = (N == 1 ? 0 : r / 10);

    FOR (i, l, r)
    {
        bool isok = true;
        string s  = toString(i);
        for (auto c : cond)
        {
            if (s[c.first - 1] - '0' != c.second)
                isok = false;
        }

        if (isok)
        {
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long n;
    cin >> n;
    long long ans = 0;
    for (long long a = 1; a * a <= n; a++) {
        if (n % a == 0) {
            long long b = n / a;
            if (b - 1 > a) {
                ans += b - 1;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
for e in iter(input, "-1 -1 -1"):
    m, f, r = tuple(map(int, e.split(" ")))
    total = m + f
    if -1 in (m, f):
        print("F")
    elif total >= 80:
        print("A")
    elif 80 > total >= 65:
        print("B")
    elif 65 > total >= 50:
        print("C")
    elif 50 > total >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    elif total < 30:
        print("F")


Measured memory_bytes: 5600
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)

struct Edge{
    int to;
    int dist;
};
using Graph = vector<vector<Edge>>;

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

    int u,v,w;
    for(int i=0;i<n-1;i++){
        cin>>u>>v>>w;
        Edge tmp;
        tmp.to = v - 1,tmp.dist = w % 2;
        G[u-1].push_back(tmp);
        tmp.to = u - 1;
        G[v-1].push_back(tmp);
    }

    vector<int> d(n,-1);
    queue<int> que;

    d[0] = 0;
    que.push(0);

    vector<int> ans(n,0);

    while(!que.empty()){
        int pv = que.front();
        que.pop();

        for(auto nv : G[pv]){
            if(d[nv.to] != -1) continue;

            d[nv.to] = d[pv] + nv.dist;
            if(d[nv.to] % 2 == 0) ans[nv.to] = 0;
            else ans[nv.to] = 1;

            que.push(nv.to);
        }
    }

    for(int i=0;i<n;i++) cout<<ans[i]<<endl;
}

Measured memory_bytes: 7168
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;



int main() {
	string s;
	cin >> s;
	s += 'E';
	int x, y;
	cin >> x >> y;

	priority_queue<int> pq_x;
	priority_queue<int> pq_y;

	bool isX = true;
	bool isFirst = true;
	int cnt = 0;
	for (int i = 0; i < s.length();i++) {
		if (s[i] == 'F') {
			cnt++;
		}
		else {
			if (isFirst) {
				x -= cnt;
				
				isFirst = false;
				isX = false;

			}else if (isX) {
				pq_x.push(cnt);
				isX = false;
				
			}
			else {
				pq_y.push(cnt);
				isX = true;
				
			}
			cnt = 0;
		}
	}
	

	while (!pq_x.empty()) {
		int dx = pq_x.top();
		pq_x.pop();
		if (x <= 0) {
			x += dx;
		}
		else {
			x -= dx;
		}
	}
	while (!pq_y.empty()) {
		int dy = pq_y.top();
		pq_y.pop();
		if (y <= 0) {
			y += dy;
		}
		else {
			y -= dy;
		}
	}

	cout << ((x == 0 && y == 0) ? "Yes" : "No") << endl;
}
	


Measured memory_bytes: 256
# dfs
def search7(i, ticket, equation):
    if i == len(ticket) - 1:
        if eval(equation) == 7:
            return True, equation
        else:
            return False, '_'
    else:
        check_param, new_equation = search7(i + 1, ticket, equation + '+' + ticket[i + 1])
        if check_param:
            return True, new_equation
        check_param, new_equation = search7(i + 1, ticket, equation + '-' + ticket[i + 1])
        if check_param:
            return True, new_equation
        
        return False, '_'


def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    ticket = list(input())

    _, equation = search7(0, ticket, ticket[0])
    print(equation+'=7')


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
    _typer init = 0;
    char ch = getchar(), k = 0;
    for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
    for ( ; isdigit(ch); ch = getchar())
        init = (init << 3) + (init << 1) + (ch ^ 48);
    return k ? -init : init;
}
const ll N = 0, INF = 1e9;

/*******************************************************************************
 *
 *
 *
 ******************************************************************************/

int n;
string s;

int main() {
    n = read<int>();
    cin  >> s;
    if (n < 3200) cout << "red" << endl;
    else cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, T;
    cin >> N >> T;
    vector<int> A(N);
    rep(i, N) { cin >> A[i]; }
    vector<int> rmax(N);
    int ma = 0;
    for(int i = N - 2; i >= 0; i--) {
        ma = max(A[i + 1], ma);
        rmax[i] = ma;
    }
    vector<int> dif(N);
    ma = 0;
    rep(i, N - 1) {
        dif[i] = rmax[i] - A[i];
        ma = max(dif[i], ma);
    }
    int res = 0;
    rep(i, N - 1) {
        // cout << dif[i] << endl;
        if(dif[i] == ma)
            res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1408
def abc133c
	l,r = gets.chomp.split(/\s/).map{|x| x.to_i}

	min = l*r
    for i in l..r-1
        mod = 0
		for j in i+1..r
			mod = (i*j)%2019
			min = [min, mod].sort[0]
			break if mod == 0
		end
        break if mod == 0
	end
	puts min
end

abc133c

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

int main() {
    int n;
    cin >> n;
    int arr[100];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    for (int i = n; i > 0; i--) {
        cout << arr[i -1];
        if (i != 1) cout << " ";
    }

    cout << endl;
}

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

int main() {

    string n,ans = "No";
    cin >> n;

    if ((n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3])) {
        ans = "Yes";
    }

    cout << ans << endl;

    return 0;
}

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

int isPrime(int x);

main(){

  int N;
  int i,j,a;
  int count = 0;

  scanf("%d",&N);

  for (i=0;i<N;i++){
    scanf("%d",&a);
    count += isPrime(a);
  }

  printf("%d\n",count);

}

int isPrime(int x){

  int i;
  int limit = sqrt(x) + 1;
  int s;

  /*
  s = sqrt(x);
  if(sqrt(x) - s == 0){
    limit = s + 1;
  }
  */

  if(x>2 && x%2==0){
    return 0;
  }

  for (i=3;i<limit;i+=2){
    if(x%i==0){
      return 0;
    }
  }
  return 1;

}

Measured memory_bytes: 0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
Vs = list(map(int, input().split()))
Vs.sort()

s = 0
coeff = 1
for i, v in enumerate(Vs):
    if i <= 1:
        s += v
    else:
        coeff *= 2
        s += v * coeff

t = 2 ** (N - 1)

print("{:.15f}".format(s / t))








Measured memory_bytes: 6992
import collections, math

local = False
if local:
    file = open("inputt.txt", "r")

def inp():
    if local:
        return file.readline().rstrip()
    else:
        return input().rstrip()

def ints():
    return [int(_) for _ in inp().split()]


X, Y, Z = ints()

X, Y = Y, X
X, Z = Z, X

print(str(X) + " " + str(Y) + " " + str(Z))

Measured memory_bytes: 38460
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;
const ll INF = 1061109567;
const double EPS = 1e-10;

int main(){
	int H, W;
	cin >> H >> W;
	char s[H+2][W+2];
	for (int i = 0; i < W + 2; i++) {
		s[0][i] = '.';
		s[H + 1][i] = '.';
	}
	for (int i = 0; i < H + 2; i++) {
		s[i][0] = '.';
		s[i][W + 1] = '.';
	}
	for (int i = 1; i < H+1; i++) {
		for (int j = 1; j < W+1; j++) {
			cin >> s[i][j];
		}
	}

	for (int i = 1; i < H+1; i++) {
		for (int j = 1; j < W+1; j++) {
			if (s[i][j] == '#'&&s[i - 1][j] == '.'&&s[i + 1][j] == '.'&&s[i][j - 1] == '.'&&s[i][j + 1] == '.') {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[2000000];
int main() {
    int n;
    scanf("%d",&n);
    scanf("%s",s);
    int m=strlen(s);
    for(int i=0;i<m;i++) s[i]='A'+(s[i]-'A'+n)%26;
    printf("%s",s);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
string S, FRONT, BACK;
bool FR = true;
int Q;
int main() {
	cin >> S;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int T, F;
		char C;
		cin >> T;
		if (T == 1) {
			FR ^= 1;
			continue;
		}

		cin >> F >> C;

		if ((F == 1 && FR) || (F == 2 && !FR)) {
			FRONT += C;
		}
		else {
			BACK += C;
		}
	}

	if (FR) {
		reverse(FRONT.begin(), FRONT.end());
		cout << FRONT << S << BACK << endl;
	}
	else {
		reverse(S.begin(), S.end());
		reverse(BACK.begin(), BACK.end());
		cout << BACK << S << FRONT << endl;
	}
	return 0;
}

Measured memory_bytes: 1088
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
    using T = ll;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;

bool seen[100100];
int main(){
    ll n, k;
    cin >> n >> k;
    Graph G(n);
    rep(i, n - 1){
        ll a, b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    queue<P> q;
    q.push(P(0, 1));
    ll res = k;
    while(!q.empty()){
        P p = q.front();
        q.pop();
        int v = p.first;
        seen[v] = true;
        ll cnt = p.second;
        for(auto nv : G[v]){
            if(seen[nv])continue;
            if(cnt > k){
                cout << 0 << endl;
                return 0;
            }
            res = res * (k - cnt) % MOD;
            cnt++;
            q.push(P(nv, min((ll)2, p.second + 1)));
        }
    }
    cout << res << endl;
}



Measured memory_bytes: 10860
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>

#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()

using namespace std;

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
    cout << s.substr(0, 4) << " " << s.substr(4, 8) << endl;
    
}

Measured memory_bytes: 256
D,N=map(int,input().split())
dp=[[-1]*(N) for i in range(D+1)]
#dp[i][j][k] i日目にｊを着たときの最大
d=[]
for i in range(D):
    i=int(input())
    d.append(i)
J=[]
for j in range(N):
    a,b,c=map(int,input().split())
    J.append([a,b,c])
t=d[0]
h=[-1]*N
for j in range(N):
    a,b,c=J[j]
    if t<a or b<t:
        continue
    h[j]=c
for i in range(2,D+1):
    t=d[i-1]
    for j in range(N):
        a,b,c=J[j]
        if t<a or b<t:
            continue
        for k in range(N):
            if i==2:
                if h[k]==-1:
                    continue
                dp[i][j]=max(abs(J[k][2]-c),dp[i][j])
            if dp[i-1][k]==-1:
                continue
            dp[i][j]=max(dp[i-1][k]+abs(J[k][2]-c),dp[i][j])
ans=0
for i in range(N):
    ans=max(dp[D][i],ans)
print(ans)



Measured memory_bytes: 6368
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
	if a[i]==1:
		break
p=i
k-=1

#print(ans)
x=0
for j in range(n-1,p,-k):
	x+=1
#print(x)
for j in range(0,p,k):
	x+=1
y=p%k+1+(n-p-1)%k
if p%k>0 and (n-p-1)%k>0 and y<=k+1:
	x-=1
print(x)

Measured memory_bytes: 13880
n = int(input())
ans = 0
t = 0
for i in range(n):
    a, b = map(int, input().split())
    if a == b:
        t += 1
    else:
        t = 0
    ans = max(t, ans)
if ans >= 3:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9200
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/

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

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    a.sort()
    mr = 0
    for i in range(n):
        r = min(a[i], a[-1] - a[i])
        if r > mr:
            mr = a[i]
    print(a[-1], mr)


if __name__ == '__main__':
    solve()


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

#define SZ(v) ((int)(v).size())
using ll = long long;

pair<int, int> gok(int k, int h, int m)
{
	while (k > 0)
	{
		m++;
		if (m == 60)
			m = 0, h++;
		k--;
	}
	return {h, m};
}

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

	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int h(h1), m(m1);
	int ans(0);
	while (1)
	{
		auto [hh, mm] = gok(k, h, m);
		if (hh > h2 or (hh == h2 and mm > m2))
			break;
		m++;
		++ans;
		if (m==60)
			m = 0, h++;
	}
	cout << ans -1<< endl;
}

Measured memory_bytes: 3652
/**
* Copyright(c)
* Author : tiketiskte
* Date : 2020-04-27-11.56.25
*/
#include <bits/stdc++.h>
#define IOS {ios::sync_with_stdio(false);cin.tie(0);}
using namespace std;
int n, ans;
map<string, int>mp;
string x;
int main()
{
    IOS
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> x;
        if(mp[x] == 0) {
            ans++;
            mp[x]++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 19200
#include<stdio.h>
int main()
{
    long long int n,i,j,a,b,result,p,q,s,r[100005];
    while(scanf("%lld %lld %lld",&n,&a,&b)!=EOF)
    {
        result=0;
        for(i=0; i<n; i++)
        {
            scanf("%lld",&r[i]);
        }
        for(i=0; i<n-1; i++)
        {
            p=r[i+1]-r[i];
            q=p*a;
            if(q>=b)
            {
                result=result+b;
            }
            else
            {
                result=result+q;
            }

        }
        printf("%lld\n",result);
    }
    return 0;
}



Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
using lint = long long;
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (lint i = 0; i < lint(n); ++i)
#define Rep(i, n) for (lint i = lint(n); i >= 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to; double cost; };
using P = pair<lint, lint>;
using D = pair<double, double>;
using DI = pair<double, int>;
//const lint mod = 998244353LL;
const lint mod = 1000000007LL;
const lint inf = 3LL * mod * mod;

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

lint modpow(lint x, lint n, lint m) {
	lint ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (m <= ans) ans %= m;
		}
		x *= x;
		if (m <= x) x %= m;
		n >>= 1;
	}
	return ans;
}

lint fact[1000000];
void f_init(lint n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

lint inver[1000000]; bool inve[100000];
lint inv(lint x) {
	if (x == 0) return 0;
	else if (inve[x]) return inver[x];
	else {
		inve[x] = true;
		return inver[x] = modpow(x, mod - 2, mod);
	}
}

lint comb(lint n, lint r) {
	if (n < r) return 0;
	if (n == r) return 1;
	lint ans = fact[n] * inv(fact[n - r]) % mod * inv(fact[r]) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

lint nck[1010][1010];
void comb(lint n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

lint gcd(lint a, lint b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

bool pri(lint p) {
	for (lint i = 2; i * i <= p; i == 2 ? ++i : i += 2) if (p % i == 0) return false;
	return p > 1;
}

map<lint, lint> factring(lint n) {
	map<lint, lint>ans;
	for (lint i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

double dis(D a, D b) { return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second)); }

int main() {
	string s;
	cin >> s;
	string k = s;
	reverse(all(k));
	int ans = 0;
	rep(i, s.size()) {
		if (s[i]!= k[i]) ++ans;
	}
	cout << ans / 2 << endl;
}

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

struct edge {
    int from, to;
};

using edges = std::vector<edge>;
using graph = std::vector<edges>;


class lowlink {
public:
    lowlink(graph const& g, int root)
        : ord(g.size()),
          low(g.size())
    {
        const int N = g.size();
        std::vector<bool> visited(N);
        int cnt = 0;
        for(int i=0; i<N; ++i) {
            if(!visited[i]) {
                dfs(i, -1, cnt, g, visited);
            }
        }
    }

    std::vector<int> get_articulation_points() const {
        return articulation_points;
    }

    std::vector<edge> get_bridges() const {
        return bridges;
    }

private:
    void dfs(int v, int prev, int& cnt, graph const& g, std::vector<bool>& visited) {
        visited[v] = true;
        ord[v] = cnt++;
        low[v] = ord[v];
        bool is_articulation = false;
        int cnt2 = 0;

        for(auto& e : g[v]) {
            if(e.to != prev && visited[e.to]) {
                low[v] = min(low[v], ord[e.to]);
            } else if(!visited[e.to]) {
                cnt2++;
                dfs(e.to, v, cnt, g, visited);
                low[v] = min(low[v], low[e.to]);
                if(prev != -1 && ord[v] <= low[e.to]) {
                    is_articulation = true;
                }
                if(ord[v] < low[e.to]) {
                    bridges.push_back(e);
                }
            }
        }

        if(prev == -1 && cnt2 > 1) {
            is_articulation = true;
        }
        if(is_articulation) {
            articulation_points.push_back(v);
        }
    }

private:
    std::vector<int> articulation_points;
    std::vector<edge> bridges;
    std::vector<int> ord;
    std::vector<int> low;
};

int main() {
    int V, E;
    cin >> V >> E;
    graph g(V);
    for(int i=0; i<E; ++i) {
        int s, t;
        cin >> s >> t;
        g[s].push_back(edge{s, t});
        g[t].push_back(edge{t, s});
    }
    lowlink ans(g, 0);
    auto ap = ans.get_articulation_points();
    sort(ap.begin(), ap.end());
    for(auto x : ap) {
        cout << x << endl;
    }
}


Measured memory_bytes: 5196
#include <stdio.h>

#define N 45

int F[N];

int makeFibonacci(){
  int i;
  F[0] = 1;
  F[1] = 1;
  for(i=2; i<N; i++){
    F[i] = F[i-2] + F[i-1];
  }
}

int main(){
  int num;
  scanf("%d",&num);
  makeFibonacci();
  printf("%d\n",F[num]);

  return 0;

}

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

int main(){
	int a, b, d, r;
	double f;
	cin >> a >> b;
	d = a / b;
	r = a % b;
	f = (double)a / b;
	cout << fixed;
	cout << d << " " << r << " " << setprecision(5) << f << endl;
	return 0;
}


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

int main() {
        int n, m;
        scanf("%d%d", &n, &m);
        vector<int> deg(n);
        vector<vector<int>> g(n);
        rep(i, m) {
                int a, b;
                scanf("%d%d", &a, &b);
                a --, b --;
                deg[a] ++;
                deg[b] ++;
                g[a].push_back(b);
                g[b].push_back(a);
        }
        int f = 0, s = 0;
        int p = -1, q = -1;
        rep(i, n) {
                if (deg[i] & 1) {
                        puts("No");
                        return 0;
                }
                if (deg[i] >= 4) {
                        f ++;
                        if (f == 1) {
                                p = i;
                        } else {
                                q = i;
                        }
                }
                s += deg[i] >= 6;
        }
        if (f >= 3 || s >= 1) {
                puts("Yes");
                return 0;
        }
        if (f < 2) {
                puts("No");
                return 0;
        }
        assert(f == 2);
        int c = 0;
        function<void (int, int)> dfs = [&](int u, int prev) {
                for (auto v : g[u]) if (v != prev) {
                        if (v == q) {
                                c ++;
                                continue;
                        } else if (v == p) {
                                continue;
                        }
                        dfs(v, u);
                }
        };
        dfs(p, -1);
        if (c == 4) {
                puts("No");
        } else if (c == 2) {
                puts("Yes");
        } else {
                assert(false);
        }
        return 0;
}


Measured memory_bytes: 7680
using System;
using System.Linq;
class c
{
    static void Main()
    {
        {
            var nm = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int n = nm[0], m = nm[1];
            var box = Enumerable.Repeat(1, n).ToArray();
            var judge = new bool[n];
            judge[0] = true;
            for (int i = 0; i < m; i++)
            {
                var xy = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
                int x = xy[0] - 1, y = xy[1] - 1;
                if (judge[x])
                {
                    judge[y] = true;
                    box[y]++;
                    box[x]--;
                    if (box[x] == 0) judge[x] = false;
                }
                else
                {
                    box[y]++;
                    box[x]--;
                }
            }
            Console.WriteLine(judge.Count(f => f == true));
        }
    }
}

Measured memory_bytes: 16608
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define f(x,n) for (int i=x;i<n;i++)

void knapsack(long long int price[],long long int weight[],int N,int W)
{
  long long int dp[101][100001];
 for(int n=0;n<=N;n++)
 {
  for(int w=0;w<=W;w++)
  {
    if(n==0 || w==0)
      dp[n][w]=0;
    else
    {
      long long int inc=0,exc=0;
      if(weight[n]<=w)
      {
        inc=price[n]+dp[n-1][w-weight[n]];
        exc=dp[n-1][w];
        dp[n][w]=max(inc,exc);
      }
      else
      {
        dp[n][w]=dp[n-1][w];
      }
    }
  }
 }
cout<<dp[N][W];
}
int main()
{
  int N,W;
  cin>>N>>W;
  long long int weight[N+1],price[N+1];
  for (int i=1;i<=N;i++)
  {
    cin>>weight[i]>>price[i];
  }

  knapsack(price,weight,N,W);
  return 0;
}

Measured memory_bytes: 82472
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int R = sc.nextInt();
		if(N >= 10) {
			System.out.println(R);
		} else {
			System.out.println(R + 1000 - 100 * N);
		}
	}
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> h(n), h2(n, 0);
    rep(i, n)
    {
        cin >> h.at(i);
    }

    // 高さが0になるまでやる
    int res = 0;
    while (true)
    {
        // 高さの最高が0だったらループを抜ける
        if (*max_element(h.begin(), h.end()) == 0)
            break;

        // 区間の分割を行う
        int i = 0;
        while (i < n)
        {
            if (h.at(i) == 0)
            {
                ++i; // 0なら何もしないで次に進む
            }
            else
            {
                ++res; // 区間の始まり
                while (i < n && h.at(i) > 0)
                {
                    --h.at(i); //高さを引く
                    ++i;       // 区間の終わりまで続ける
                }
            }
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding("utf8");

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

const lines = [];

reader.on("line", (line) => {
  lines.push(line);
});

reader.on("close", () => {
  let [a, b, l] = lines[0].split(" ").map(Number);
  l = (l * Math.PI) / 180;
  const h = Math.sin(l) * b;
  const c = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(l));
  console.log(((a * h) / 2).toFixed(5));
  console.log((a + b + c).toFixed(5));
  console.log(h.toFixed(5));
});



Measured memory_bytes: 20376
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN=100005;
const int Mod=1000000007;
const ll INF=(1LL<<61)-1;
ll s[MAXN],dif[MAXN],dp[MAXN][2],pre[MAXN][2];
ll rmq[20][MAXN],mm[MAXN];
void initRMQ(ll a[],int n)
{
    mm[0]=-1;
    for(int i=1;i<=n;i++)
        rmq[0][i]=a[i],mm[i]=mm[i-1]+((i&(i-1))==0);
    for(int i=1;i<=mm[n];i++)
        for(int j=1;j+(1<<i)-1<=n;j++)
            rmq[i][j]=min(rmq[i-1][j],rmq[i-1][j+(1<<(i-1))]);
}
ll cal(int l,int r)
{
    if(r<l)return INF;
    int k=mm[r-l+1];
    return min(rmq[k][l],rmq[k][r-(1<<k)+1]);
}
int main()
{
    int n;
    scanf("%d",&n);
    ll A,B;
    scanf("%lld%lld",&A,&B);
    if(A<B)swap(A,B);
    for(int i=1;i<=n;i++)
        scanf("%lld",&s[i]);
    s[0]=-INF,s[n+1]=INF;
    for(int i=1;i<=n+1;i++)
        dif[i]=s[i]-s[i-1];
    dp[0][1]=pre[0][1]=1;
    initRMQ(dif,n+1);
    for(int i=1;i<=n+1;i++)
    {
        int tl=0,tr=i-1;
        while(tl<tr)
        {
            int tm=(tl+tr+1)/2;
            if(s[i]-s[tm]>=A)tl=tm;
            else tr=tm-1;
        }
        int r=tl;
        tl=1,tr=i;
        while(tl<tr)
        {
            int tm=(tl+tr)/2;
            if(cal(tm+1,i-1)>=B)tr=tm;
            else tl=tm+1;
        }
        int l=tl-1;
        //printf("now %d [%d,%d]\n",i,l,r);
        for(int j=0;j<2;j++)
            pre[i][j]=pre[i-1][j];
        if(l>r)continue;
        if(r==i-1)
        {
            dp[i][1]=(dp[i][1]+dp[i-1][0]+dp[i-1][1])%Mod;
            r--;
        }
        if(l<=r)
        {
            for(int j=0;j<2;j++)
                dp[i][0]=((dp[i][0]+pre[r][j]-(l ? pre[l-1][j] : 0))%Mod+Mod)%Mod;
        }
        pre[i][0]=(pre[i][0]+dp[i][0]*(s[i+1]-s[i-1]>=B))%Mod;
        pre[i][1]=(pre[i][1]+dp[i][1])%Mod;
    }
    //for(int i=0;i<=n+1;i++)
    //    printf("%lld %lld\n",dp[i][0],dp[i][1]);
    printf("%lld\n",((dp[n+1][0]+dp[n+1][1])%Mod+Mod)%Mod);
    return 0;
}

Measured memory_bytes: 18176