akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
const long double PI = 3.141592653589793238462643383279502884197;

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

	int n; cin >> n;

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

		for (int x = 1; x <= sqrt(i); x++) {
			for (int y = 1; y <= sqrt(i); y++) {
				int val = i - (x * x + y * y + x * y);
				
				int L = 1, R = sqrt(i);
				while (L < R) {
					int z = (L + R) / 2;
					
					if (val <= z * z + (x + y) * z) R = z;
					else L = z + 1;
				}
				//cnt++;
				//if (val < L * L + (x + y) * L) cnt++;
				if (val == L * L + (x + y) * L) cnt++;
			}
		}

		cout << cnt << '\n';
	}

	return 0;
}

Measured memory_bytes: 3528
N = int(input())
d = []
for _ in range(N):
    d += [int(input())]

d = sorted(d, reverse=True)

dan = 1
current_size = d[0]

for i in range(1, N):
    if d[i] < current_size:
        dan += 1
        current_size = d[i]
print(dan)


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

int main(){
	int D;

	cin >> D;

	if(D == 25){
		cout << "Christmas" << endl;
	}
	else if(D == 24){
		cout << "Christmas Eve" << endl;
	}
	else if(D == 23){
		cout << "Christmas Eve Eve" << endl;
	}
	else if(D == 22){
		cout << "Christmas Eve Eve Eve" << endl;
	}






}

Measured memory_bytes: 256
c = [list(map(int, input().split())) for i in range(3)]

if c[0][0]+c[1][0]-2*c[2][0]+c[0][1]+c[1][1]-2*c[2][1]-2*c[0][2]-2*c[1][2]+4*c[2][2] == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

h,w,k=mp()
grid=[]
for i in range(h):
    grid.append(input())
ans=0
for i in range(2**h):
    for j in range(2**w):
        c=0
        for x in range(h):
            for y in range(w):
                if ((i>>x)&1) and ((j>>y)&1) and grid[x][y]=="#":
                    c+=1
        if c==k:
            ans+=1
print(ans)

Measured memory_bytes: 79000
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N, A[1 << 18], B[1 << 18], P[9];
int c1 = 0, c2 = 0, cnts = 0;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];
	for (int i = 0; i < N; i++) P[i] = i + 1;

	do {
		cnts++;
		bool flag1 = false;
		for (int i = 0; i < N; i++) { if (A[i] != P[i]) flag1 = true; }
		bool flag2 = false;
		for (int i = 0; i < N; i++) { if (B[i] != P[i]) flag2 = true; }
		if (flag1 == false) c1 = cnts;
		if (flag2 == false) c2 = cnts;
	} while (next_permutation(P, P + N));

	cout << abs(c1 - c2) << endl;
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<vector<int>> A(10, vector<int>(10, 0));
  for (int n = 1; n < N + 1; n++) {
    int x = n;
    while (x >= 10) {
      x /= 10;
    }
    A[x][n % 10]++;
  }
  int res = 0;
  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      res += A[i][j] * A[j][i];
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <queue>
#include <numeric>
#include <stack>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int x3, y3, x4, y4;
  
  x3 = x2 - (y2 - y1);
  y3 = y2 + (x2 - x1);

  x4 = x1 - (y2 - y1);
  y4 = y1 + (x2 - x1);

  printf("%d %d %d %d\n", x3, y3, x4, y4);

    return 0;
}








Measured memory_bytes: 888
#include <iostream>
#include <cmath>
#include <vector>

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

bool check_prime(vector<int> v, int num) {
    int i = 0;
    while (v[i] <= sqrt(num)) {
        if (num % v[i] == 0) {
            return false; 
        }
        i++;
    }
    return true;
}

int main(void) {
    vector<int> v;
    vector<int> prime;
    v.push_back(6); 
    for (int i = 13; i - 5 < 300000; i+=7) {
        v.push_back(i - 5); 
        v.push_back(i); 
    }
    for (int i = 0; i < v.size(); i++) {
        if (check_prime(v, v[i]) == true) {
            prime.push_back(v[i]); 
        }
    }

    int number;
    int k;
    bool p_check;
    while (1) {
        cin >> number;
        if (number == 1) {
            break;
        }
        cout << number << ":"; 
        k = 0; 
        p_check = false;
        while (prime[k] < number) {
            if (number % prime[k] == 0) {
                cout << " " << prime[k];
                p_check = true;
            }
            k++;
        }
        if (p_check == false) {
            cout << " " << number;
        }
        cout << endl;
    }

    return 0;
}

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

const int MAXN = 1e5 + 5;
int h[MAXN], dp[MAXN];
int n, k;

void input();
void solve();

int main() {
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	input();
	solve();
	return 0;
}

void input() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> h[i];
}

