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

//#define int long long

using namespace std;

int num[4];
int op[3];//'+' = 1, '-' = -1

//関数funcを作る
void func(int deep)
{
    if (deep == 3)
    {
        //計算結果が7にならないとき
        if (num[0] + op[0] * num[1] + op[1] * num[2] + op[2] * num[3] != 7)
        {
            //関数を終了
            return;
        }

        cout << num[0] << (op[0] == 1 ? '+' : '-') << num[1] << (op[1] == 1 ? '+' : '-') << num[2] << (op[2] == 1 ? '+' : '-') << num[3] << "=7\n";

        exit(0);
    }

    op[deep] = 1;
    func(deep + 1);

    op[deep] = -1;
    func(deep + 1);
}

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

    string in;
    cin >> in;

    for (int i = 0; i < 4; ++i)
    {
        num[i] = in[i] - '0';
    }

    //関数funcを呼ぶ
    func(0);
}


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

int main(){
  int n;
  cin >> n;
  int a = 0, b = 0, ans = 0, ab = 0;
  rep(i, n) {
    string s;
    cin >> s;
    rep(j, s.length() - 1) {
      if(s[j] == 'A' && s[j + 1] == 'B') ++ans;
    }
    if(s[0] == 'B' && s.back() == 'A') ++ab;
    else if(s[0] == 'B') ++b;
    else if(s.back() == 'A') ++a;
  }
  if(a == 0 && b == 0) {
    ans += max(0, ab - 1);
  } else {
    ans += ab + min(a, b);
  }
  cout << ans << endl;
};

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

int main(){
  string s;
  int count;
  long k;
  cin >> s >> k;
  for(int i = 0; i < s.size(); i++){
    if( s[i] == '1' ){
      count++;
    }else{
      break;
    }
  }
  if ( count == s.size() || count >= k ){
    cout << 1 << endl;
  }else{
    cout << s[count] << endl;
  }
}
  

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

typedef long long ll;

int main(void) {
	ll N,sum=0;
	cin >> N;

	for (ll i = 1; i <= N; i++) {
		if ((i % 3 != 0) && (i % 5 != 0)) sum = sum + i;
	}

	cout << sum << endl;
}


Measured memory_bytes: 3636
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
const int mod=1000000007;
const llint big=1e18+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<int>&ar,int in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<int>&ar,int in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int a,b,i,j;cin>>a>>b;
	cout<<"100 100"<<endl;
	vector<string>mat(100);
	for(i=0;i<50;i++){mat[i]=string(100,'.');}
	for(i=50;i<100;i++){mat[i]=string(100,'#');}
	for(i=0;i<50;i+=2){
		for(j=0;j<50;j+=2){
			if(b<=1){break;}
			mat[i][j]='#';b--;
		}
	}
	for(i=51;i<100;i+=2){
		for(j=0;j<50;j+=2){
			if(a<=1){break;}
			mat[i][j]='.';a--;
		}
	}
	for(auto it:mat){cout<<it<<endl;}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define str string
#define please return
#define AC 0
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n > 0) { 
		sum += n % 10; n /= 10; }
	return sum;//Nanashi,tRue,wai
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {

	string s, ans;
	cin >> s;
	rep(i, s.size()) {
		if (i % 2 == 0) {
			//０から数えて偶数
			ans += s[i];
		}
	}
	cout << ans << rt;

	please AC;
}

Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
long long int a = 0, b = 0, c = 0,d=0, x = 0, y = 0, z = 0,n=0,m=0, maxy = 0, mini = 9999, counter = 0, s = 0, endp = 0, checker = 0;
long long int one = 0, two = 0, four = 0;
std::vector <char> vec{}, vecsec{}, vecth{};
long long int iremono[100001];
long long int iremono2[100001],check[100001];
std::vector<long long int>kinds{}, ans{}, kaku{};
char moji, moji2;
bool okada = false, okada2 = false;
std::string output, output2, input;
char rev[100001];
unsigned long long int kakunou2[101][101] = {};
unsigned long long int M, A, R, C, H;

int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}
int main()
{
	cin >> a;
	rep(i, a) {
		cin >> b;
		if (b % 4 == 0) {
			four++;
		}
		else if(b%2==0){
			two++;
		}
		else {
			one++;
		}
	}
	okada = false;
	if (four>=one-1) {
		okada = true;
	}
	if (four == one - 1 && two > 0) {
		okada = false;
	}
	
	if (okada) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No"<< endl;
	}
}
//14141412222222
//４は多くてもいい　そして1の個数-1が下限

