akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1145141919
#define LLINF 1145148101919
#define PI 3.14159265359
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}

class UnionFind
{
public:
    vector<ll> par; // 各元の親を表す配列
    vector<ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL)
    {
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_)
    {
        siz.assign(sz_, 1LL); // assign: 再代入
        par.resize(sz_);      // resize: 再確保
        for (ll i = 0; i < sz_; ++i)
            par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x)
    { // 根の検索
        while (par[x] != x)
        {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y])
            swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y)
    { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x)
    { // 素集合のサイズ
        return siz[root(x)];
    }
};

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;
}

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

vector<ll> decom;

void decompositPrime(ll n)
{
    ll a = 2;
    while (n >= a * a)
    {
        if (n % a == 0)
        {
            decom.push_back(a);
            n /= a;
        }
        else
        {
            a++;
        }
    }
    decom.push_back(n);
}

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

string S, T;
int ctoi_alpha(char c)
{
    if (c >= 'a' && c <= 'z')
    {
        return c - 'a';
    }
    return 0;
}

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

int main()
{
    ll N; cin >> N;
    vector<ll> H(N);
    REP(i,N) cin >> H[N-i-1];

    ll ans=0, cnt=0;

    REP(i,N-1){
        if(H[i+1]-H[i]>=0){
            cnt++;
        }else{
            cnt=0;
        }
        if(ans<=cnt) ans=cnt;
    }

    cout << ans << endl;

    return 0;
}


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

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

const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}