void solve() {
	memset(dp, 63, sizeof dp);
	dp[0] = 0;
	for (int i = 0; i < n; i++)
		for (int j = 1; j <= k; j++)
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
	cout << dp[n - 1];
}


Measured memory_bytes: 1024
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

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

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

void solve() {
    inl(N, A, B);
    vll X(N);
    rep(i, N) cin >> X[i];

    ll ret = 0;
    rep(i, N - 1)
        ret += min(A * (X[i + 1] - X[i]), B);
    out(ret);
}


Measured memory_bytes: 3996
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <map>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>
 
using namespace std;
#define set_precision cout << fixed << setprecision(10)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define replb(i, a, b) for (ll i = a; i >= b; i--)
#define repl(i, a, b) for (ll i = a; i < b; i++)
#define repit(arr) for (auto it = arr.begin(); it != arr.end(); it++)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define vpi vector<pair<int,int>>
#define seti set<int>
#define setl set<ll>
#define dseti set<int, greater<int>>
#define dsetl set<ll, greater<ll>>
#define mseti multiset<int>
#define msetl multiset<ll>
#define dmseti multiset<int, greater<int>>
#define dmsetl multiset<ll, greater<ll>>
#define sortA(arr) sort(arr.begin(), arr.end())
#define dsortA(arr) sort(arr.begin(), arr.end(), greater<int>())
#define ssort(arr) stable_sort(arr.begin(), arr.end())
#define search(arr, c) binary_search(arr.begin(), arr.end(), c)
#define pb push_back
#define ll long long
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define castl static_cast<ll>
#define BRAHAMASTRA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ull unsigned long long int

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

    long long k;
    cin >> k;
 
    long long i = 0;
    long long val = 0;
 
    while (true) {
        i++;
        val = val * 10 + 7;
        long long rem = val % k;
        if (rem == 0) {
            break;
        }
        if (i > k) {
            i = -1;
            break;
        }
        val = rem;
    }
    cout << i << endl;
 
    return 0;
}

Measured memory_bytes: 3640
N = int(input())
C = []
S = []
F = []
for i in range(N-1):
  c, s, f = map(int, input().split())
  C.append(c)
  S.append(s)
  F.append(f)