Measured memory_bytes: 256
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let a: Vec<_> = (0..n)
		.map(|_| {
			let a: i32 = s.next().unwrap().parse().unwrap();
			let b: i32 = s.next().unwrap().parse().unwrap();
			a == b
		})
		.collect();
	if (0..=n - 3).any(|i| a[i] && a[i + 1] && a[i + 2]) {
		println!("Yes");
	} else {
		println!("No");
	}
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	cout << (n >= 1000 ? "ABD" : "ABC") << '\n';
}


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

int main()
{
    int w;
    int h;
    int x;
    int y;
    int r;
    
    cin >> w >> h >> x >> y >> r;
    
    if ((x - r < 0 || x + r > w) || (y - r < 0 || y + r > h)) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3096
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	A = LI1()
	L = [0]*N
	b = [0]*N
	t = 1
	for i,a in enumerate(A):
		L[a]+=1
		if(i==0):
			b[0]=t
		else:
			b[i]=b[i-1]+t
		t+=1
	L_s = L.copy()
	L_s.sort(reverse=True)
	max_c = 0
	for l in L_s:
		if l <= 1:
			break
		else:
			max_c += b[l-2]
	ans = [max_c]*N
	for i,a in enumerate(A):
		if(L[a]>=2):
			ans[i]+=(-L[a]+1)
	printV(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 37916
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;
using P = pair<int,int>;

int main(){

  int A, B, C;
  cin >> A >> B >> C;

  int modSum;
  for (int i = 1; i <= B*B; i++) {
    int Ai = A * i;
    // cout << "Ai " << Ai << endl;
    int AmodB = Ai % B;
    // cout << "AmodB " << AmodB << endl;
    modSum += AmodB;
    // cout << "modSum " << modSum << endl;
    int check = modSum % B;
    // cout << "check " << check << endl;

    if(check == C || AmodB == C){
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b; cin >> a >>b;
  if( (a > 0 and b < 0) or (a < 0 and b > 0) or a == 0 or b == 0)
    cout << "Zero" << endl;
  else if(a > 0 and b > 0)
    cout << "Positive" <<endl;
  else{
    int sabun = b - a + 1;
    if(sabun % 2 == 0)
      cout <<"Positive" <<endl;
    else
      cout <<"Negative" << endl;
  }
}

Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main()
{
string A, B;
cin >> A>> B ;
if (A.at(0)==B.at(2)&&A.at(2)==B.at(0)&&A.at(1)==B.at(1))
    cout << "YES";
else
    cout << "NO";

    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,K = map(int,readline().split())
H = np.array([0] + read().split(),np.int64)

INF = 10 ** 17
dp = np.full((N+1,N+1),INF,np.int64)
dp[0,0] = 0

for n,x in enumerate(H[1:],1):
    add = np.maximum(0, x - H[:n])
    dp[n,1:] = np.min(dp[:n,:-1] + add[:,None], axis=0)

answer = dp[:,N-K:].min()
print(answer)

Measured memory_bytes: 14012
import sys

def is_lunlun(x):
    x_str = str(x)
    for i in range(len(x_str)-1):
        if abs(int(x_str[i]) - int(x_str[i+1])) > 1:
            return False
    return True

def main():
    k = int(input())

    lunlun_map = {
        0: [0, 1],
        1: [0, 1, 2],
        2: [1, 2, 3],
        3: [2, 3, 4],
        4: [3, 4, 5],
        5: [4, 5, 6],
        6: [5, 6, 7],
        7: [6, 7, 8],
        8: [7, 8, 9],
        9: [8, 9]
    }

    if k < 10:
        print(k)
        sys.exit()

    count = 9
    all_lunluns = [list(range(1, 10))]
    i = 0
    while True:
        for lunlun in all_lunluns[i]:
            least = int(str(lunlun)[-1])
            lunluns = []
            for j in lunlun_map[least]:
                new_lunlun = int(str(lunlun) + str(j))
                lunluns.append(new_lunlun)
                count += 1
                if count == k:
                    print(new_lunlun)
                    sys.exit(0)
            all_lunluns.append(lunluns)
        i += 1

if __name__ == "__main__":
    main()

Measured memory_bytes: 45404
coin = int(input())
fivet_yen = 0
five_yen = 0
if coin == 0:
    print(0)
else:
   while(coin > 0):
    if coin >= 500:
        coin = coin - 500
        fivet_yen = fivet_yen + 1000
    else:
        if coin >= 5:
            coin = coin - 5
            five_yen   = five_yen + 5
        else:  
            coin = coin - 1
   print(fivet_yen + five_yen)


       
    
       

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll n,m;
    cin >> n;
    vll t(n);
    rep(i,n)cin >> t[i];
    cin >> m;
    vll p(m),x(m),sum(m);
    rep(i,m){
        sum[i]=0;
        cin >> p[i] >> x[i];
        rep(j,n){
            if(j == p[i]-1)sum[i] += x[i];
            else sum[i] += t[j];
        }
    }
    rep(i,m)cout << sum[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
int n;int f[100][5][2];int p[100][11];
int main(){
	cin >> n;
	REP(i,n) {
		REP(j,5) {
			REP(k,2){
				cin >> f[i][j][k];
			}
		}
	}
	REP(i,n){
		REP(j,11) {
			cin >> p[i][j];
		}
	}

	int ans = -2000000000;
	FOR(S,1,1<<10){
		int P = 0;
		REP(i,n) {
			int c = 0;
			REP(j,5) {
				REP(k,2) {
					int l = j * 2 + k;
					if(f[i][j][k] && (S & (1 << l))) 
						c++;
				}
			}
			P += p[i][c];
		}
		ans = max(ans,P);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/pypy
from collections import defaultdict

N,M=map(int, raw_input().split())
E = defaultdict(list)
for i in xrange(M):
    s,t = map(int, raw_input().split())
    E[s-1].append(t-1)

mn = float('inf')
for b in xrange(N):
    dp = [0 for _ in range(N)]
    dp[N-1] = 0.0
    for i in xrange(N-2, -1, -1):
        s = 0.0
        mx = 0.0
        for e in E[i]:
            s += dp[e]
            if mx < dp[e]:
                mx = dp[e]
        l = len(E[i])
        if b==i and l > 1:
            s -= mx
            l -= 1
        dp[i] = s / l + 1
    if mn > dp[0]:
        mn = dp[0]

print (str(mn))



Measured memory_bytes: 43804
line = gets.split('')

case line[0]
when "S" then
  case line[1]
  when "S" then
    case line[2]
    when "S" then
      a = 0
    when "R" then
      a = 1
    end
  when "R" then
    case line[2]
    when "S" then
      a = 1
    when "R" then
      a = 2
    end
  end

when "R" then
  case line[1]
  when "S" then
    case line[2]
    when "S" then
      a = 1
    when "R" then
      a = 1
    end
  when "R" then
    case line[2]
    when "S" then
      a = 2
    when "R" then
      a = 3
    end
  end
end

p a

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


int main(void){
  while(1){
    int n;
    std::vector<signed int> s;
    std::vector<signed int>::iterator it;

    std::cin >> n;
    if(n == 0) return 0;
    for(int i=0; i < n; i++){
      int inputting;
      std::cin >> inputting;
      s.push_back(inputting);
    }


    int max = -1, min = INT_MAX;
    std::vector<signed int>::iterator maxind;
    std::vector<signed int>::iterator minind;
    for(it = s.begin(); it != s.end(); ++it){
      if(*it > max){
        max = *it;
        maxind = it;
      }
    }
    s.erase(maxind);

    for(it = s.begin(); it != s.end(); ++it){
      if(*it < min){
        min = *it;
        minind = it;
      }
    }
    s.erase(minind);

    int sum = 0, avr;
    for(it = s.begin(); it != s.end(); it++){
      sum += *it;
    }
    std::cout << sum / s.size() << std::endl;
  }
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll N;
    ll A[MAX_N];
    ll answer[MAX_N];

    cin >> N;
    rep(i, N) cin >> A[i];

    answer[0] = 0;
    rep(i, N){
        if (i % 2 == 0) answer[0] += A[i];
        else answer[0] -= A[i];
    }

    For(i, 1, N){
        answer[i] = 2 * A[i - 1] - answer[i - 1];
    }

    rep(i, N) cout << answer[i] << " ";
    cout << "" << endl;

    return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <cstdio>
#define N 200005
using namespace std;

typedef long long ll;
ll n, s, a[N]{-1};
int main()
{
	int i;
	cin >> n;
	for (i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		if (a[i] - a[i - 1] > 1) {cout << "-1"; return 0;}
		if (a[i] <= a[i - 1]) s += a[i - 1];
	}
	s += a[n];
    cout << s << endl;
    return 0;
}

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


int main(){
    int n, m;
    cin >> n >> m;
    vector<int> path(n, 0);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        path[a - 1]++;
        path[b - 1]++;
    }

    for(auto x : path){
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double A,B,P,Q,R;
    cin >> A >> B >> P >> Q >> R;
    cout << fixed << setprecision(10) << B+(P*B-Q*(B-A))/(R+Q) << endl;
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

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, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination MOD prime
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];
    }
    mint p(int n, int k) {
        return fact[n]*ifact[n-k];
    }
} ;//comb(10000007);
// comb(5, 2) → 10, comb.p(5, 2) → 20
// comb.fact[4] → 24, 2のN乗 → mint(2).pow(N)

int main() {
    // A[i]を集合として使わない、集合として使うがsumに加えない、集合として使いsumに加えるの3通り
    int N, S;
    cin >> N >> S;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    vector<mint> dp(S+1);
    dp[0] = 1;
    for (int a : A) {
        vector<mint> prev(S+1);
        swap(dp, prev);
        for (int i = 0; i <= S; i++) {
            dp[i] += prev[i] * 2;
            if (i + a <= S) {
                dp[i+a] += prev[i];
            }
        }
    }
    cout << dp[S] << '\n';
    return 0;
}

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

ll w[101],v[101];
ll wg,n;
ll dp[101][100001];

ll solve(ll i, ll tmp){
    if(dp[i][tmp]==-1){
        if(i==n)return dp[i][tmp]=0;
        if(tmp+w[i]>wg)return dp[i][tmp]=solve(i+1, tmp);
        return dp[i][tmp]=max(solve(i+1,tmp), solve(i+1,tmp+w[i]) + v[i]);
    }
    return dp[i][tmp];
}

int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */ 
    cin>>n>>wg;
    for(ll x=0; x<n; x++){
        cin>>w[x]>>v[x];
    }
    for(ll x=0; x<=n; x++){
        for(ll y=0; y<=100000; y++){
            dp[x][y]=-1;
        }
    }
    cout<<solve(0,0);
    return 0;
}



Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

const ll mod=1000000007;

ll factorial(int N) {
    if(N==1) return 1;
    return (N*factorial(N-1))%mod;
}

int main() {
    int N,M;
    cin>>N>>M;
    int diff=abs(N-M);
    if(diff>1) {
        cout<<0<<endl;
        return 0;
    }
    if(N==M) cout<<(factorial(N)*factorial(M)*2)%mod<<endl;
    else cout<<(factorial(N)*factorial(M))%mod<<endl;
}

Measured memory_bytes: 1792
import java.util.*;

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

        int n30 = 30;
        long[] num = new long[n30];

        for(int i=0; i<n; i++){
            char c = s.charAt(i);
            int ic = c - 'a';
            num[ic]++;
        }

        final long DIV = 1000000007;
        long ans = 1;

        for(int i=0; i<n30; i++){
            ans *= num[i] + 1;
            ans %= DIV;
        }

        ans -= 1;
        if(ans < 0) ans += DIV;

        System.out.println(ans);
    }
}

Measured memory_bytes: 26964
n = int(input())
a = [[int(i) for i in input().split()] for _ in range(n)]

d = [a[i][:] for i in range(n)]
for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j] = min(d[i][j],d[i][k] + d[k][j])

ans = 0
for i in range(n):
    for j in range(n):
        if a[i][j] > d[i][j]:
            ans = -2
            break
        for k in range(n):
            if i == k or j == k: continue
            if d[i][j] == d[i][k] + d[k][j]: break
        else:
            ans += d[i][j]
    else:
        continue
    break

ans //= 2
print(ans)

Measured memory_bytes: 45660
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from collections import defaultdict
def resolve():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    S=[0]*(n+1)
    for i in range(n):
        S[i+1]=S[i]+A[i]
    for i in range(n+1):
        S[i]-=i
        S[i]%=k

    ans=0
    D=defaultdict(int)
    for i in range(n+1):
        s=S[i]
        ans+=D[s]
        D[s]+=1
        if(i>=k-1):
            D[S[i-k+1]]-=1
    print(ans)
resolve()

Measured memory_bytes: 104160
using System;
using System.Reflection;
using System.Linq.Expressions;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder {
    public class Program {
        static int[] getKeys(char delimiter) {
            var Keys = Console.ReadLine().Split(' ');
            int N = Keys.Length;
            int[] Ns = new int[N];
            for (int i = 0; i < N; i++) {
                Ns[i] = int.Parse(Keys[i]);
            }
            return Ns;
        }
        static void Show<T>(T[,] map) {
            int H = map.GetLength(0);
            int W = map.GetLength(1);
            Console.WriteLine("-------------------------");
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    Console.Write(map[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine("-------------------------");
        }
        static void Show<T>(T[,] map, string delimiter) {
            int H = map.GetLength(0);
            int W = map.GetLength(1);
            Console.WriteLine("-------------------------");
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    Console.Write(map[i, j] + delimiter);
                }
                Console.WriteLine();
            }
            Console.WriteLine("-------------------------");
        }
        static void Show<T>(IEnumerable<T> ts) {
            foreach (var item in ts) {
                Console.Write(item + " ");
            }
            Console.WriteLine();
        }
        static void Show<T>(IEnumerable<T> ts, string delimiter) {
            foreach (var item in ts) {
                Console.Write(item + delimiter);
            }
            Console.WriteLine();
        }

        static void Main() {
            int N = int.Parse(Console.ReadLine());
            int[] Keys;
            List<Dish> dishes = new List<Dish>();
            long T = 0, A = 0;
            for (int i = 0; i < N; i++) {
                Keys = getKeys(' ');
                dishes.Add(new Dish(Keys[0] + Keys[1], Keys[0], Keys[1]));
            }
            dishes.Sort((x, y) => (int)(y.Value - x.Value));
            for (int i = 0; i < N; i++) {
                if (i % 2 == 0) {
                    T += dishes[i].Taka;
                } else {
                    A += dishes[i].Ao;
                }
            }
            Console.WriteLine(T - A);
        }
    }

    class Dish {
        public long Value;
        public long Taka, Ao;
        public Dish(long v, long T, long A) {
            Value = v;
            Taka = T;
            Ao = A;
        }
    }
}



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

const int maxn = 1e5 + 10;

pair<int, int> edge[maxn];
int taken[maxn], deg[maxn], ansu[maxn], ansv[maxn], fa[maxn], tot;
vector<int> adj[maxn];

int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }

void dfs(int u, int parent) {
  for(auto v : adj[u]) {
    if(v != parent) dfs(v, u);
  }
  if(parent == -1) return;
  if(deg[u] & 1) ansu[tot] = u, ansv[tot] = parent, ++tot;
  else ansu[tot] = parent, ansv[tot] = u, deg[parent] ^= 1, ++tot;
}

int main() {
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  #endif
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  if(m & 1) { cout << -1; return 0; }
  for(int i = 0; i < m; ++i) {
    cin >> edge[i].first >> edge[i].second;
  }
  for(int i = 1; i <= n; ++i) fa[i] = i;
  int root;
  for(int i = 0; i < m; ++i)
    if(find(edge[i].first) != find(edge[i].second)) {
      fa[find(edge[i].second)] = find(edge[i].first);
      root = edge[i].first;
      adj[edge[i].first].push_back(edge[i].second);
      adj[edge[i].second].push_back(edge[i].first);
    }
    else {
      ansu[tot] = edge[i].first;
      ansv[tot] = edge[i].second;
      ++tot;
      deg[edge[i].first] ^= 1;
    }
  dfs(root, -1);
  for(int i = 0; i < m; ++i)
    cout << ansu[i] << ' ' << ansv[i] << endl;
  return 0;
}


Measured memory_bytes: 14080
#pragma GCC optimize("O2")
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cmath>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i=n;i<=999;i++) {
        string s = to_string(i);
        bool c = true;
        for (int j=1;s[j];j++) {
            if (s[j]!=s[j-1]) {
                c = false;
                break;
            }
        }
        if (c) return cout << i << endl,0;
    }
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int s4 = 0, s2 = 0;

    rep(i, n)
    {
        int input;
        cin >> input;
        if (input % 4 == 0)
        {
            ++s4;
            continue;
        }
        if (input % 2 == 0)
        {
            ++s2;
            continue;
        }
    }
    n -= s4 * 2;
    if (n <= 1)
    {
        cout << "Yes" << endl;
        return 0;
    }
    n -= s2;
    if (n <= 0)
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3576
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007
#define MAXS(x,y) (x = max(x,y))
#define MINS(x,y) (x = min(x,y))

using namespace std;

typedef long long int ll;

const ll INF=(ll)1e18;

int N, M;
vector<vector<int> > e;
vector<ll> memo;


ll dp(int node){
  if(memo[node] != -1)return memo[node];
  ll ret = 0;
  for(auto v : e[node]) ret = std::max(ret, dp(v)+1);
  return memo[node] = ret;

}

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

  e.resize(N+1);

  REP(i,M){
    int x, y;
    cin >> x >> y;
    e[x].push_back(y);
  }

  memo.resize(N+1,-1);

  FOR(i,1,N+1)dp(i);

  cout << *max_element(memo.begin(), memo.end()) << endl;
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
int a[10],v[10],f[11]={0,2,5,5,4,5,6,3,7,6},dp[100005];
int main()
{
    int n,m,i,j,tmp;
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;i++)
        scanf("%d",&a[i]),v[a[i]]=1;
        memset(dp,-1,sizeof(dp));
    dp[0]=0;
    for(i=1;i<=m;i++)
        for(j=f[a[i]];j<=n;j++)
            dp[j]=max(dp[j],dp[j-f[a[i]]]+1);
     tmp=dp[n];
    for(i=1;i<=tmp;i++)
        for(j=9;j>=1;j--)
        if(v[j]&&f[j]<=n&&dp[n]==dp[n-f[j]]+1)
        {
            printf("%d",j),n-=f[j];break;
        }
    return 0;
}


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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 11;
ll p[T], c[T];