int main(){
    ll n;
    cin >> n;
    ll mi;
    cin >> mi;

    ll ans = 1;
    for(ll i = 1; i < n; i++){
        ll p = 0;
        cin >> p;
        if(mi >= p){
            ans++;
            mi = p;
        }
        //cout << mi << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)
const long double PI = (acos(-1));

int main() {

	double a, b, x;
	cin >> a >> b >> x;

	long double ans;
	if (a * a * b / 2 <= x) ans = atan(2 * (a * a * b - x) / (a * a * a));
	else ans = PI / 2 - atan(2 * x / (a * b * b));

	ans = ans * 180.0 / PI;

	cout << fixed << setprecision(10) << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
int main(){
    string a;
    char c[10];
    char b[100][11];
    int check[100];
    for(int i=0;i<100;i++)
        check[i]=0;
    int n;
    int count=0;
    cin>>a;
    for(int i=0;i<a.size();i++){
        c[i]=a[i];
    }
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
            cin>>b[i][j];
        }
    }
    for(int i=0;i<n;i++){
        int s=0;
        for(int k=0;k<10;k++){
        for(int j=0;j<a.size();j++){
            if(b[i][(k+j)%10]==c[j]){
                s++;
                if(s==a.size()){
                    if(check[i]==1)
                        count--;
                    count++;
                    check[i]=1;
                }
            }
            else
                s=0;
        }
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 1200
def main():
    n, s = map(int, input().split())
    a = list(map(int, input().split()))
    mod = 998244353
    dp = [[0]*(s+1) for _ in range(n+1)]
    dp[0][0] = 1
    for i in range(1, n+1):
        ai = a[i-1]
        for j in range(min(s+1, ai)):
            dp[i][j] += dp[i-1][j]*2
            dp[i][j] %= mod
        for j in range(ai, s+1):
            dp[i][j] += dp[i-1][j]*2 + dp[i-1][j-ai]
            dp[i][j] %= mod
    print(dp[n][s])

if __name__ == "__main__":
    main()

Measured memory_bytes: 132264
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#include <numeric>
#include <cmath>
#include <set>

int main(){

    int n;
    scanf("%d",&n);
    int foge = n/2;
    int counter4 = 0;
    int counter2 = 0;
    for(int i=0;i<n;i++){
        int x;
        scanf("%d",&x);
        if(x%4 == 0){
            counter4 ++;
        }
        else if(x%2 == 0){
            counter2 ++;
        }
    }
    counter4 = counter4 + (counter2/2);
    if(counter4 >= foge){
        printf("Yes");
    }
    else{
        printf("No");
    }
}

Measured memory_bytes: 888
#include<stdio.h>

int main()
{
	static int ink[10][10]={0};/*インクの量*/
	int x,y,i,j,max=0,none=0;
	int size;/*インクのタイプ*/
	char c;
	
	while(scanf("%d%c%d%c%d",&x,&c,&y,&c,&size) != EOF)
	{
		ink[x][y]+=1;
		for(i=1;i>=-1;i--)
		{
			for(j=1;j>=-1;j--)
			{
				if((i*j!=0 && size==1)||(x+i<0 || x+i>9 || y+j>9||y+j<0)||(i==0&&j==0))
					continue;
				else
					ink[x+i][y+j]+=1;
			}
		} 
		if(size==3)
		{
			for(i=2;i>=-2;i-=4)
			{
				if(x+i>=0 && x+i<=9)
					ink[x+i][y]+=1;
				if(y+i>=0 && y+i<=9)
					ink[x][y+i]+=1;
			}
		}
	}

		for(i=0;i<10;i++)
		{
			for(j=0;j<10;j++)
			{
				if(ink[i][j]==0)
				{
					none++;
				}
				else if(max<ink[i][j])
				{
					max=ink[i][j];
				}

			}
		}

		printf("%d\n",none);
		printf("%d\n",max);

		return 0;
}

Measured memory_bytes: 600
sub f{my$r=$s=$v[$_]=1;my$p=$h[my$c=$c[$_-1]-1];$v[$_]or$a[$c]-=-$s*(-$s+($s=($r+=f())-$h[$c]+$p))for@$_;$a[$c]+=($p+$r-$h[$c])*(@a-($h[$c]=$p+$r))+1;$r}$_=@a=(0)x<>;@c=glob<>;map{push@$_,$u-$_+$;for($u,$;)=split}<>;f;print"@a"

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

int main(){
  
  int n;
  cin >> n;
  vector<double> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  
  double x=0;
  for(int j=0;j<n;j++){
    x+=1/a.at(j);
  }
  
  cout << fixed << setprecision(6);
  cout << 1/x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, T, A[201010], B[201010];
ll dp[201010][40];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> T;
	rep(i, 0, N) cin >> A[i] >> B[i], B[i]++;

	vector<int> one;
	rep(i, 0, N) if (1 <= A[i]) one.push_back(i);
	sort(all(one), [&](int x, int y) { // aybx < axby
		return 1LL * A[y] * B[x] < 1LL * A[x] * B[y];
	});
	int M = one.size();
	rep(i, 0, M + 1) rep(j, 0, 35) dp[i][j] = inf;
	dp[0][0] = 1;
	rep(i, 0, M) rep(j, 0, 35) if (dp[i][j] != inf) {
		int id = one[i];
		chmin(dp[i + 1][j], dp[i][j]);
		chmin(dp[i + 1][j + 1], dp[i][j] + 1LL * A[id] * dp[i][j] + B[id]);
	}

	vector<ll> zeros;
	rep(i, 0, N) if (A[i] == 0) zeros.push_back(B[i]);
	sort(all(zeros));
	int mm = zeros.size();
	rep(i, 1, mm) zeros[i] += zeros[i - 1];
	zeros.push_back(infl);

	int ans = 0;
	rep(cn, 0, 35) if (dp[M][cn] - 1 <= T) {
		ll t = dp[M][cn] - 1;
		int cnt = cn;
		ll rest = T - t;
		int zero = upper_bound(all(zeros), rest) - zeros.begin();
		chmax(ans, cn + zero);
	}
	cout << ans << endl;
}







Measured memory_bytes: 65524
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615


int main(){
  float a,b; cin>>a>>b;
  int price1,price2;
  int ans=-1;
  
  
  for(int i=10000; i>0; i--){
    price1=i*0.08;
    price2=i*0.1;
    if(a==price1){
      if(b==price2){
        ans=i;
        
      }
    }
  }
  cout<<ans;       
}

Measured memory_bytes: 3632
from itertools import combinations as comb
def get_ans(m, n):
    ans = sum(1 for nums in comb(list(range(1, min(m+1,n-2))), 3) if sum(nums)==n)
    return ans
     
while True:
    m, n = (int(x) for x in input().split())
    if m==0 and n==0:
        quit()
    ans = get_ans(m, n)
    print(ans)


Measured memory_bytes: 5644
#include <stdio.h>
int main(void){
   int a,b,c,d,s;
   scanf("%d %d %d %d",&a,&b,&c,&d);
   s=a+b+c+d;
   int e,f,g,h,t;
   scanf("%d %d %d %d %d",&e,&f,&g,&h);
   t=e+f+g+h;
   if(s>t) printf("%d\n",s);
   else printf("%d\n",t);
 return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
  }
  vector<int> C(N-1);
  for (int i = 0; i < N-1; i++) {
    cin >> C.at(i);
  }
  
  int sat = 0;
  for (int i = 0; i < N; i++) {
    if (i != 0) {
      if (A.at(i) == A.at(i - 1) + 1) {
        sat = sat + C.at(A.at(i-1) - 1) + B.at(A.at(i) - 1);
      }
      else {
        sat = sat + B.at(A.at(i) - 1);
      }
    }
    else {
      sat = sat + B.at(A.at(0) - 1);
    }
  }
  cout << sat << endl;
}


Measured memory_bytes: 3616
import java.util.*;
import java.util.Arrays;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int[] A=new int[3];
		int[] diffe=new int[2];
		int[] diffe_tmp=new int[2];
		int flag=0;
		String ans="null";

		for(int i=0;i<3;i++) A[i]=sc.nextInt();

		diffe[0]=A[0]-A[1];
		diffe[1]=A[1]-A[2];

		for(int i=0;i<=1;i++){
			for(int j=0;j<3;j++) A[j]=sc.nextInt();

			diffe_tmp[0]=A[0]-A[1];
			diffe_tmp[1]=A[1]-A[2];
			if(diffe[0]!=diffe_tmp[0] || diffe_tmp[1]!=diffe[1]) flag=1;
		}
		
		if(flag==0) ans="Yes";
		else ans="No";

		System.out.println(ans);
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
typedef long long ll;
const int MAX = 401;
const ll INF = 1e17;

ll sum[MAX] = {};
vector<vector<ll>> dp(MAX, vector<ll>(MAX,-1));

ll dfs(int i, int j){
    if(dp[i][j] != -1) return dp[i][j];
    if(i == j) return dp[i][j] = 0;
    ll d = INF;
    for(int k = i; k < j; k++){
        d = min(d,dfs(i,k)+dfs(k+1,j)+sum[j]-sum[i-1]);
    }
    return dp[i][j] = d;
}


int main(){
    int n;
    cin >> n;
    rep(i,n){ 
        ll a;
        cin >> a;
        sum[i+1] += sum[i] + a;
    }
    cout << dfs(1,n) << endl;
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  string s, t;
  cin >> s >> t;
  s = s + t[t.size() - 1];
  if (s == t) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}


Measured memory_bytes: 3628
n, M = map(int, input().split())
s = [[] for _ in range(M)]
for i in range(M):
    li = list(map(int, input().split()))  # -> li = [1,2,3,...n]
    s[i] = li[1:]
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
    f = True
    for j in range(M):
        ss = s[j]
        x = 0
        for sss in ss:
            if (i >> (sss-1)) & 1:
                x += 1
        if p[j] != (x%2):
            f = False
    if f:
        ans += 1
print(ans)

Measured memory_bytes: 40944
n = int(input())

ti,xi,yi = 0,0,0
found = True
for _ in range(n):
    t, x, y = map(int, input().split())
    root = abs(x-xi)+abs(y-yi)
    if root > (t-ti) or (t-ti-root)&1:
        found = False
    ti,xi,yi = t,x,y  
    
print("Yes" if found else "No")

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

#define FOR(VAR,ST,END) for(int VAR=ST; VAR<END; ++VAR)
#define FORI(VAR,ST,END) for(int VAR=ST; VAR<=END; ++VAR)
#define ROF(VAR,ST,END) for(int VAR=ST; VAR>END; --VAR)
#define ROFI(VAR,ST,END) for(int VAR=ST; VAR>=END; --VAR)
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define MAXI(a,b) (a=(a>b?a:b))
#define MINI(a,b) (a=(a<b?a:b))
#define MINI_NZ(a,b) {if(a==0) a = b; else a = a<b?a:b;}
#define SWAP_IF(type,x,y,cond) if(cond) {type tmp=x; x=y; y=tmp;}
#define SWAP(type,x,y) {type tmp=x; x=y; y=tmp;}
#define INF 0x3f3f3f3f

using namespace std;

#define MAX_N 100000

char names[MAX_N][11];

long long cnt[26];

#define IDX(x) (x-'A')
#define CNT(x) cnt[IDX(x)]

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

    FOR(i, 0, n)
    {
        cin >> names[i];
        cin.get();
        ++cnt[names[i][0] - 'A'];
    }

    long long ans =
        CNT('M') * CNT('A') * CNT('R') +
        CNT('M') * CNT('A') * CNT('C') +
        CNT('M') * CNT('A') * CNT('H') +
        CNT('M') * CNT('R') * CNT('C') +
        CNT('M') * CNT('R') * CNT('H') +
        CNT('M') * CNT('C') * CNT('H') +
        CNT('A') * CNT('R') * CNT('C') +
        CNT('A') * CNT('R') * CNT('H') +
        CNT('A') * CNT('C') * CNT('H') +
        CNT('R') * CNT('C') * CNT('H');

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main() {
    int H, W; cin >> H >> W;
    vector<vector<bool> > maze(H + 2, vector<bool>(W + 2, false));
    for (int i = 1; i < H + 1; i++) {
        for (int j = 1; j < W + 1; j++) {
            char s; cin >> s;
            if (s == '.') {
                maze[i][j] = true;
            }
        }
    }
    
    int ans = 0;
    for (int i = 1; i < H + 1; i++) {
        for (int j = 1; j < W + 1; j++) {
            if (maze[i][j]) {
                vector<vector<bool> > searched(H+2, vector<bool>(W+2, false));
                queue<vector<int> > q;
                int temp_ans = 0;
                searched[i][j] = true;
                q.push({i, j, 0});
                while(!q.empty()) {
                    vector<int> t = q.front();
                    int h = t[0]; int w = t[1]; int depth = t[2];
                    temp_ans = max(temp_ans, depth);
                    q.pop();
                    if (maze[h+1][w] && !searched[h+1][w]) {
                        searched[h+1][w] = true;
                        q.push({h+1, w, depth+1});
                    }
                    if (maze[h-1][w] && !searched[h-1][w]) {
                        searched[h-1][w] = true;
                        q.push({h-1, w, depth+1});
                    }
                    if (maze[h][w+1] && !searched[h][w+1]) {
                        searched[h][w+1] = true;
                        q.push({h, w+1, depth+1});
                    }
                    if (maze[h][w-1] && !searched[h][w-1]) {
                        searched[h][w-1] = true;
                        q.push({h, w-1, depth+1});
                    }
                }
                ans = max(ans, temp_ans);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String [] args){
		Scanner scan = new Scanner(System.in);
		int one[][], i, j;
		
		int r = scan.nextInt();
		int c = scan.nextInt();
		one = new int[r+1][c+1]; 
		
		for(i=0; i<=r; i++){
			for(j=0; j<=c; j++){		
				one[i][j] = 0;
			}
		}
		
		for(i=0; i<r; i++){
			for(j=0; j<c; j++){		
				int x = scan.nextInt();
				one[i][j] = x;
			}
		}
		
		for(i=0; i<r; i++){
			int sumx=0;
			for(j=0; j<=c; j++){
				if(j==c){
					one[i][c] = sumx;
				}else{
					sumx += one[i][j];
				}
			}
		}
		
		for(i=0; i<=c; i++){ 
			int sumy=0;
			for(j=0; j<=r; j++){
				if(j==r){
					one[r][i] = sumy;
				}else{
					sumy += one[j][i];
				}
			}
		}
		
		
		for(i=0; i<=r; i++){
			for(j=0; j<=c; j++){
				System.out.print(one[i][j]);
				if(j != c){
					System.out.print(" ");
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 39620
#include<map>
#include<cstdio>
using namespace std;

int N,M;
map<int,long long> R;

int main(){
    scanf("%d%d",&N,&M);
    int Sum=0,a;
    for(int i=1;i<=N;i++){
        scanf("%d",&a);
        Sum=(Sum+a)%M;
        R[Sum]++;
    }
    long long Ans=0;
    for(map<int,long long>::iterator it=R.begin();it!=R.end();it++){
        if(it->first==0)
            Ans+=it->second;
        Ans=Ans+it->second*(it->second-1)/2;
    }
    printf("%lld",Ans);
}


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

int main() {
  	int N, X;
    cin >> N >> X;
    vector<int> G(N);
    for (int i=0; i<N; i++){
      	cin >> G[i];
    }
    sort(G.begin(), G.end());
    int SUM=0;
    for (int i=0; i<N; i++){
      	SUM += G[i];
    }
    int REST=X-SUM;
    cout << N+REST/G[0] << endl;
}

Measured memory_bytes: 3564
n, k = map(int, input().split())

mod = 10**9 + 7

fac = [1, 1]
inv = [1, 1]
finv = [1, 1]
for i in range(2, n+5):
    fac.append(fac[i-1] * i % mod)
    inv.append(mod - inv[mod%i] * (mod//i) % mod)
    finv.append(finv[i-1] * inv[i] % mod)

def nck(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

for i in range(1, k+1):
    print(nck(k-1, i-1) * nck(n-k-(i-1)+i, i) % mod)

Measured memory_bytes: 3572
str_a = input()
str_b = input()

int_len = len(str_a) if len(str_a) > len(str_b) else len(str_b)



for x, y in zip(str_a.zfill(int_len), str_b.zfill(int_len)):
    if int(x) > int(y):
        print("GREATER")
        exit(0)
    elif int(x) < int(y):
        print("LESS")
        exit(0)
    else:
        pass
print("EQUAL")


Measured memory_bytes: 3060
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        (a,b,n): (u64, u64, u64)
    };

    if b - 1 <= n {
        println!("{}", (a * (b - 1)) / b);
    } else {
        println!("{}", (a * n) / b - a * (n / b))
    }
}


Measured memory_bytes: 2164
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			
			if (H == 0 && W == 0) { break; }
			
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();

		}
		
		sc.close();
	}
}


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

int N;
string s, t;

signed main()
{
	cin >> N;
	cin >> s >> t;

	rep(i,s.length() + 1) {
		string str = s.substr(0, i) + t.substr(0);
		if (str.substr(0, s.length()) == s && str.substr(str.length() - t.length()) == t) {
			cout << str.length() << endl;
			return 0;
		} 
	}
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

ll dp[2002][2002] = {};

int main() {
	IOS();
	ll n, m;
	cin >> n >> m;
	vector<ll> s(n), t(m);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> t[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i] == t[j]) {
				dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j] + 1;
			} else {
				dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j] - dp[i][j];
			}
			dp[i + 1][j + 1] = mod(dp[i + 1][j + 1], MOD);
		}
	}
	dump((dp[n][m] + 1) % MOD);
	return 0;
}

Measured memory_bytes: 31616
#include<iostream>
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned int ui;
#define infin (ll)(998244353)
using namespace std;
int main()
{  
   int n,k;
   cin>>n>>k;
   int l,r;
   vector<ll> dp(n+1,0); //0 to n
   vector <pair<int,int>>v;
   for(int j=0;j<k;j++)
   {
      cin>>l>>r;
      v.push_back({l,r});
   }
   dp[0]=1;;
   dp[1]=1; 
   sort(v.begin(),v.end());
   auto z=v.begin();
   if ((*z).first==1)
      dp[2]=1;
   else
     dp[2]=0;
   for(int i=3;i<=n;i++)
   {  
      dp[i]=dp[i-1];
      for (auto x:v)
      {
         if (i>x.first)
            dp[i]+=dp[i-x.first];
         else
            break;
         if (i-1>x.second)
            {
               dp[i]-=dp[i-1-x.second];
               if (dp[i]<0)
                  dp[i]+=infin;
            }
      }
      dp[i]=(dp[i]) % infin;
   }
   cout<<dp[n]<<endl;
}


Measured memory_bytes: 4812
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>

using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

ll n,cnt;
void foo(ll num,bool t,bool f,bool s){
    if(num > n)return ;
    if(t&&f&&s)cnt++;
    foo(num*10+3,true,f,s);
    foo(num*10+5,t,true,s);
    foo(num*10+7,t,f,true);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    foo(0,0,0,0);
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mk make_pair
using namespace std;
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9;
  
int n, m, no[N];
set<int> G1[N], G2[N];
queue< pair<int, int> > q;
map< pair<int, int>, int> cnt;

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		if (x > y) swap(x, y);
		G1[x].insert(y);
		G1[y].insert(x);
		cnt[mk(x, y)]++;
	}
	for (int i = 1; i < n; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		if (x > y) swap(x, y);
		G2[x].insert(y);
		G2[y].insert(x);
		cnt[mk(x, y)]++;
		if (cnt[mk(x, y)] == 2) q.push(mk(x, y));
	}
	while (q.size()) {// cout << "/";
		int x = q.front().first;
		int y = q.front().second;
		q.pop(); // cout << x << "," << y << endl;
		if (no[x] || no[y]) continue;
		m++;
		no[y] = 1;
		G1[x].erase(G1[x].find(y));
		G1[y].erase(G1[y].find(x));
		G2[x].erase(G2[x].find(y));
		G2[y].erase(G2[y].find(x));
		for (auto i: G1[y]) {
			int xx = i, yy = x;
			if (xx > yy) swap(xx, yy);
			G1[x].insert(i);
			G1[i].insert(x);
			cnt[mk(xx, yy)]++;
			if (cnt[mk(xx, yy)] == 2) q.push(mk(xx, yy));
		}
		for (auto i: G2[y]) {
			int xx = i, yy = x;
			if (xx > yy) swap(xx, yy);
			G2[x].insert(i);
			G2[i].insert(x);
			cnt[mk(xx, yy)]++;
			if (cnt[mk(xx, yy)] == 2) q.push(mk(xx, yy));
		}
	} 
	if (m == n - 1) puts("YES");
	else puts("NO");
}

Measured memory_bytes: 156928
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (auto&& e : a) cin >> e;
  a.insert(begin(a), -1);
  V<> b(n + 1);
  for (int i = n; i; --i) {
    int s = 0;
    for (int j = 2 * i; j <= n; j += i) {
      s += b[j];
    }
    s &= 1;
    if (a[i] != s) b[i] = 1;
  }
  cout << accumulate(begin(b), end(b), 0) << '\n';
  for (int i = 1; i <= n; ++i) if (b[i]) {
    cout << i << ' ';
  }
  cout << '\n';
}

Measured memory_bytes: 2492
def bubble_sort(c, n)
  0.upto(n-1) do |i|
    (n-1).downto(i+1) do |j|
      if c[j][1].to_i < c[j-1][1].to_i
        c[j], c[j-1] = c[j-1], c[j]
      end
    end
  end

  puts c.join(' ')
  puts 'Stable'

  c
end

def selection_sort(c, n)
  0.upto(n-1) do |i|
    min_j = i
    i.upto(n-1) do |j|
      if c[j][1].to_i < c[min_j][1].to_i
        min_j = j
      end
    end

    c[i], c[min_j] = c[min_j], c[i] if i != min_j
  end

  puts c.join(' ')

  c
end

N = gets.to_i
C = gets.split

if bubble_sort(C.dup, N) == selection_sort(C.dup, N)
  puts 'Stable'
else
  puts 'Not stable'
end

Measured memory_bytes: 8740
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

void pv(vector<int>&v){
	for(int i = 0;i<v.size();i++){
		if(i)cout<<' ';
		cout<<v[i];
	}
	cout<<endl;
}

int lsum = 0,rsum = 0;
priority_queue<int>l;
priority_queue<int,vector<int>,greater<int>>r;

void update_lsum(int t){
	if(l.size()==0)l.push(t);
	else if(l.top()<=t){
		lsum += abs(t - l.top()) * l.size();
		l.push(t);
	}else{
		lsum += abs(l.top() - t);
		l.push(t);
	}
	//cout<<"lsum"<<" "<<t<<" "<<l.top()<<endl;
}
void update_rsum(int t){
	if(r.size()==0)r.push(t);
	else if(r.top()>=t){
		rsum += abs(r.top() - t) * r.size();
		r.push(t);
	}else{
		rsum += abs(t - r.top());
		r.push(t);
	}
	//cout<<"rsum"<<" "<<t<<" "<<r.top()<<endl;
}

signed main()
{
	IOS();
	int Q;
	cin >> Q;
	int x = 0;
	while(Q--){
		int t;
		cin >> t;
		if(t == 1){
			int a,b;
			cin>>a>>b;
			x += b;
			if(l.size()<=r.size()){
				update_lsum(a);
			}else{
				update_rsum(a);
			}
			while(l.size()&&r.size()&&l.top()>r.top()){
				int L = l.top();
				l.pop();
				lsum -= abs(L - l.top()) * l.size();
				int R = r.top();
				r.pop();
				rsum -= abs(R - r.top()) * r.size();
				update_lsum(R);
				update_rsum(L);
			}
		}else{
			if(r.size()==0)cout<<l.top()<<" "<<x<<endl;
			else {
				//cout<<l.top()<<" "<<r.top()<<endl;
				//cout<<lsum<<" "<<rsum<<endl;
				int t = abs(l.top()-r.top())*r.size();
				//cout<<r.size()<<" "<<l.size()<<endl;
				int ans = x + lsum + rsum;
				cout<<l.top()<<" "<<ans+t<<endl;
			}
		}
		//if(l.size()&&r.size())cout<<l.top()<<" "<<r.top()<<endl;
	}
}


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


vector<ll> enum_div(ll n)//nの約数を列挙
{
	std::vector<ll> ret;
	for(ll i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
 
int main(){
    ll N;
    cin >> N;
    
    /*
    for(ll i=1;i<=sqrt(N);i++){
        if(N%i == 0)
            vec.push_back(i);
    }
    vec.push_back(N);
    */
    vector<ll> vec = enum_div(N);
    vec.push_back(N);
    ll ans = 0, l = vec.size(), m;
    /*
    for(ll i=0;i<l;i++){
        cout << vec[i] << endl;
    }
    */
    for(ll i=0;i<l;i++){
        m = vec[i];
        if(m-1 > 0){
            if(N/(m-1) == N%(m-1))
                ans += m - 1;
        }
    }

    cout << ans << endl;    

}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
  
  int a,b;
  
  cin >> a >> b;

  if (a%3==0 || b%3==0 || (a+b)%3==0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }

  return 0;
}



Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        d: usize,
        t: usize,
        s: usize,
    }
    if t * s >= d {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

using namespace std;

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

const int T = (1<<19);

int N,Q;
int tree[T];
int a[200010];

void init() {
  REP(i,T) tree[i] = INT_MAX;
}

int find(int N) {
  int x = 1;
  while (x < N) x <<= 1;
  return x;
}

void update(int x, int y) {
  int p = find(N) + x;
  tree[p] = y;
  while (p > 0) {
    p = p / 2;
    tree[p] = min(tree[p * 2], tree[p * 2 + 1]);
  }
}

int query(int a, int b, int k, int l, int r) {
  if (r <= a || b <= l) {
    return INT_MAX;
  } else if (a <= l && r <= b) {
    return tree[k];
  } else {
    int m = (l + r) / 2;
    int lv = query(a, b, k * 2,     l, m);
    int rv = query(a, b, k * 2 + 1, m, r);
    return min(lv, rv);
  }
}

int main() {
  init();
  cin >> N >> Q;
  REP(i,N) a[i] = INT_MAX;
  REP(i,Q) {
    int c,x,y;
    scanf("%d %d %d", &c, &x, &y);
    if (c == 0) {
      update(x, y);
    } else {
      printf("%d\n", query(x, y + 1, 1, 0, find(N)));
    }
  }
  // REP(i,10) cout << i << ' ' << tree[i] << endl;
  // cout << query(0, 1, 1, 0, N) << endl; // 0
  //cout << query(1, 2, 1, 0, find(N)) << endl; // 1
  // cout << query(3, 4, 1, 0, N) << endl; // 2
  // cout << query(0, 1, 1, 0, N) << endl;

  return 0;
}



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


int main(){
  string n;
  cin >> n;
  for (auto &&i : n)
  {
    int a = i - '0';
    if (a == 7)
    {
      cout << "Yes" << endl;
      return 0;
    }

  }
  cout << "No" << endl;

}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60; 
#define MOD 1000000007

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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}


int main() {
	string a, b;
	cin >> a;
	cin >> b;
	if (a.size() > b.size()) {
		cout << "GREATER" << endl;
	}
	else if (a.size() < b.size()) {
		cout << "LESS" << endl;
	}
	else {
		if (a > b) {
			cout << "GREATER" << endl;
		}
		if (a < b) {
			cout << "LESS" << endl;
		}
		if (a == b) {
			cout << "EQUAL" << endl;
		}
	}

}



Measured memory_bytes: 256
#include <iostream>
 #include <stdio.h>
#include <stdlib.h>
#include<algorithm>
using namespace std;
int main()
{
    int a[200010],b[200010];
    int i,n;
    scanf("%d",&n);
    for(i=0;i<n;i++ )
        {
            scanf("%d",&a[i]);
            b[i]=a[i];
        }
    sort(b,b+n);
    for(i=0;i<n;i++)
    {
        if(a[i]<b[n/2])
            printf("%d\n",b[n/2]);
        else
            printf("%d\n",b[n/2-1]);
    }
 
 
 
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll ,P> P3;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int v, e, used[MAX_N], cnt[2]{}, dif[MAX_N];
vector<vector<int> > g;
bitset<MAX_N*2> dp;

bool dfs(int i, int c){
    used[i] = c;
    cnt[c]++;
    bool res = true;
    for(auto to : g[i]){
        if(used[to] < 0){
            res &= dfs(to,c^1);
        }
        else{
            res &= used[to] != c;
        }
    }
    return res;
}

int main() {
    cin >> v >> e;
    g.resize(v);
    REP(i,e){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    // 二部グラフ判定
    bool ok = true;
    fill(used,used+v,-1);
    REP(i,v){
        if(used[i]<0){
            ok &= dfs(i,0);
            dif[abs(cnt[0]-cnt[1])]++;
            cnt[0] = cnt[1] = 0;
        }
    }
    if(ok){
        dp.set(v);  // 差分を調整してある数を作れるか
        vector<int> ls;
        for(int i=1;i<v;i++){  // 差分の種類はsqrt(V)程度なので圧縮できる
            int m=1;
            while(dif[i]>=m){
                ls.push_back(i*m);
                dif[i] -= m;
                m*=2;
            }
            if(dif[i]>0) ls.push_back(i*dif[i]);
        }
        for(auto i : ls){
            dp = dp<<i | dp>>i;
        }
        ll ans = 0;
        REP(i,v){
            if(dp[i+v]) ans = max(ans,ll(v-i)/2*ll((v-i)/2+i));
        }
        cout << ans - e << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}



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

using namespace std;

#define INF int(1e9)

int dp[100000000];

int main() {
  int N, K; cin >> N >> K;
  vector<int> v(N+1);
  
  for (int i = 1; i <= N; i++) cin >> v[i];
  for (int i = 0; i <= N; i++) dp[i] = INF;
  
  dp[0] = 0;
  dp[1] = 0;
  
  for (int i = 1; i <= N; i++) {
    for (int k = 1; k <= K; k++) {
      if (i + k <= N) dp[i+k] = min(dp[i+k], dp[i] + abs(v[i] - v[i+k]));
    }
  }
  
  cout << dp[N] << endl;
  return 0;
}

Measured memory_bytes: 1024
N = int(input())
H = [int(i) for i in input().split()]
mx = 0
tmp = 0
#print(H)
for i in range(N-1):
    if H[i] >= H[i+1]:
        tmp = tmp + 1
        if tmp > mx:
                mx = tmp
    else:
        tmp = 0
    #print(H[i], H[i+1], tmp)
        
        
print(mx)

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

int main()
{
    string s;
    int a = 700;
    getline(cin,s);
    if( s[0] == 'o' ) {
        a += 100;
    }
    if( s[1] == 'o' ) {
        a += 100;
    }
    if( s[2] == 'o' ) {
        a += 100;
    }
    cout << a;
}


Measured memory_bytes: 3612
n, k = map(int, input().split())

# pows[i] = pow(2, i)
pows = [1]
while pows[-1] < k:
    pows.append(2 * pows[-1])

ans = 0
ind = -1
for i in range(1, n + 1):
    if -ind < len(pows) and pows[ind-1] * i >= k:
        ind -= 1
    ans += pows[-ind - 1]

print(ans / (pows[-1] * n))

Measured memory_bytes: 63380
a=[]
cp_a=[]
an = input()
a.append(int(an))
i=0
cp_a.append(a[0])
t_or_f = 0
m = 0
n = 0

for k in range(1000000):
    if int(a[i])%2==0:
        cal = int(a[i])* (1/2)
        next_i = i+1
        a.append(int(cal))
        cp_a.append(a[next_i])
        i = i+1
    elif int(a[i])%2!=0:
        next_i = i+1
        cal  = 3*int(a[i]) + 1
        a.append(int(cal))
        cp_a.append(a[next_i])
        i = i+1


    for s in range(i):
        for t in range(s+1,i):
            if a[s]==cp_a[t]:
                n = s
                m = t
                print(m+1)
                t_or_f = 1
                break
        if t_or_f:
            break
    if t_or_f:
        break

# print(a)
# print(cp_a)







Measured memory_bytes: 3064
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

template <class T>
struct Edge {
    int to;
    T cost;
    Edge(int to, T cost) : to(to), cost(cost){};
};

template <class T = int>
class Graph {
public:
    explicit Graph(int N = 0) : size(N) { path.resize(size); }
    void span(int u, int v, T cost = 1) { path[u].push_back(Edge<T>(v, cost)); }
    vector<Edge<T>> operator[](int v) const { return path[v]; }

    int size;
    vector<vector<Edge<T>>> path;
};

template <class T>
vector<T> bfs(const Graph<>& graph, int s) {
    vector<int> dist(graph.size, -1);
    dist[s] = 0;
    queue<int> que;
    que.push(s);

    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (auto e : graph[v]) {
            if (dist[e.to] < 0) {
                dist[e.to] = dist[v] + 1;
                que.push(e.to);
            }
        }
    }
    return dist;
}

int main() {
    int N;
    cin >> N;
    Graph<> graph(N);
    for (int i = 0; i < N; ++i) {
        int v, k;
        cin >> v >> k;
        --v;
        for (int j = 0; j < k; ++j) {
            int sv;
            cin >> sv;
            graph.span(v, --sv);
        }
    }

    auto dist = bfs<int>(graph, 0);
    for (int v = 0; v < N; ++v) {
        cout << v + 1 << " " << dist[v] << endl;
    }
    return 0;
}



Measured memory_bytes: 3096
import sys

if sys.platform =='ios':
	sys.stdin=open('inputFile.txt')
		
#+++++

def main():
	s = input()
	ss=set()
	for c in s:
		ss.add(c)
		
	if len(ss) != 2:
		return 'No'
		
	cc=list(s)[0]
	aa=len([c for c in list(s) if c==cc])
	
	if aa == 2:
		return 'Yes'
	return 'No'
	

if __name__ == "__main__":
	print(main())
	
	

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

using namespace std;

typedef complex<double> Point;
const double eps = 1e-10;

double dot(Point a,Point b)
{
    return real(b*conj(a));
}

double cross(Point a,Point b)
{
    return imag(b*conj(a));
}

Point projection(Point p,Point a,Point b)
{
    Point m = b-p;
    Point ab = b-a;
    Point n = dot(m,ab)/abs(ab)*ab/abs(ab);
    return b - n;
}

Point rotation(Point l,double theta)
{
    double x = l.real(), y = l.imag();
    double c = cos(theta),s = sin(theta);
    return Point(x*c-y*s,x*s+y*c);
}

bool eq(double a,double b)
{
    return abs(a-b)<eps;
}

bool eq(Point a,Point b)
{
    return eq(a.real(),b.real())&&eq(a.imag(),b.imag());
}

bool online(Point a,Point b,Point c)
{
    return eq(abs(c-a)+abs(b-c),abs(a-b));
}

vector<Point> intersectPoint(Point a,Point b,double r)
{
    Point mid = projection(Point(0,0),a,b);

    vector<Point> rs;

    if(eq(mid,Point(0,0)))
    {
        Point ab = b-a;
        Point p = ab*r/abs(ab);
        if(online(a,b,p))
            rs.push_back(p);
        p = -ab*r/abs(ab);
        if(online(a,b,p))
            rs.push_back(p);
    }else
    {
        double theta = acos(abs(mid)/r);
        Point p = rotation(mid,theta);
        p = p*r/abs(p);
        if(online(a,b,p))
            rs.push_back(p);
        p = rotation(mid,-theta);
        p = p*r/abs(p);
        if(online(a,b,p))
            rs.push_back(p);
    }

    return rs;
}


double intersection(Point a,Point b,double r)
{
    if(eq(cross(a,b),0)) return 0;
    int sign = cross(a,b)/abs(cross(a,b));
    double len1=abs(a),len2=abs(b);
    if(len1>len2) swap(a,b),swap(len1,len2);

    double area = 0;
    if(len1<r+eps&&len2<r+eps)
    {
        area = 0.5*abs(cross(a,b));
    }else
    {
        vector<Point> rs=intersectPoint(a,b,r);
        if(len1<r&&len2>r)
        {
            Point p = rs[0];
            area = 0.5*abs(cross(a,p));
            double theta = acos(dot(b,p)/abs(b)/abs(p));
            area += 0.5*theta*r*r;
        }else if(rs.size()==2)
        {
            if(abs(rs[0]-a)>abs(rs[1]-a)) swap(rs[0],rs[1]);
            area = 0.5*abs(cross(rs[0],rs[1]));
            double theta = acos(dot(a,rs[0])/abs(a)/abs(rs[0]));
            area += 0.5*theta*r*r;
            theta = acos(dot(b,rs[1])/abs(b)/abs(rs[1]));
            area += 0.5*theta*r*r;
        }else
        {
            double theta = acos(dot(a,b)/abs(a)/abs(b));
            area = 0.5*theta*r*r;
        }

    }
    return sign*area;
}

double getCommonArea(const vector<Point> &g,double r)
{
    double ans = 0;
    int sz = g.size();

    for(int i=0;i<sz;i++)
    {
        ans += intersection(g[i],g[(i+1)%sz],r);
    }

    return ans;
}

int main()
{
    int n,r;
    cin>>n>>r;
    vector<Point> g;
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        g.push_back(Point(x,y));
    }

    cout<<fixed<<setprecision(10);
    cout<<getCommonArea(g,r)<<endl;

    return 0;
}



Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  int count=0;
  for(int i=0; i<s.size(); i++)
  {
      if(s[i]=='A')
      {
          if(s[i+1]=='B'&&s[i+2]=='C')
            count++;
      }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 3588
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;

char str[100];
int num[30];

int main(){
  scanf("%s", str);
  for(int i = 0; i < 30; i++)
    num[i] = 0;

  int l = strlen(str);
  for(int i = 0; i < l; i++){
    int code = str[i] - 'a';
    num[code]++;
  }

  bool f = true;
  for(int i = 0; i < 30; i++){
    f = f && (num[i] % 2) == 0;
  }  

  if(f)
    printf("Yes\n");
  else
    printf("No\n");
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    int n;
    cin >> n;
    for(int i = 100; i < 1000; i++)
    {
        if(i < n) continue;
        string s = to_string(i);
        bool flag = true;
        for(int i = 0; i < s.size(); i++)
        {
            if(s[i] != s[0])
            {
                flag = false;
            }
        }
        if(flag)
        {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }


int main() {
    int A, B;
    cin >> A >> B;

    if ((A+B) % 2 != 0) print("IMPOSSIBLE");
    else print((A+B) / 2);

    return 0;
}



Measured memory_bytes: 256
//Abhigyan's Code:
             
    //YOU DON'T DARE TO COPY :) 

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long int ll;
    typedef unsigned long long int ull;
    #define checker cout<<"CHECKED" 
    #define modulo 1000000007
    
    int main()
    {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      ll n ;
      cin >> n;

      ll wt;
      cin >> wt;

      ll t = n;
      ll i = 0;

      ll dp[n+1][wt+1];

      vector< pair<ll,ll> > vop(t);

      while(t--)
      {
        ll a , b;
        cin >> a >> b ;
        vop[i] =make_pair(a, b);
        i++;
      }

      dp[0][0] = 0;

      for(ll i =0 ; i<= n; i++)
      {
        for(ll j =0 ; j<=wt ; j++)
        {
          if(i ==0 || j ==0)
            dp[i][j] =0;
          else if(vop[i-1].first <= j)
          {
            dp[i][j] = max(dp[i-1][j] , vop[i-1].second + dp[i-1][j- vop[i-1].first] ); 
          }
          else
          {
            dp[i][j] = dp[i-1][j];
          }  
        }

      }

      cout<<dp[n][wt];

      return 0 ;

    } 

Measured memory_bytes: 82512
#include <iostream>
typedef long long ll;
using namespace std;

// ll sumArray(ll a[], int n)
// {
// 	ll sum = 0;
// 	for (int i = 0; i < n; i++)
// 	{
// 		sum += a[i];
// 	}
// 	return sum;
// }

int main()
{
	int N, M, K;

	int ans = 0;
	int ans_tmp;

	cin >> N >> M >> K;

	ll A[N];
	ll B[M];
	ll A_acc[N + 1];
	ll B_acc[M + 1];
	A_acc[0] = 0;
	B_acc[0] = 0;

	for (int i = 0; i < N; i++)
		cin >> A[i];
	for (int j = 0; j < M; j++)
		cin >> B[j];

	for (int i = 1; i < N + 1; i++)
	{
		A_acc[i] = A_acc[i - 1] + A[i - 1];
		// cout << A_acc[i] << endl;
	}
	for (int i = 1; i < M + 1; i++)
	{
		B_acc[i] = B_acc[i - 1] + B[i - 1];
		// cout << B_acc[i] << endl;
	}

	int j = M;
	for (int i = 0; i < N + 1; i++)
	{
		if (A_acc[i] > K)
			break;
		// cout << B_acc[j] << endl;
		while (B_acc[j] > K - A_acc[i])
		{
			j--;
			// cout << j << endl;
		}
		ans_tmp = i + j;
		// cout << "i: " << i << endl;
		// cout << "j: " << j << endl;
		// cout << "ans: " << ans_tmp << endl;
		if (ans_tmp > ans)
			ans = ans_tmp;
	}

	cout << ans << endl;
}


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

int main()
{
  int N;
  string S;
  cin >> N >> S;

  string ans = N % 2 == 1 ? "No" : "Yes";

  for (int i = 0; i < N / 2; i++)
  {
    if (S.at(i) != S.at(i + N / 2))
      ans = "No";
  }

  cout << ans << endl;
}


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

 
int main() {
    int N;
    int flag = 0;
    int fizz[1000000];
    fizz[0] = 0;
    long result = 0;
    
    cin >> N; 
    for (int i = 1; i <= N; i++) {
        if(i%3 != 0 && i%5 != 0){
            fizz[i] = i;
        }
        else{
            fizz[i] = 0;
        }
        result += fizz[i];
    }
    
          cout << result << endl;
}

Measured memory_bytes: 3636