def process(i, t):
  if i == N-1:
    return t
  if t <= S[i]:
    return process(i+1, S[i]+C[i])
  elif t % F[i] == 0:
    return process(i+1, t+C[i])
  else:
    t2 = ((t//F[i])+1)*F[i]
    return process(i+1, t2+C[i])

for i in range(N):
  print(process(i, 0))

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

const int Z = 63;
int N, A[Z+1][200200];
long long K;

int main()
{
	cin.tie(NULL);ios_base::sync_with_stdio(false);

	cin >> N >> K;
	for (int i = 1; i <= N; i++) cin >> A[0][i];
	for (int j = 1; j <= Z; j++) for (int i = 1; i <= N; i++) A[j][i] = A[j - 1][A[j - 1][i]];

	int x = 1;
	for (int j = 0; K; j++, K /= 2){
		if (K & 1) x = A[j][x];
	}

	cout << x << endl;

	return 0;
}

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

//temmplate------
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define INF 1e9
#define ZERO(a) memset(a, 0, sizeof(a))
typedef long long lint;
//------template

int main(){
    string S;
    string T;
    string U;
    int A;
    int B;
    cin >> S >> T >> A >> B >> U;
    if (S == U){
        A -= 1;
    } else {
        B -= 1;
    }
    cout << A << " " << B << "\n";
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns, MultiWayIf #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Int
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> Int -> VU.Vector Int32 -> Int32
solve !n !k !an = VU.last $ V.last dp
 where
  big = 10 ^ 9 + 7

  plus x y = let z = x + y in if z >= big then z - big else z
  minus x y = let z = x - y in if z < 0 then z + big else z

  dp :: V.Vector (VU.Vector Int32)
  dp = V.postscanl'
    (\(!dpi) (!i) -> VU.scanl'
      (\(!dpij) (!j) ->
        let !p = if j - fromIntegral (an VU.! i) - 1 >= 0
              then dpi VU.! (j - fromIntegral (an VU.! i) - 1)
              else 0
            !q = dpi VU.! j
            !a = dpij `plus` q `minus` p
        in  a
      )
      1
      (VU.generate k (+ 1))
    )
    (VU.cons 1 $ VU.replicate k 0)
    (V.convert $ VU.generate n id)

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (n, k) <-
    (\(!vec) -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
  an <- VU.unfoldrN n readInt <$> B.getLine
  print $ solve n k an


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

int main() {
  int n;cin>>n;
  int ans=0;
  for(int k=1; k<=n; k+=2) {
    int c=0;
    for(int i=1; i<=k; i++) {
      if(k%i==0) c++;
    }
    if(c==8)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

inline char shift(char c, int x) {
    int d;
    char nc;
    if(c >= 'a' && c <= 'z') {
        nc = (char)(c - x);
        if(nc >= 'a' && nc <= 'z') {
            return nc;
        }
        d = 'a' - nc;
        return shift('Z', d - 1);
    } else {
        nc = (char)(c - x);
        if(nc >= 'A' && nc <= 'Z') {
            return nc;
        }
        d = 'A' - nc;
        return shift('z', d - 1);
    }
} 

int main() {
    int n;
    std::vector<int> k(100);
    std::string s;

    int i, l;
    while(std::cin >> n, n != 0) {
        for(i = 0; i < n; ++i) {
            std::cin >> k[i];
        }
        std::cin >> s;

        l = s.length();
        for(i = 0; i < l; ++i) {
            std::cout << shift(s[i], k[i % n]);
        }
        std::cout << std::endl;
    }
}


Measured memory_bytes: 3136
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int c[200100];
ll memo[200100];
ll dp[200100];

ll solve() {
    vector<int> v;
    int idx = 0;
    while (idx < n) {
        v.push_back(c[idx]);
        int a = 0;
        while (idx+a<n && c[idx] == c[idx+a]) a++;
        idx += a;
    }

    dp[0] = 1;
    const int sz = (int)v.size();
    for (int i = 1; i <= sz; i++) {
        dp[i] = dp[i-1];
        dp[i] += memo[v[i-1]];
        dp[i] %= mod;
        memo[v[i-1]] += dp[i-1];
        memo[v[i-1]] %= mod;
    }
    
    return dp[sz];
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> c[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 7904
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <iomanip>
#define For(i,j,k) for(int i=j;i<=k;i++)
#define Dow(i,j,k) for(int i=j;i>=k;i--)
#define LL long long
using namespace std ;
inline int read() {
	int x = 0 , f = 1 ;
	char ch = getchar() ;
	while(ch<'0'||ch>'9') { if(ch=='-') f = -1 ; ch = getchar() ; }
	while(ch>='0'&&ch<='9') { x = x * 10+ch-48 ; ch = getchar() ; }
	return x * f ;
}

const int N = 1e5+11;
int n,sum,tot;
int a[N];

int main() {
	n=read(); 
	For(i, 1, n) a[i]=read();
	sort(a+1,a+n+1);
	a[0] = a[1]-1;
	For(i, 1, n) 
		if(a[i]==a[i-1]) sum++;
		else {
			if(sum&1) tot++;
			sum = 1;
		}
	if(sum&1) tot++;
	printf("%d\n",tot);
}









Measured memory_bytes: 1016
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int r = Integer.parseInt(sc.next());
        int g = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int diff = g - r;
        int result = r + diff * 2;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21716
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CirclePond solver = new CirclePond();
        solver.solve(1, in, out);
        out.close();
    }

    static class CirclePond {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            pw.println(2d * sc.nextInt() * Math.PI);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

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

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

    }
}



Measured memory_bytes: 32968
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;
typedef vector<ll> vll;
ll mod = 1000000007;
ll INF = 10000000000000000;
ll gcd(ll a, ll b){if (b==0){return a;}return gcd(b, a%b);}
// for (ll i = 0; i < n; i++) {
// sort(.begin(),.end());
int main(){
  ll n, X;
  cin >> n >> X;
  vll x(n), G(n);
  for (ll i = 0; i < n; i++) {
    cin >> x[i];
    x[i] = abs(x[i] - X);
  }
  
  G[0] = x[0];
  for (ll i = 1; i < n; i++) {
    G[i] = gcd(G[i-1], x[i]);
  }
  
  cout << G[n-1] << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
	int n[5];
	scanf("%d%d%d%d%d", &n[0],&n[1],&n[2],&n[3],&n[4]);
	printf("%s", n[0] == 0 ? "1" :
					n[1] == 0 ? "2" :
					n[2] == 0 ? "3" :
					n[3] == 0 ? "4" :
					"5"
					);
	return 0;
}


Measured memory_bytes: 1708
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 100000007
typedef long long ll;
using namespace std;

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


Measured memory_bytes: 256
n, t = gets.split.map(&:to_i)
costTime = readlines.map(&:chomp).map(&:split).map {|i| i.map(&:to_i)}

arr = []
costTime.map do |x, y|
  if (y <= t)
    arr << x
  end
end

if arr.empty?
  puts "TLE"
else
  puts arr.min
end


Measured memory_bytes: 1788
#include<cstdio>
#include<cstring>
using namespace std;
char s[1000000];
int main()
{
    scanf("%s",s);
    int l=strlen(s);
    for(int i=0;i<l;i++)
        if(s[i]=='9')
            return 0*printf("Yes");
    return 0*printf("No");
}

Measured memory_bytes: 128
import java.util.*;
public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = null;
        sc = new Scanner(System.in);
        String s = sc.nextLine();	
        String t = sc.nextLine();
        sc.close();	
        char[] cs = s.toCharArray();
        char[] ct = t.toCharArray();
        int count = 0;
        for (int i = 0; i < cs.length; i++) {
            if (cs[i] != ct[i]) {
                count +=1;
            } 
        }
        System.out.println(count);   
    }
    
}

Measured memory_bytes: 43132
#include <iostream>
using namespace std;
string a;
int main() {
	cin>>a;
	cout<<(a[0]=='1' ? 9 : 1);
	cout<<(a[1]=='1' ? 9 : 1);
	cout<<(a[2]=='1' ? 9 : 1);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int K = sc.nextInt();
    int[] A = new int[M];
    int[] B = new int[M];
    for (int i = 0; i < M; i++) {
      A[i] = sc.nextInt();
      B[i] = sc.nextInt();
    }
    int[] C = new int[K];
    int[] D = new int[K];
    for (int i = 0; i < K; i++) {
      C[i] = sc.nextInt();
      D[i] = sc.nextInt();
    }
    sc.close();
    /*
    */

    @SuppressWarnings("unchecked")
    Set<Integer>[] g = new Set[N + 1];
    int[] fc = new int[N + 1];
    for (int i = 0; i < M; i++) {
      int a = A[i];
      int b = B[i];
      if (g[a] == null && g[b] == null) {
        Set<Integer> set = new HashSet<>();
        set.add(a);
        set.add(b);
        g[a] = set;
        g[b] = set;
      } else if (g[a] == null) {
        Set<Integer> set = g[b];
        set.add(a);
        g[a] = set;
      } else if (g[b] == null) {
        Set<Integer> set = g[a];
        set.add(b);
        g[b] = set;
      } else if (g[a] != g[b]) {
        Set<Integer> setL = g[a];
        Set<Integer> setS = g[b];
        if (setL.size() < setS.size()) {
          Set<Integer> temp = setL;
          setL = setS;
          setS = temp;
        }
        setL.addAll(setS);
        for (int c : setS) g[c] = setL;
      }
      fc[a]++;
      fc[b]++;
    }

    int[] bc = new int[N + 1];
    for (int i = 0; i < K; i++) {
      int c = C[i];
      int d = D[i];
      if (g[c] == g[d]) {
        bc[c]++;
        bc[d]++;
      }
    }
    /*
    sc.close();
    */

    int[] ans = new int[N + 1];
    for (int i = 1; i < N + 1; i++)
      if (g[i] != null)
        ans[i] = g[i].size() - 1 - fc[i] - bc[i];

    StringBuilder buf = new StringBuilder();
    for (int i = 1; i < N + 1; i++)
      buf.append(ans[i]).append(' ');
    System.out.println(buf);
  }
}

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

using namespace std;

int n, x, y;
string s;

int main()
{
    cin >> s;
    n = s.size();
    for(int i = 0; i < n; i++){
        if(s[i] == 'A'){
            x = i;
            break;
        }
    }
    for(int i = n - 1; i >= 0; i--){
        if(s[i] == 'Z'){
            y = i;
            break;
        }
    }
    cout << y - x + 1;
    return 0;
}


Measured memory_bytes: 640
import math


a, b, c, d = map(int, input().split())
#arr - list(map(int, input().split()))
#s = input()

i = 0
while a:
	if i % 2 == 0:
		c -= b
		if c <= 0:
			print('Yes')
			exit()
	else:
		a -= d
		if a <= 0:
			print('No')
			exit()
	i += 1

Measured memory_bytes: 9176
#include <iostream>
#include <numeric>
using namespace std;
int main () {
	int n;
	while (cin >> n, n) {
		int d[10][10];
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				d[i][j] = ((i == j) ? 0 : 0xffffff);
			}
		}
		int v = 0;
		for (int i = 0; i < n; i++) {
			int a, b, c;
			cin >> a >> b >> c;
			d[a][b] = d[b][a] = c;
			v = max(a, max(b, v));
		}
		v++;
		// ワーシャルフロイド法
		for (int k = 0; k < v; k++) {
			for (int i = 0; i < v; i++) {
				for (int j = 0; j < v; j++) {
					// pathを1つの辺と考えることで，
					// 直接行く場合とそうでない場合を考える問題とすることができる
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
		int minPos;
		int minPosTotal = 0x7fffffff;
		for (int i = 0; i < v; i++) {
			int total = accumulate((int*) d[i], d[i] + v, 0);
			//cout << total << endl;
			if (total < minPosTotal) {
				minPos = i;
				minPosTotal = total;
			}
		}
		cout << minPos << ' ' << minPosTotal << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define e "\n"
#define MaRiaMa { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
#define fix(n) cout << fixed << setprecision(n);
using namespace std;
int main()
{
	MaRiaMa;
	int n,k=0;
	cin >> n;
	vi p(n);
	string s;
	cin >> s;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'I')
		{
			k++;
			p[i] = k;
		}
		else
		{
			k--;
			p[i] = k;
		}
	}
	sort(p.begin(), p.end(),greater<int>());
	if (p[0] > -1)
		cout << p[0];
	else
		cout << "0";
}

Measured memory_bytes: 3616
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
	int N;
  	cin >> N;
  	vector<int> H(N);
  	vector<int> change(N,0);
  	rep(i,N) cin >> H[i];
  
  	rep(i,N-1){
    	if(H[i] == H[i+1]){
          	change[i+1]++;
          	//cout << "case1: " << i << ": " << H[i] << " " << H[i+1] << endl;
        }
      	else if(H[i] < H[i+1] && change[i+1] == 0){
        	H[i+1]--;
          	change[i+1]++;          	
          	//cout << "case2: " << i << ": " << H[i] << " " << H[i+1] << endl;
        }
      	else if(H[i] == H[i+1]+1 && change[i] == 0){
        	H[i]--;
          	change[i]++;
          	change[i+1]++;
          	//cout << "case3: " << i << ": " << H[i] << " " << H[i+1] << endl;
        }
      	else{
          	//cout << "case4(No): " << i << ": " << H[i] << " " << H[i+1] << endl;
        	puts("No");
          	return;
        }
    }
  	puts("Yes");
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


struct edge{int to;ll cap;int rev;};
struct Dinic{
private:
    int n;
    vector<vector<edge>> v;
    vector<int> dist,iter;
public:
    Dinic(int sz):n(sz),v(sz),dist(sz),iter(sz){}
    
    void addedge(int from,int to,ll cap){
        int x=v[to].size(),y=v[from].size();
        v[from].push_back({to,cap,x});
        v[to].push_back({from,0,y});
    }
    
    void bfs(int s){
        fill(dist.begin(),dist.end(),-1);
        queue<int> q;
        dist[s]=0;
        q.push(s);
        while(q.size()){
            int x=q.front();q.pop();
            rep(i,v[x].size()){
                edge &e=v[x][i];
                if(e.cap>0&&dist[e.to]<0){
                    dist[e.to]=dist[x]+1;
                    q.push(e.to);
                }
            }
        }
    }
    
    ll dfs(int x,int t,ll f){
        if(x==t)return f;
        for(int& i=iter[x];i<(int)v[x].size();++i){
            edge& e=v[x][i];
            if(e.cap>0&&dist[x]<dist[e.to]){
                ll d=dfs(e.to,t,min(f,e.cap));
                if(d>0){
                    e.cap-=d;
                    v[e.to][e.rev].cap+=d;
                    return d;
                }
            }
        }
        return 0;
    }

    ll max_flow(int s,int t){
        ll flow=0;
        while(1){
            bfs(s);
            if(dist[t]<0)return flow;
            fill(iter.begin(),iter.end(),0);
            ll f;
            while((f=dfs(s,t,1LL<<62))>0)flow+=f;
        }
    }
};
int main(){
    int h,w;
    cin>>h>>w;
    string s[h];
    rep(i,h)cin>>s[i];
    Dinic dn(h+w+2);
    rep(i,h)rep(j,w){
        if(s[i][j]!='.'){
            dn.addedge(i, h+j, 1);
            dn.addedge(h+j, i, 1);
        }
        if(s[i][j]=='S'){
            dn.addedge(h+w, i, inf);
            dn.addedge(h+w, j+h, inf);
        }
        if(s[i][j]=='T'){
            dn.addedge(i, h+w+1, inf);
            dn.addedge(j+h, h+w+1, inf);
        }
    }
    int ret = dn.max_flow(h+w, h+w+1);
    cout<<(ret>=inf?-1:ret)<<endl;
    return 0;
}

Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long k = sc.nextLong();
		long d = sc.nextLong();
		x = Math.abs(x);

//		if (0 < x) {
			if (x / d < k) {
				if ((k - x / d) % 2 == 0) {
					System.out.println(Math.abs(x - (x / d * d)));
				} else {
					System.out.println(Math.abs(x - (x / d * d) - d));
				}
			} else {
				System.out.println(Math.abs(x - k * d));
			}
//		}



		sc.close();

	}

}

Measured memory_bytes: 35660
#include<cstdio>
#include<cstring>
using namespace std;
int flag[100010];
int a[100010];
int main()
{
	int N;
	while(~scanf("%d",&N))
	{
		memset(flag,0,sizeof flag);
		for(int i=1;i<=N;i++)
		{
			scanf("%d",&a[i]);
			flag[a[i]]++;
		}
		int num1=0,num2=0;
		bool sign = false;
			for(int i=1;i<=N;i++)
			{
				if(N%2==0){
				if(flag[a[i]]!=2)
				{
					sign = true;
					break;
				}}
				else 
				{
					if(flag[a[i]]==1&&a[i]==0)
					num1++;
					if(flag[a[i]]==2)
					num2++;
					
				}
			}
			if(N%2==0)
			if(sign)
			{
				printf("0\n");
				continue;
			}
			if(N%2!=0){
			if(num1==1&&num2==N-1);
			else 
			{
				printf("0\n");
				continue;
			}}
		long long ans = 1;
		if(N%2==0)
		{
			//long long ans = 1;
			for(int i=1;i<=N/2;i++)
			ans *= 2ll,ans %= 1000000000+7;
			
		}
		else 
		{
			for(int i=1;i<=(N-1)/2;i++)
			ans *= 2ll,ans %= 1000000000+7;
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
int k;
cin>>k;
  for(int i=0; i<n; i++){
    cin>>a[i];
  }
    sort(a,a+n);
    reverse(a,a+n);
    int sum = 0;
    
    for(int j = 0; j<k; j++){
        sum = sum+a[j];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,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 fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll 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())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  char s; cin >> s;
  if(isupper(s)) cout << "A" << endl;
  else cout << "a" << endl;
}


Measured memory_bytes: 3512
import math

def solve():
    [D,G] = [int(x) for x in input().split()]
    P = []
    C = []
    for _ in range(D):
        [p,g] = [int(x) for x in input().split()]
        P.append(p)
        C.append(g)

    LIM = 1 << D
    ans = 10**12  # INF 
    for bits in range(LIM):
        score = 0
        count = 0
        for i in range(D):
            maxi = -1
            if (bits >> i) & 1 == 1:
                # use all
                # print("useall", i, P[i])
                score += P[i] * 100 * (i+1) + C[i]
                count += P[i]

        if G <= score:
            # print("ans, count", ans, count)
            ans = min(ans, count)
            continue

        # use 中途半端
        for i in range(D):
            if (bits >> i) & 1 != 1:
                n = (G-score) / ((i+1)*100)
                # print("n", n)
                if n >= P[i]:
                    continue

                n = int(math.ceil(n))
                # print("cn", count + n)
                ans = min(ans, count + n)
    # print(ans)
    return ans


print(solve())


Measured memory_bytes: 3064
(defun solve (k s)
  (loop for x from 0 to (min k s)
        sum (loop for y from 0 to (min k (- s x))
                  count (<= (- s x y) k))))

#-swank
(let* ((k (read))
       (s (read)))
  (format t "~A~%" (solve k s)))


Measured memory_bytes: 13160
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
#define SYOU(x) fixed<<setprecision(x) //小数点桁数を指定する
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){
    STR(S);
    if(S[2]==S[3] && S[4]==S[5]){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
   
}

Measured memory_bytes: 256
def main():
    mod = 10 ** 9 + 7
    n, m = map(int, input().split())
    a = [int(x) for x in input().split()]

    if not m:
        print(0)
        return
    
    mx = [0] * (n + 1)
    mn = [mod] * (n + 1)
    
    for i in range(n):
        if mx[i] > a[i]:
            mx[i + 1] = mx[i]
        else:
            mx[i + 1] = a[i]
    for i in range(n - 1, -1, -1):
        if mn[i + 1] < a[i]:
            mn[i] = mn[i + 1]
        else:
            mn[i] = a[i]
    
    dp = [0] * (n + 1)
    
    dp[1] = 2

    for i in range(1, n):

        ndp = [0] * (n + 1)

        check0 = mx[i + 1] == a[i]
        check1 = mn[i + 1] >= mx[i]
        check2 = mn[i] == a[i]

        if check0:
            if check1:
                for j in range(i + 1):
                    ndp[j + 1] += dp[j]
                    ndp[i - j + 1] += dp[j]

            else:
                for j in range(i + 1):
                    ndp[j + 1] += dp[j]


        else:
            if check2:
                for j in range(i + 1):
                    ndp[j] += dp[j]

        dp = [x % mod for x in ndp]
        
    ans = 0
    for i in range(n - m, m + 1):
        ans += dp[i]
        ans %= mod

    print(ans)

if __name__ == "__main__":
    main()



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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N, 0);
  for( int i=0; i<N; i++ ){
    cin >> a.at(i);
    a.at(i)--;
  }
  
  int cur = 0;
  for( int i=0; i<N; i++ ){
    cur = a.at(cur);
    if( cur == (2 - 1) ){
      cout << (i + 1) << endl;
      return 0;
    }
  }
  
  cout << -1 << endl;
}

Measured memory_bytes: 3764
#include<stdio.h>
int main(void)
{
        int a,b,k,i,j=0,s[1000000];
        scanf("%d %d %d",&a,&b,&k);
        for(i=a;i<=b;i++)
                if((i<a+k)||(i>b-k)){s[j]=i; j++;}
        for(i=0;i<j;i++) printf("%d\n",s[i]);
        return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;
    int M;
    int[] H;
    int[] A;
    int[] B;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.N = sc.nextInt();
        this.M = sc.nextInt();
        this.H = new int[N+1];
        this.A = new int[M];
        this.B = new int[M];
        for (int i = 1; i <= N; i++) {
        	this.H[i] = sc.nextInt();
        }
        for (int i = 0; i < M; i++) {
        	this.A[i] = sc.nextInt();
        	this.B[i] = sc.nextInt();
        }
    }
    
    //解答処理
    private int solve() {
        int count = 0;
        int[] m = new int[N+1];
        
        for (int i = 0; i < M; i++) {
        	m[A[i]] = Math.max(m[A[i]], H[B[i]]);
        	m[B[i]] = Math.max(m[B[i]], H[A[i]]);
        }
        
        for (int i = 0; i <= N; i++) {
        	if (m[i] < H[i]) {
        		count++;
        	}
        }
        
        return count;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }

}


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

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
	int q; cin >> q;
	long double theta1, theta2;
	theta1 = atan2(y2 - y1, x2 - x1);
	while (q--) {
		int x, y; cin >> x >> y;
		theta2 = atan2(y - y1, x - x1);
		long double dist = hypot(x - x1, y - y1) * cos(theta2 - theta1);
		long double dist_x = dist*cos(theta1), dist_y = dist*sin(theta1);
		cout << fixed << setprecision(11) << x1 + x1 + (dist_x - x) + dist_x << " " << y1 + y1 + (dist_y - y) + dist_y << endl;
		//                                       (  dist from p1.x to p.x)                  ( dist from p1.y to p.y)
	}
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int>list(M);
  for(int i=0;i<N;i++){
    int K;
    cin>>K;
    for(int j=0;j<K;j++){
      int A;
      cin>>A;
      list.at(A-1)=list.at(A-1)+1;
    }
  }
  int count=0;
  for(int i=0;i<M;i++){
    if(list.at(i)==N){
      count=count+1;
    }
    else{
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
// 大文字小文字エラー回避→プログラム中は小文字で統一
#define yes "Yes" 
#define no "No" 
#define black '#'
using namespace std;

// Problem https://atcoder.jp/contests/abc096/tasks/abc096_c
// Refference1 https://atcoder.jp/contests/abc096/submissions/2447972
//           (https://img.atcoder.jp/abc096/editorial.pdf)
// Refference2 https://atcoder.jp/contests/abc096/submissions/2470276

int main(void){
    bool answer;   
    answer = true;
    int H,W;
    cin >> H >> W;
    vector<string> canpus;
    canpus.clear();
    for(int j=0;j<H;j++){
        string oneLine;
        cin >> oneLine;
        canpus.push_back(oneLine);
    }
    // チェック方向
    vector<int> dh = {1,0,-1,0};
    vector<int> dw = {0,1,0,-1};
    for(int j=0;j<H;j++){
        for(int k=0;k<W;k++){
            if(canpus.at(j).at(k)==black){
//                cout << "Now ("<< j << "," << k <<") is checking." << endl;
                int blackCounter;
                blackCounter = 0;
                for(int dir=0;dir<4;dir++){
                    int nowH,nowW;
                    nowH = j+dh.at(dir);
                    nowW = k+dw.at(dir);
//                    cout << "\t dir ("<< nowH << "," << nowW <<") is checking" << endl;
                    if(nowH < 0 || (H-1) < nowH || 
                    nowW < 0 || (W-1) < nowW){
//                        cout << "\t\t Oh !!  ("<< nowH << "," << nowW <<
//                        ") is out of canpus!." << endl;
                        continue;
                    } // if(nowH < 0 || ...)
                    if(canpus.at(nowH).at(nowW)==black){
                        blackCounter = blackCounter + 1;
//                        cout << "\t\t OK  ("<< nowH << "," << nowW <<
//                        ") is black. ("<< j << "," << k << ") blackCounter=" 
//                        << blackCounter << endl;
                    } // if(canpus.at(nowH).at(nowW)...)
                } // for(int dir=0;dir<4 ...)
                if(blackCounter==0)
                {
//                    cout << "point(" << j << "," << k << ") is rount no black!!" << endl;
                    answer = false;    
                } // if(blackCounter == 0...)
            }// if(canpus.at(j).at(k)==black...)
            else{
                continue;
            }//   if(canpus.at(j).at(k)==black...) のelse        
            }
            }
        if(answer){
        cout << yes << endl;
    }
    else{
        cout << no << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD=1000000007;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main()
{
    
    while(1){
        ll N;
        cin >> N;
        if ( N == 0 )   break;

        vector<ll> dp(N+1, 0);
        dp[0] = 1;

        for ( ll i = 0; i < N; ++ i ){
            for ( ll j = 1; j <= 3; ++ j ){
                ll n = i + j;
                if ( n > N )    break;
                dp[n] += dp[i];
            }
        }

        auto ans =static_cast<ll>( ceil((float)dp[N] / ( 10.f * 365)));

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


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

int n;
pair<int, int> schedule[200004];
int main() {
	cin>>n;
	for(int i = 0;i<n;i++){
		int a, b;
		cin>>a>>b;
		schedule[i] = {b, a};
	}
	sort(schedule, schedule + n);
	int cur = 0;
	for(int i = 0;i<n;i++){
		if(schedule[i].second + cur > schedule[i].first){
			cout<<"No";
			return 0;
		}
		cur += schedule[i].second;
	}
	cout<<"Yes";
	return 0;
}


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

int main(){
 int n,l;
  cin>>n;
vector<string> m(n);
  for(int i=0;i<n;i++){
    cin>>m[i];
    if(i>0){
    if((m[i-1])[l-1]!=(m[i])[0]){
      cout<<"No"<<endl;
      return 0;
    }
    }
    l=(m[i]).size();
    for(int j=0;j<i;j++){
      if(m[i]==m[j]){
        cout<<"No"<<endl;
      return 0;
      }
    }
    if(i==n-1){
      cout<<"Yes"<<endl;
      return 0;
    }
  }



}



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

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  int x, y;
  cin >> x >> y;

  if ((x + y) % 3 != 0) {
    cout << 0 << endl;
    return 0;
  }

  int n = (x + y) / 3;
  x -= n, y -= n;

  if (x < 0 || y < 0) {
    cout << 0 << endl;
    return 0;
  }

  combination comb(x + y);
  mint ans = comb(x + y, x);
  cout << ans.x << endl;

  return 0;
}


Measured memory_bytes: 13440
import re
S = input().strip()
while True:
  #print(S)
  if len(S) == 0:
    print('YES')
    break
  if S[-5:] == 'dream':
    S = S[:-5]
  elif S[-7:] == 'dreamer':
    S = S[:-7]
  elif S[-5:] == 'erase':
    S = S[:-5]
  elif S[-6:] == 'eraser':
    S = S[:-6]
  else:
    print('NO')
    break
    

Measured memory_bytes: 133880
n = int(input())
h = list(map(int, input().split()))
l = [0] * n
t = 0

for i in reversed(range(0, len(h))):
    if i > 0:
        if h[i] <= h[i-1]:
            t+=1
            l[i-1] = t
        else:
            t = 0
print(max(l))

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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main() {
  int n;
	cin >> n;
	vector<char> ma(n);
	REP(i,n) cin >> ma[i];
	int f = 1;
	int F = n/2;
	f *= (n%2==0);
	REP(i,F) if(ma[i] != ma[i+F]) f=0;
	string ans = "No";
	if (f) ans = "Yes";
  cout << ans << endl;
}


Measured memory_bytes: 3620
N = int(input())
tlist = list(map(int, input().split()))
vlist = list(map(int, input().split()))
vlist.append(0)
flag = True
while flag:
    flag =  False
    for i in range(N):
        if vlist[i]-vlist[i+1] > tlist[i]:
            vlist[i] = vlist[i+1]+tlist[i]
            flag = True
speed = 0
x = 0
for i in range(N):
    ti = tlist[i]
    vi = vlist[i]
    vj = vlist[i+1]
    if vi <= vj:
        if vi-speed <= ti:
            x += ti*vi - ((vi-speed)**2)/2
            speed = vi
        else:
            x += ti*(speed+ti) - (ti**2)/2
            speed += ti
    else:
        if speed+ti <= vj:
            x += ti*(speed+ti) - (ti**2)/2
            speed += ti
        elif 2*vi-speed-vj <= ti:
            x += ti*vi - ((vi-speed)**2)/2 - ((vi-vj)**2)/2
            speed = vj
        else:
            a = (ti+vj-speed)/2
            x += a*(2*speed+a)/2 + (ti-a)*(2*vj+ti-a)/2
            speed = vj
print(x)

Measured memory_bytes: 3064