int main() {
    ios_base::sync_with_stdio(false);
    ll d,g; cin >> d >> g;
    g /= 100;

    for(int i = 0; i < d; i++) {
        cin >> p[i] >> c[i];
        c[i] /= 100;
    }

    int gol = (1<<d);
    ll ans = INF;

    for(ll mask = 0; mask < gol; mask++) {
        ll points = 0;
        ll solve = 0;
        for(ll j = 0; j < d; j++) {
            if(mask&(1<<j)) {
                solve += p[j];
                points += (j+1)*p[j]+c[j];
            }
        }
        for(ll j = d-1; j >= 0 and points < g; j--) {
            if(mask&(1<<j)) continue;
            ll ok = 0;
            while(ok < p[j] and points < g) {
                points += (j+1);
                solve++;
                ok++;
            }
            if(ok == p[j]) points += c[j];
        }
        if(points >= g) ans = min(ans,solve);
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define x first
#define y second
#define iter iterator
#define riter reversed_iterator
#define y1 Lorem_ipsum_
#define tm dolor_sit_amet_
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int mxN = 1e6;
char a[mxN+3];
int b[mxN+3];
int s[mxN+3];
int mn[mxN+3];
int n;

int main()
{
	scanf("%s",a+1); n = strlen(a+1);
	int cur = 0,cur2 = 0,lb = 0;
	for(int i=1; i<=n; i++) {b[i] = (a[i]=='1'?-1:1); s[i] = s[i-1]+b[i]; lb = min(lb,s[i]);}
	mn[n] = s[n]; for(int i=n-1; i>=0; i--) {mn[i] = min(s[i],mn[i+1]);}
	int ans = 0;
	for(int i=1; i<=n; i++)
	{
		if(a[i]=='?')
		{
			if(mn[i]-cur*2-2>=lb) {cur++; b[i] = -1;}
		}
	}
	for(int i=1; i<=n; i++) {s[i] = s[i-1]+b[i]; ans = max(ans,s[i]);}
	ans -= lb;
	
	for(int i=1; i<=n; i++) {b[i] = (a[i]=='1'?-1:1); s[i] = s[i-1]+b[i];}
	mn[n] = s[n]; for(int i=n-1; i>=0; i--) {mn[i] = min(s[i],mn[i+1]);}
	int ans2 = 0; lb--; cur = 0;
	for(int i=1; i<=n; i++)
	{
		if(a[i]=='?')
		{
			if(mn[i]-cur*2-2>=lb) {cur++; b[i] = -1;}
		}
	}
	for(int i=1; i<=n; i++) {s[i] = s[i-1]+b[i]; ans2 = max(ans2,s[i]);}
	ans2 -= lb;
	printf("%d\n",min(ans,ans2));
	return 0;
}
//	printf("ans=%d\n",ans);
//	printf("b: "); for(int i=1; i<=n; i++) printf("%d ",b[i]); puts("");
//	printf("s: "); for(int i=1; i<=n; i++) printf("%d ",s[i]); puts("");

Measured memory_bytes: 16520
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int ceil_(int a, int b) { return (a + (b - 1)) / b; }
int positive_surplus(int &a) { return (a + MOD) % MOD; }
int bpm(int x, unsigned int y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  int ans   = 1;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  x %= MOD;
  for (unsigned int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) ans = ans * x % MOD;
    x = x * x % MOD;
  }
  return ans;
}
template <class T>
void cumulative_sum(T &container) {
  for (int i = 0; i < container.size() - 1; i++) container[i + 1] += container[i];
}

class BCountBalls {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    int N, A, B;
    cin >> N >> A >> B;
    cout << A * (N / (A + B)) + min((N % (A + B)), A) << endl;
  }
};


signed main() {
  BCountBalls solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e-a>k) cout << ":(" << "\n";
    else cout << "Yay!" << "\n";

    return 0;
}

Measured memory_bytes: 3648
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	std::map<int,int> map;
	rep(i,n) map[a[i]]++;
	if(map.size()==n) print("YES");
	else print("NO");
	return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

string s;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> s;
    map <char, int> c;
    for(auto &i : s) c[i] = 1;
    if((c['N'] ^ c['S']) || (c['W'] ^ c['E'])) cout << "No\n";
    else cout << "Yes\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
  std::vector<int> a;
  for(int i=0;i<10;i++){
    int tmp;
    std::cin >> tmp;
    a.push_back(tmp);
  }
  std::sort(a.begin(), a.end());
  for(auto i=a.rbegin();i!=a.rbegin()+3;i++){
    std::cout << *i << std::endl;
  }
  return 0;
}


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

int main() {
  int A,B;
  cin >> A >> B;
  if (A%2 == 0) {
    if (25*A/2 <= 10*B && 10*B <= 25*A/2 + 12)
      cout << 10*B << endl;
    else if (10*B <= 25*A/2 && 25*A/2 <= 10*B + 9) 
      cout << 25*A/2 << endl;
    else
      cout << -1 << endl;
  }
  else {
    if ((25*A + 1)/2 <= 10*B && 10*B <= (25*A + 1)/2 + 11)
      cout << 10*B << endl;
    else if (10*B <= (25*A + 1)/2 && (25*A + 1)/2 <= 10*B + 9)
      cout << (25*A + 1)/2 << endl;
    else
      cout << -1 << endl;
  }
   
    
}

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

int main()
{
    char a,b;
   // freopen("inp.txt","r",stdin);    
   cin>>a>>b;
    if(a=='H')
    {
        if(b=='H')
        {
            cout<<"H ";
        }
        else
            cout<<"D ";
    }
    else
    {
        if(b=='H')
        {
            cout<<"D ";
        }
        else
            cout<<"H ";

    }
}


Measured memory_bytes: 256
#include<cstdio>

using namespace std;

const int md=1000000007;
int a[200001],f[200001],pre[200001];
int main(){
	int n;
	scanf("%d",&n);
	f[0]=1;
	for(int i=1;i<=n;i++){
		int o;
		scanf("%d",&o);
		f[i]=(f[i-1]+(pre[o]==i-1||pre[o]==0?0:f[pre[o]]))%md;
//		printf("%d %d %d\n",f[i],pre[o],f[i-1]+(pre[o]==i-1||pre[o]==0?0:f[pre[o]]));
		pre[o]=i;
	}
	printf("%d\n",f[n]);
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main(){
	int t=1;
	//cin>>t;
	while(t--){
		int n,m;
		cin>>n>>m;
		int currl=1,currr=n;
		for(int i=0;i<m;i++){
			int l,r;
			cin>>l>>r;
			if(l>currr||r<currl){
				cout<<0<<endl;
				exit(0);
			}
			if(currl<l){
				currl=l;
			}
			if(currr>r)
				currr=r;
		}
		cout<<currr-currl+1<<endl;
	}
}

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    rep(i,n) p[i]++;
    int m = 0;
    int s = 0;
    queue<int> q;
    rep(i,n){
        s += p[i];
        q.push(p[i]);
        if(q.size() > k){
            s -= q.front();q.pop();
        }
        if(q.size() == k){
            m = max(m,s);
        }
    }
    double ans = m;
    ans /= 2;
    cout << fixed << setprecision(10) << ans << endl; 
}

Measured memory_bytes: 1792
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod = 10**9+7

class UnionFind:
  def __init__(self,n):
    self.n=[-1]*n
    self.r=[0]*n
  def find_root(self,x):
    if self.n[x]<0:
      return x
    else:
      self.n[x]=self.find_root(self.n[x])
      return self.n[x]
  def unite(self,x,y):
    x=self.find_root(x)
    y=self.find_root(y)
    if x==y:return
    elif self.r[x]>self.r[y]:
      self.n[x]+=self.n[y]
      self.n[y]=x
    else:
      self.n[y]+=self.n[x]
      self.n[x]=y
      if self.r[x]==self.r[y]:
        self.r[y]+=1
  def root_same(self,x,y):
    return self.find_root(x)==self.find_root(y)
  def count(self,x):
    return -self.n[self.find_root(x)]

N,M,K = map(int,input().split())
u = UnionFind(N)
blocks = [0]*N
f_count = [0]*N
for i in range(M):
    a,b = I()
    f_count[a-1] += 1
    f_count[b-1] += 1
    u.unite(a-1,b-1)
for i in range(K):
    c,d = I()
    if u.root_same(c-1,d-1):
        blocks[c-1] += 1
        blocks[d-1] += 1
for i in range(N):
    print(u.count(i)-f_count[i]-blocks[i]-1)

Measured memory_bytes: 89072
#include <iostream>

using namespace std;

int main()
{
int a[3];
while(cin>>a[0]>>a[1]>>a[2])
{
int sum = 0,sum2 = 0;
for(int i=0;i<3;i++){
if(a[i] == 5)
sum++;
else
if(a[i] == 7)
sum2++;
}
if((sum == 2) && (sum2 == 1))
cout << "YES" <<endl;
else
cout<<"NO"<<endl;
}
    return 0;
}


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

bool f(int a){
	for(int i = 1;i <= a;i++){
		for(int j = 2;j <= 10;j++){
			if(pow(i,j) == a){
				return true;
			}
		}
	}
	return false;
}

int main(){
	int x;
	cin >> x;
	while(1){
		if(f(x)){
			cout << x << endl;
            return 0;
		}
		x--;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
using namespace std;

int main() {
	int a = 0, b = 0;
	vector<int>x(3);
	for (int i = 0; i < 3; i++) {
		cin >> x[i];
		b += x[i];
		if (a < x[i])a = x[i];
	}
	cout << b + a * 9 << endl;
	return 0;
}

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

using namespace std;
#define F first
#define S second
typedef long long lli;
const int MX = 100005 , infi =1000000 , mod = 1000000007;
typedef pair<int,int> pii;

lli n;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n;
    priority_queue<int> F;
    cout<<n<<": ";
    for(int i=2;i*i<=n;i++)
    {
        while(n%i==0)
        {
            F.push(-i);
            n/=i;
        }
    }
    if(n>1)F.push(-n);
    while(!F.empty())
    {
        cout<<-F.top();
        F.pop();
        if(F.size())cout<<" ";
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
typedef long long ll;
#define pri(n) printf("%d\n",n)
#define lpri(n) printf("%lld\n",n);
#define rep(i,st,ed) for(int i=st;i<ed;i++)
#define F first
#define S second 
#define pb(n) push_back(n)
const int N=1e5+6;
const ll M=1e9+7;

int main()
{
	int n,w;
	scn(n);scn(w);
	ll dp[n+1][N];
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<N;j++)
			dp[i][j]=M;
	}

	// think of it as minimum weight for a particular value
	// the value can be at max 1e5. this if the key of the 
	// problem
	for(int i=1;i<=n;i++)
	{
		int wt,val;
		scn(wt);scn(val);
		if(dp[i-1][val]==M)
			dp[i][val]=wt;
		else dp[i][val]=min(dp[i][val],1ll*wt);
		for(int j=0;j<N;j++)
		{
			dp[i][j]=min(dp[i-1][j],dp[i][j]);
			if(j>=val)
			{
				if(dp[i-1][j-val]!=M)
					dp[i][j]=min(dp[i][j],dp[i-1][j-val]+wt);				
			}
		}
	}
	ll ans=0;
	for(int i=N-1;i>=0;i--)
	{
		if(dp[n][i]<=w)
		{			
			// lpri(dp[n][i]);
			ans=i;
			break;
		}
	}
	lpri(ans);
}

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

int c[3][3];
int a[3];
int b[3];

int main(){
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            scanf("%d", &c[i][j]);
        }
    }
    for(int i = 0; i < 3; i++){
        b[i] = c[0][i] - a[0];
    }
    for(int i = 1; i < 3; i++){
        a[i] = c[i][0] - b[0];
    }
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            if(c[i][j] != a[i] + b[j]){
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 256