akhauriyash/Code-Regression huggingface dataset:
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N, M;
	std::vector<std::pair<int, bool>> PS;
	std::cin >> N >> M;
	PS.resize(M);
	for (auto& ps : PS) {
		std::string s;
		std::cin >> ps.first;
		std::cin >> s;
		ps.first--;
		ps.second = (s == "AC");
	}
	
	std::vector<bool> AC(N);
	for (const auto& ps : PS) {
		if (ps.second)
			AC[ps.first] = true;
	}

	int acs = 0;
	for (auto ac : AC) {
		if (ac)
			++acs;
	}

	int penalty = 0;
	for (const auto& ps : PS) {
		if (AC[ps.first]) {
			if (ps.second)
				AC[ps.first] = false;
			else
				++penalty;
		}
	}
	
	std::cout << acs << " " << penalty << "\n";
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
    int n, m;
    cin >> n >> m;
    int sum = 0;
    rep(i, m) {
        int a;
        cin >> a;
        sum += a;
    }
    int ans = n - sum;
    ans = max(ans, -1);
    cout << ans << endl;
}


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

vector<int> dp(100005,-1);
vector<vector<int>> g(100005);


// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

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;}
    //a^tを求める
    //例：d[i] = mint(k/i).pow(n);
    //mint(2).pow(n); 2^n
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

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



int main(){
  int h,w;
  cin>>h>>w;
  vector<string> g(h);
  mint dp[h+1][w+1];
  rep(i,h+1)rep(j,w+1)dp[i][j]=0;
  rep(i,h){
    string now;
    cin>>now;
    g[i]=now;
  }
  dp[0][1]=1;
//  dp[1][0]=1;
  rep(i,h)rep(j,w){
    if (g[i][j]=='.'){
      dp[i+1][j+1]+=dp[i+1][j];
      dp[i+1][j+1]+=dp[i][j+1];
    }
    else dp[i+1][j+1]=0;
  //  cout<<dp[i+1][j+1]<<"i"<<i<<"j"<<j<<endl;
  }
cout<<dp[h][w].x;

}


Measured memory_bytes: 14808
#!/usr/bin/env pypy3

def ans(N, A, B):
    B = B[::-1]

    match_vals = set()

    for i in range(N):
        if A[i] == B[i]:
            match_vals.add(A[i])

    if len(match_vals) == 0:
        print("Yes")
        print(*B)
        return

    assert(len(match_vals) == 1)
    [m] = list(match_vals)

    ok = []
    bad = []
    for i in range(N):
        if B[i] != m and A[i] != m:
            ok += [i]
        if A[i] == B[i]:
            bad += [i]

    if len(bad) > len(ok):
        print('No')
        return

    for i in range(len(bad)):
        B[bad[i]], B[ok[i]] = B[ok[i]], B[bad[i]]

    print('Yes')
    print(*B)

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans(N, A, B)

Measured memory_bytes: 115628
#include<bits/stdc++.h>
#define INF 10000000000ll
#define ll long long
using namespace std;
signed main(){
  ll n,m,x,y,a,b;
  cin>>n>>m>>x>>y;
  for(int i=0;i<n;i++){
    cin>>a;
    x = max(a,x);
  }
  for(int i=0;i<m;i++){
    cin>>b;
    y = min(y,b);
  }
  if(y > x){
    cout<<"No War\n";
  }else{
    cout<<"War\n";
  }
  return 0;
}

Measured memory_bytes: 256
/**
 *     author: nayakashutosh9
 *     college: National Institute of Technology, Rourkela
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
const int N = 200005;

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




int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	// int t, z = 1; cin >> t;
	// cin.ignore();
	// while (t--) {

	// }
	int n; cin >> n;
	vector<int> a(n);
	int sum = 0;
	map<int, int> m; m.clear();
	for (int i = 0; i < n; i++) cin >> a[i], m[a[i]]++, sum += a[i];
	int q; cin >> q;
	while (q--) {
		int x, y; cin >> x >> y;
		sum -= (x * m[x]);
		sum += (y * m[x]);
		if (m.count(y)) m[y] += m[x];
		else m[y] = m[x];
		m.erase(x);
		cout << sum << endl;
	}
	return 0;
}


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

int main()
{
	int N, M;

	cin >> N >> M;

	string A[N];
	string B[M];

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

	for (int istart = 0; istart < N - M+1; istart++)
	{
		for (int jstart = 0; jstart < N - M+1; jstart++)
		{
			bool flg = true;

			for (int i = 0; i < M; i++)
			{
				for (int j = 0; j < M; j++)
				{
					if (A[istart + i][jstart + j] != B[i][j])
					{
						flg = false;
					}
				}
			}

			if (flg == true)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))

from fractions import gcd 

def lcms(List):
    __ = 1
    for _ in List:
        __ =int(__ * _ // gcd(__, _))
    return __

x = lcms(l)-1

y=0
for j in range(n):
    y+=(x)%l[j]

print(y)

Measured memory_bytes: 5160
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N;
int A[100005];
char op[100005];
int dp[100005][5];
//    [i項目][i項目までに開いているかっこの数]

int solve(){
    for(int i=0;i<100005;++i)for(int j=0;j<5;++j)dp[i][j]=-INF;
    dp[0][0] = A[0];
    for(int i=0;i<N-1;++i){
        for(int j=0;j<=3ll;++j){
            int f;
            if(j%2==0)f=1;
            else f=-1;
            int t1 = f*A[i+1];
            if(op[i+1]=='+'){
                dp[i+1][j] = max(dp[i][j]+t1,dp[i+1][j]);
                if(j!=0)dp[i+1][j-1] = max(dp[i][j]+t1,dp[i+1][j-1]);
            }
            else {
                dp[i+1][j] = max(dp[i][j]-t1,dp[i+1][j]);
                dp[i+1][j+1] = max(dp[i][j]-t1,dp[i+1][j+1]);
                if(j!=0)dp[i+1][j-1] = max(dp[i][j]-t1,dp[i+1][j-1]);
            }
        }
    }
    int ans=-INF;
    for(int i=0;i<=3;++i)ans=max(dp[N-1][i],ans);
    return ans;
}


signed main(){
    cin>>N;
    op[0]='+';
    for(int i=0;i<N;++i){
        cin>>A[i];
        if(i!=N-1)cin>>op[i+1];
    }
    cout<<solve()<<endl;
}


Measured memory_bytes: 4992
// In the name of GOD
 
#include <bits/stdc++.h>
#define ll long long
#define pp pair <int, int>
using namespace std;
const int N = 2e5 + 10, MOD = 1e9 + 7;
const ll INF = 1e18;

vector <vector <int>> adj(N);
bool vis[N];
vector <ll> ans(N);

void dfs(int node, int parent) {
	if  (parent != -1)
		ans[node] += ans[parent];
	for (int v : adj[node]) {
		if(v == parent)	continue;
			dfs(v, node);
	}
} 
void solve() {
	int n, q;
	cin >> n >> q;
	for (int i = 0; i < n - 1; ++i) {
		int x, y;
		cin >> x >> y;
		--x; --y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}

	memset(vis, 0, sizeof vis);
	for (int i = 0; i < q; ++i) {
		int node;
		int val;
		cin >> node >> val;
		--node;
		ans[node] += val;
	}
	// for (int i = 0; i < n; ++i)
	// 	cout << ans[i] << " ";
	// cout << "\n";
	dfs(0, -1);
	for (int i = 0; i < n; ++i)
		cout << ans[i] << " ";
}

int main () {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        solve();
    }
}                                  

Measured memory_bytes: 24448
import queue
def s():
 N=int(input())
 M=[input().split()[2:]for _ in[0]*N]
 q=queue.Queue();q.put(0)
 d=[-1]*N;d[0]=0
 while not q.empty():
  u=q.get()
  for v in M[u]:
   v=int(v)-1
   if d[v]<0:d[v]=d[u]+1;q.put(v)
 for i in range(N):print(i+1,d[i])
if'__main__'==__name__:s()


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

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



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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
long long gcd(long long x, long long y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

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

int main(){
    

    long long n,m;
    cin>>n>>m;

    long long a[n];
    long long ans=0;
    int cnt=0;
    rep(i,n){
        cin>>a[i];
        
        if(a[i]%2!=0){
            cout<<ans<<endl;
            return 0;
        }
        else{
            a[i]/=2;
            int tmp=0;
            long long A=a[i];
            while(A%2==0){
                A/=2;
                tmp++;
            }
            if(cnt!=tmp && cnt>0){
                cout<<ans<<endl;
                return 0;
            }
            else{
                cnt=tmp;
            }
        }
        
    }
    long long LCM=1;
    rep(i,n){
        LCM=lcm(LCM,a[i]);
    }
    //cout<<LCM<<endl;
    ans=floor((long double)m/LCM);
    ans=ceil((long double)ans/2);

    cout<<ans<<endl;

    return 0;

}
/*


*/


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
const double PI = acos(-1);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

/*C++になってるか確認したほうがよくない？WOWWOW*/
/*DP使ったほうがよくない？？WOWWOW*/

int main(){
    int A, B, C, K; cin>>A>>B>>C>>K;
    ll ans;
    if(K<A){
        ans=K;
    }
    else if(K<=A+B){
        ans=A;
    }
    else{
        ans=A-(K-A-B);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
int main(void){
    // Here your code !
    int N,P,K,i;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d%d",&K,&P);
        if( K % P == 0)printf("%d\n", P);
        else printf("%d\n", K % P);
    }
    return 0;
}

Measured memory_bytes: 596
from collections import defaultdict
H,W,D = map(int,input().split())
grid = [[0]*W for _ in range(H)]
for h in range(H):
    grid[h] = list(map(int, input().split()))
number_yx = [[0,0] for _ in range(H*W+1)]
for y in range(H):
    for x in range(W):
        number_yx[grid[y][x]] = [y,x]
fromto_cost = defaultdict(lambda: defaultdict(int))
for mod_group in range(D):
    # 剰余ごとにスタートを決定
    start = mod_group+1
    previous = start
    fromto_cost[start][start] = 0
    previous_y, previous_x = number_yx[previous]
    cost = 0
    while previous+D <= (H*W):
        Next = previous+D 
        Next_y, Next_x = number_yx[Next]
        cost += abs(Next_y-previous_y) + abs(Next_x-previous_x)
        fromto_cost[start][Next] = cost

        previous = Next
        previous_y,previous_x = Next_y,Next_x

Q = int(input())
ans_ls = [0] * Q
for i in range(Q):
    start, goal = map(int,input().split())
    mod = start % D
    base = mod
    if base == 0:
        base = D 
    base_to_goal = fromto_cost[base][goal]
    base_to_start = fromto_cost[base][start]
    ans_ls[i] = base_to_goal - base_to_start
for ans in ans_ls:
    print(ans)



Measured memory_bytes: 53756
#include<iostream>
using namespace std;
int main()
{
	int n,c=0,x=0;
	string ch;
	cin>>n;
	for(int i=0;i<n;i++)
    {
	cin>>ch[i];
    }
	for(int i=0;i<n;i++)
    { 
    	if(ch[i]=='I')
    	{		
		x++;          
    	c=max(c,x);    
        }
		else if(ch[i]=='D')
    	x--;        	
    	else
    	break;
	}
	cout<<c;

}

Measured memory_bytes: 256
from collections import Counter, deque
import heapq


def Dijkstra(C, s):
    q = []
    inf = float("inf")
    f = [inf] * 11
    f[-1] = 0
    f[s] = 0
    heapq.heappush(q, (0, s))
    while len(q) != 0:
        # print(q)
        # print(f)
        cost, index = heapq.heappop(q)
        if index == 1:
            return f[index]
        if f[index] < cost:
            continue
        for i in range(10):
            if cost + C[index][i] < f[i]:
                f[i] = cost + C[index][i]
                heapq.heappush(q, (f[i], i))
    return "hoge"


H, W = map(int, input().split())
C = []
A = []
for _ in range(10):
    C.append(list(map(int, input().split())))

for _ in range(H):
    A.append(list(map(int, input().split())))

c = Counter()
for i in range(H):
    for j in range(W):
        c[A[i][j]] += 1
D = []
for i in range(10):
    D.append(Dijkstra(C, i))
D.append(0)
s = 0
for i, j in c.items():
    s += D[i] * j

print(s)


Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll md=((1e+9)+7);
ll fact[100051];
ll inv[100051];
int extgcd(ll a, ll b, ll& x,ll& y){
  int d = a;
  if(b) {
    d = extgcd(b,a % b, y, x);
    y = (y - (a / b) * x) %md;
  }else{
    x=1;
    y=0;
  }
  return d;
}

ll factinv(ll a) {
  ll x, y;
  extgcd(a, md, x, y);
  return (x<0?x+md:x);
}

void init(int n){
  fact[0]=1;inv[0]=1;
  fact[1]=1;inv[1]=1;
  for(int i=2;i<=100050;i++){
    fact[i]=(fact[i-1]*i)%md;
    if(fact[i]<0)fact[i]+=md;
    inv[i]=factinv(fact[i]);
  }
}

ll conb(int n, int r){
  return (((fact[n+r-1]*inv[n-1])%md)*inv[r])%md;
}

int main(){
  int n,m;
  cin>>n>>m;
  init(n);
  vector<pair<int,int> > pv;
  for(int i=2;m!=1;i++){
    int cnt=0;
    if(m%i!=0) continue;
    while(m%i==0){
      m/=i;
      cnt++;
    }
    pv.push_back(pair<int,int>(i,cnt));
  }
  ll ans = 1;
  for(int i=0;i<pv.size();i++){
    ans = ans*conb(n,pv[i].second)%md;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>

using namespace std;

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
 
 int solve()
 { 
  int n;
string a,b,c;
cin>>n>>a>>b>>c;
int count=0;
rep(i,0,n)
{  char a1=a[i],b1=b[i],c1=c[i];
  if(a1==b1&&b1==c1)continue;
  else if(a1==b1&&b1!=c1)count+=1;
    else if(a1==c1&&c1!=b1)count+=1;
    else if(b1==c1&&c1!=a1)count+=1;
    else count+=2;


}
cout<<count ;
return 0;
}


int main()
{  int t=1;


  
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
  
 

  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;
    bool flag=true;
   while(t--)
     { 
      solve();
     }

         time_req = clock() - time_req;
   // cout << "Processor time taken is "
     //  << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
s=[input()for _ in range(h)]

yoko=[[0]*2005 for _ in range(2005)]
tate=[[0]*2005 for _ in range(2005)]

for i in range(h):
	for j in range(w):
		if s[i][j] == ".":
			yoko[i][j]+=1
			if j>0:
				yoko[i][j]+=yoko[i][j-1]
	for j in range(w-2,-1,-1):
		yoko[i][j] = max(yoko[i][j],yoko[i][j+1]) if yoko[i][j] else 0

for j in range(w):
	for i in range(h):
		if s[i][j] == ".":
			tate[i][j]+=1
			if i>0:
				tate[i][j]+=tate[i-1][j]
	for i in range(h-2,-1,-1):
		tate[i][j] = max(tate[i][j],tate[i+1][j])  if tate[i][j] else 0

ans = 0
for i in range(h):
	for j in range(w):
		ans = max(ans,yoko[i][j]+tate[i][j]-1)
print(ans)

Measured memory_bytes: 124632
import java.io.*;

class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String[] str = buf.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			if(H==0 && W==0)
				break;
			for(int i=1; i<=H; i++){
				for(int j=1; j<=W; j++){
					System.out.print("#");
				}
				System.out.println();
			}
                  System.out.println();
      
		}
	}	
}

Measured memory_bytes: 30860
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;
typedef pair<ll,ll> P;

ll N;
map<P,ll> coloredge;
vector<ll> edge[100010];
ll nodecolor[100010];
queue<ll> que;
//edgeをi=1から並べるのに使う
P edgeorder[100010];

//bfsを使って処理

ll bfs(){
  ll count=0;
  que.push(1);
  nodecolor[1]=0;
  while(!que.empty()){
    ll s=que.front();que.pop();
    ll color=0;
    for(const auto t:edge[s]){
      if(nodecolor[t]==-1){
        ++color;
        if(color==nodecolor[s])++color;
        nodecolor[t]=color;
        coloredge[P(max(t,s), min(t,s))]=color;
        que.push(t);
      }
    }
    count=max(count,color);
  }
  return count;
}

int main(){
  cin>>N;
  FOR(i,1,N){
    ll s,t;
    cin>>s>>t;
    edgeorder[i]={max(s,t),min(s,t)};
    edge[s].push_back(t);
    edge[t].push_back(s);
  }
  fill(nodecolor,nodecolor+N+5,-1);

  cout<<bfs()<<endl;
  FOR(i,1,N){
    cout<<coloredge[edgeorder[i]]<<endl;
  }

}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll k, cur = 0;
	cin >> k;
	bool b[k];
	fill(b, b + k, false);
	for (ll i = 1; ; i++){
		cur *= 10;
		cur += 7;
		cur %= k;
		if (b[cur]) break;
		b[cur] = true;
		if (cur == 0){
			cout << i;
			return 0;
		}
	}
	cout << "-1";
}

Measured memory_bytes: 4540
#include <iostream>
#include <string>

using namespace std;

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

  int64_t t  = a - k > 0 ? a - k : 0;
  int64_t ao = b - (k - a) > 0 ? b - (k - a) : 0;

  if (a - k > 0)
  {
    t  = a - k;
    ao = b;
  }
  else
  {
    t  = 0;
    ao = b - (k - a) > 0 ? b - (k - a) : 0;
  }

  cout << t << " " << ao << endl;

  return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll A[3];
    rep(i, 0, 3) scanf("%lld", A+i);
    ll MAX=A[0];
    rep(i, 0, 3) chmax(MAX, A[i]);
    ll sum=0;
    rep(i, 0, 3) sum+= A[i];
    if(MAX*2==sum)printf("Yes\n");
    else printf("No\n");
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <cstring>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair

using namespace std;

typedef pair<int, int> P;

const int INF = 1<<29;

int dist(P a, P b){
	return abs(a.first-b.first) + abs(a.second-b.second);
}

int dp[2][10000];
int main(){
	int w, h;
	while(cin >> w >> h, w|h){
		vector<vector<P> > num(10000);
		P s, g;
		int max_el = 0;
		rep(i, h) rep(j, w){
			string in;
			cin >> in;

			if(in == ".") continue;
			if(in == "S"){
				s = MP(j, i);
				continue;
			}
			if(in == "G"){
				g = MP(j, i);
				continue;
			}
			int x = atoi(in.c_str());
			num[x].push_back(MP(j, i));
			max_el = max(max_el, x);
		}
		num[0].push_back(s);
		num[max_el+1].push_back(g);
		int *cur = dp[0];
		int *next = dp[1];
		memset(dp[0], 0, sizeof(dp[0]));
		rep(i, max_el+1){
			rep(k, num[i+1].size()) next[k] = INF;
			rep(j, num[i].size()){
				rep(k, num[i+1].size()){
					next[k] = min(next[k], cur[j] + dist(num[i][j], num[i+1][k]));
				}
			}
			swap(cur, next);
		}
		cout << cur[0] << endl;
	}

	return 0;
}

Measured memory_bytes: 1588
#include<stdio.h>
#include<string.h>
using namespace std;
#define rep(i,j) for(int i=0;i<(j);i++)
int memo[15000000];
int main(){
	int n,m,w[1501],h[1501],t,s,cnt;
	for(;;){
		scanf("%d%d",&n,&m);
		if(!n)break;
		cnt=s=*w=*h=0;
		memset(memo,0,sizeof(memo));
		rep(i,n){
			scanf("%d",&t);
			s+=t;
			w[i+1]=s;
		}
		s=0;
		rep(i,m){
			scanf("%d",&t);
			s+=t;
			h[i+1]=s;
		}
		
		rep(i,n+1)rep(j,i){
			int c=0;
			int len = w[i] - w[j];
			if(memo[len]>0){
				cnt+=memo[len];
				continue;
			}
			int l=0,r=1;
			while(r<=m){
				if(h[r]-h[l]==len){
					c++;
					r++;
					l++;
				}
				else if(h[r]-h[l]<len)r++;
				else l++;
			}
			memo[len]=c;
			cnt+=c;
		}
		printf("%d\n",cnt);
	}
	return 0;
}

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

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

    if (a * b % 2 == 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios		ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
	ios
	ll a,b,c;
	cin>>a>>b>>c;
	ll k;
	cin>>k;
	if(a==max(a,max(b,c)))
	cout<<pow(2LL,k)*a+b+c;
	else if(b==max(a,max(b,c)))
	cout<<pow(2LL,k)*b+a+c;
	else
	cout<<pow(2LL,k)*c+a+b;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long K, long long A, long long B){
    bool isValid = false;
    rep(i,1,1000) {
        if (A <= i*K && i*K <= B) {
            isValid = true;
            break;
        }
    }
    cout << (isValid ? "OK" : "NG") << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long K;
    scanf("%lld",&K);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(K, A, B);
    return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <vector>

using namespace std;

vector<int> G[100000];
bool used[100000];
int grundy[100000];

void dfs(int v){
    used[v] = true;
    grundy[v] = 0;
    for(int i = 0; i < G[v].size(); i++){
        if(!used[G[v][i]]){
            dfs(G[v][i]);
            grundy[v] ^= (grundy[G[v][i]]+1);
        }
    }
}

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N-1; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    dfs(0);
    if(grundy[0] != 0){
        cout << "Alice" << endl;
    }else{
        cout << "Bob" << endl;
    }
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/11/11  Problem: ABC 085 A / Link: http://arc085.contest.atcoder.jp/tasks/arc085_a  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N,M;

LL ans = 0LL;

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

	string s;
	cin >> N>>M;
	cout << (M * 1900 + (N - M) * 100)*pow(2, M) << endl;


	return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
  int dayl[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
  int today[2];
  int dayt=0;
  int ans;
  while(cin>>today[0]>>today[1]){
    if(today[0]==0&&today[1]==0) break;
    for(int i=0;i<today[0];i++) dayt += dayl[i];
    dayt += today[1];
    ans = dayt % 7;
    if(ans==1) cout << "Thursday" << endl;
    else if(ans==2) cout << "Friday" << endl;
    else if(ans==3) cout << "Saturday" << endl;
    else if(ans==4) cout << "Sunday" << endl;
    else if(ans==5) cout << "Monday" << endl;
    else if(ans==6) cout << "Tuesday" << endl;
    else  cout << "Wednesday" << endl;
    dayt = 0;
  }
  return 0;
}

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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int a = A + B , b = C + D;
  
  if (a > b) {
    cout << "Left" << endl;
  }
  else if (a < b) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 3676
n = int(input())
cards = []
for _ in range(n):
    suit, num = input().split()
    num = int(num)
    cards.append((suit, num))

for suit in ('S', 'H', 'C', 'D'):
    for num in range(13):
        if not((suit, num + 1) in cards):
            print(suit, num + 1)



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

struct UF{
  int par[MAX];
  int ran[MAX];
  int val[MAX];
  ll dat[MAX];
  vector< int > G[MAX];
  vector< int > g[MAX];
  vector< ll > h[MAX];
  int t[MAX],u[MAX];
  void init(){
    for(int i=0;i<MAX;i++){
      par[i]=i;
      ran[i]=1;
      val[i]=-1;
      dat[i]=0;
      t[i]=u[i]=-1;
      G[i].push_back(0);
      g[i].push_back(1);
      h[i].push_back(-1);
    }
  }
 
  int find(int x){
    if(par[x]==x)return x;
    else return par[x]=find(par[x]);
  }
 
  void unite(int x,int y,int z=-1){
    x=find(x);y=find(y);
    if(x==y)return;
    if( ran[x] > ran[y] )swap(x,y);
    par[x]=y;
    t[x]=y;
    u[x]=z;
    G[y].push_back(z);
    g[y].push_back(ran[y]+ran[x]);
    h[y].push_back(dat[y]+dat[x]);
    ran[y]+=ran[x];
    dat[y]+=dat[x];
    val[y]=z;
  }
 
  bool same(int a,int b){
    return (find(a)==find(b));
  }
 
  int calc(vector<int> &V,vector<int> &v,int mid){
    vector<int> :: iterator it;
    it = upper_bound( V.begin(),V.end(),mid);
    if(it==V.begin())return 0;
    it--;
    int id= it-V.begin();
    return v[id];
  }
  ll calc(vector<int> &V,vector<ll> &v,int mid){
    vector<int> :: iterator it;
    it = upper_bound( V.begin(),V.end(),mid);
    if(it==V.begin())return 0;
    it--;
    int id= it-V.begin();
    return v[id];
  }
  int funcSize(int x,int mid){
    while( t[x]!=-1 && u[x] <= mid )x=t[x];
    return calc(G[x],g[x],mid);
  }
  ll funcDat(int x,int mid){
    while( t[x]!=-1 && u[x] <= mid )x=t[x];
    /*
    for(auto p:G[x])cout<<p<<' ';
    cout<<endl;
    for(auto p:h[x])cout<<p<<' ';
    cout<<endl;
    */
    return calc(G[x],h[x],mid);
  }
  
};

struct edge{
  int a,b,y;
  bool operator < ( const edge &e ) const {
    return y < e.y;
  }
};

int N,M;
int X[100005];
int A[100005];
int B[100005];
int Y[100005];
edge edges[100005];
bool used[100005];

vector< edge > graph[100005];

UF uf;

void dfs(int a,int y){
  used[a]=true;
  for(edge e:graph[a]){
    if(e.y <= y){
      if(!used[e.b]){
        dfs(e.b,y);
      }
    }
  }
}

int main(){
  uf.init();
  ll total=0;
  
  cin>>N>>M;
  for(int i=0;i<N;i++){
    cin>>X[i];
    uf.dat[i]=X[i];
    total += X[i];
  }
  for(int i=0;i<M;i++){
    cin>>A[i]>>B[i]>>Y[i];
    A[i]--;
    B[i]--;
    edges[i]=(edge){ A[i],B[i],Y[i] };
    graph[ A[i] ].push_back( (edge){A[i],B[i],Y[i]} );
    graph[ B[i] ].push_back( (edge){B[i],A[i],Y[i]} );
  }
  sort(edges,edges+M);

  for(int i=0;i<M;i++){
    //    cout<< edges[i].a <<' '<< edges[i].b << ' '<< edges[i].y <<endl;
    uf.unite( edges[i].a, edges[i].b, edges[i].y );
  }

  reverse(edges,edges+M);

  //  cout<<uf.funcDat( 1 , 12 ) <<endl;
  
  ll ans=0;
  for(int i=0;i<M;i++){
    edge e=edges[i];
    if( used[e.a] || used[e.b] )continue;
    
    if( uf.funcDat( e.a , e.y ) >= e.y ){
      dfs(e.a,e.y);
    }else{
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 32612
from collections import defaultdict
from itertools import groupby, accumulate, product, permutations, combinations
from math import gcd

def reduction(x,y):
    g = gcd(x,y)
    return abs(x)//g,abs(y)//g

def solve():
    mod = 10**9+7
    dplus = defaultdict(lambda: 0)
    dminus = defaultdict(lambda: 0)
    N = int(input())
    x0,y0,xy0 = 0,0,0
    for i in range(N):
        x,y = map(int, input().split())
        if x==0 and y==0:
            xy0 += 1
        elif x==0 and y!=0:
            x0 += 1
        elif y==0:
            y0 += 1
        elif x*y>0:
            dplus[reduction(x,y)] += 1
        else:
            dminus[reduction(-y,x)] += 1
    ans = pow(2,x0,mod)+pow(2,y0,mod)-1
    other = N-x0-y0-xy0
    for k,v in dplus.items():
        ans *= pow(2,dminus[k],mod)+pow(2,v,mod)-1
        other -= dminus[k]+v
    ans *= pow(2,other,mod)
    ans += xy0-1
    ans %= mod
    return ans
print(solve())


Measured memory_bytes: 148292
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
using namespace std;

void getVector(int num, vector<int> &vec){
    int i;
    vec.clear();
    while (num % 2 == 0){
        vec.push_back(2);
        num /= 2;
    }
    for (i = 3; i <= num; i++){
        while (num % i == 0){
            vec.push_back(i);
            num /= i;
        }
    }
}

int main() {
    int A,B;
    cin >> A >> B;
    vector<int> A_vec, B_vec;
    getVector(A, A_vec);
    getVector(B, B_vec);
    sort(A_vec.begin(), A_vec.end());
    sort(B_vec.begin(), B_vec.end());
    long long ret = 1;
    auto a(A_vec.begin()), b(B_vec.begin());
    while (a != A_vec.end() && b != B_vec.end()) {
        if (*a == *b) {
            ret *= *a;
            a ++;
            b ++;
            continue;
        }
        if (*a < *b) {
            ret *= *a;
            a ++;
            continue;
        }
        if (*a > *b) {
            ret *= *b;
            b ++;
            continue;
        }
    }
    while (a != A_vec.end()) {
        ret *= *a;
        a ++;
    }
    while (b != B_vec.end()) {
        ret *= *b;
        b ++;
    }
    cout << ret << endl;
    return 0;
}

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

long long n;
string s;
vector<long long> cnt, sum;

long long solve();

int main() {
  cin >> s;
  n = s.size();
  cout << solve() << endl;
  return 0;
}

long long solve() {
  reverse(s.begin(), s.end());
  cnt.assign(2019, 0);
  sum.assign(n + 1, 0);
  cnt[0] = 1;
  long long res = 0, ten = 1;
  for (int i = 0; i < n; ++i, (ten *= 10) %= 2019) {
    sum[i + 1] = sum[i];
    sum[i + 1] += (s[i] - '0') * ten;
    sum[i + 1] %= 2019;
    res += cnt[sum[i + 1]];
    ++cnt[sum[i + 1]];
  }
  return res;
}


Measured memory_bytes: 5192
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstdlib>
#include <ctime>
#include <deque>
using namespace std;

long long k;
long long s[100];
char ss[9] = {' ', 'F', 'E', 'S', 'T', 'I', 'V', 'A', 'L'};
vector <int> Check;
vector <long long> num;
string ans;
int sspp[10000];

int main() {
	// cin >> k;
	int tot; 
	s[0] = 1;
	for (int i = 1; i <= 7; i++)
		s[i] = 1, ans.push_back(ss[i]);
	tot = 3000;
	int RND = 0;
	Check.push_back(ans.size());
	num.push_back(s[7]);
	while (tot > 0) {
		RND += 1;
		if (RND < 7)
		for (int j = 7 - RND + 1; j <= 7; j++)
			for (int i = 1; i <= 4 + RND; i++)
					s[j] += s[j - 1], tot -= 1, ans.push_back(ss[j]);
		else
			for (int j = 1; j <= 7; j++)
				for (int i = 1; i <= 4 + RND; i++)
						s[j] += s[j - 1], tot -= 1, ans.push_back(ss[j]);
		// RND += 1;
		// cout << ans << endl;
		Check.push_back(ans.size());
		num.push_back(s[7]);
		// printf("%lld %lf\n", s[7], log(s[7]) / log(10));
	}

	for (int j = 1; j <= 200; j++)
		s[6] += s[5], ans.push_back(ss[6]);
	for (int j = 1; j <= 200; j++)
		s[7] += s[6], ans.push_back(ss[7]);
	Check.push_back(ans.size());
	num.push_back(s[7]);
	// printf("%lld %lf\n", s[7], log(s[7]) / log(10));
	// for (int i = 1; i <= n)
	cin >> k;
	for (int i = (int) num.size() - 1; i >= 0; i--) {
		// cout << num[i] << endl;
		while (k >= num[i])
			sspp[i] += 1, k -= num[i];
		// printf("%lld %d\n", num[i], sspp[i]);
	}
	int pre = 0;
	for (int i = 0; i < (int) Check.size(); i++) {
		for (int j = pre; j < Check[i]; j++)
			printf("%c", ans[j]);
		for (int j = 1; j <= sspp[i]; j++)
			printf("%c", ss[8]);
		pre = Check[i];
	}
	printf("\n");
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long LL;

int mod=1000000007;

int main(){
  int H, W;
  cin >> H >> W;
  char G[1010][1010];
  for(int i=1; i<=H; i++){
    for(int j=1; j<=W; j++){
      cin >> G[i][j];      
    }
  }
  LL dp[1010][1010];
  for(int i=1; i<=H; i++){
    for(int j=1; j<=W; j++){
      dp[i][j]=0;
    }
  }
  for(int i=1; i<=H; i++){
    if(G[i][1]=='.') dp[i][1]=1;
    else break;
  }
  for(int i=1; i<=W; i++){
    if(G[1][i]=='.') dp[1][i]=1;
    else break;
  }
  for(int i=1; i<H; i++){
    for(int j=1; j<W; j++){
      if(G[i][j+1]=='.') dp[i+1][j+1]+=dp[i][j+1];
      if(G[i+1][j]=='.') dp[i+1][j+1]+=dp[i+1][j];
      if(dp[i+1][j+1]>=mod) dp[i+1][j+1]%=mod;
    }
  }
  cout << dp[H][W] << endl;
  
  return 0;
}

Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

void fin(){
	freopen("test.txt", "r", stdin);
}

bool sametime(int s1, int s2){
	int e1 = s1+29, e2 = s2+29;
	if(s1 <= e2 && s2 <= e1) return true;
	return false;
}

bool canwatch(vector<int> &v, int s){
	rep(i, v.size()){
		if( sametime(v[i], s)) return false;
	}
	return true;
}

int main(){
//	fin();
	int n;
	while(cin >> n, n){
		map<string, int> m;
		vector<int> time;
		rep(i, n){
			string name;
			int w, start;
			cin >> name >> w >> start;
			start = start%100 + start/100*60 + w*60*24;
			m[name] = start;
			time.push_back(start);
		}
		vector<int> watch;
		int p;
		cin >> p;
		bool ng = false;
		rep(i, p){
			string name;
			cin >> name;
			if(!canwatch(watch, m[name])) ng = true;
			watch.push_back(m[name]);
		}

		sort(all(time));
		rep(i, time.size()){
			if(!canwatch(watch, time[i])) continue;
			watch.push_back(time[i]);
		}

		if(ng)cout << -1 << endl;
		else cout << watch.size() << endl;
	}

	return 0;
}

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

#define _LL long long

bool getAns(_LL a, _LL b, _LL c)
{
    if( a + b >= c ) return false;
    _LL r = c - a- b;
    return 4 * a * b < r * r;
}

int main()
{
    _LL a, b, c;
    cin >> a >> b >> c;
    if( getAns(a, b, c) )
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int s = 0, m = n;
    while (m > 0) {
        s += m % 10;
        m /= 10;
    }
    cout << (n % s ? "No" : "Yes");
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		Arrays.sort(A);
		Arrays.sort(B);
		Arrays.sort(C);
		long[] cnt1 = new long[N];
		long[] cnt2 = new long[N];
		for(int i = 0;i < N;i++) {
			int target = B[i];
			int left = 0;
			int right = A.length;
			while(left < right) {
				int middle = (left + right)/2;
				if(A[middle] >= target) {
					right = middle;
				}else  {
					left = middle+1;
				}
			}
			cnt1[i] = left;
		}
		for(int i = 0;i < N;i++) {
			int target=B[i]+1;
			int left = 0;
			int right = C.length;
			while(left < right) {
				int middle = (left + right)/2;
				if(C[middle] >= target) {
					right = middle;
				}else  {
					left = middle+1;
				}
			}
			cnt2[i]= (C.length-left);
		}
		long res = 0;
		for(int i = 0;i < N;i++) {
			res += cnt1[i]*cnt2[i];
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 94564
#include <bits/stdc++.h>
using namespace std;
long n;
double a[11];
string s[11];
double kq=0;
int main()
{
   cin>>n;
   for(long i=1;i<=n;i++)
   {
       cin>>a[i]>>s[i];
   }
   for(long i=1;i<=n;i++)
   {
       if(s[i]=="JPY") kq+=a[i];
       if(s[i]=="BTC") kq+=a[i]*380000;
   }
   cout<<kq;
}


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

int main ()
{
	long a,b,n,aa[100],bb[100];

	cin >> a >> b >> n;
	if (n == 0)
	{
		cout << '0' << endl;
	}

	for (int i = 0; i < n; i++)
	{
		cin >> aa[i] >> bb[i];
	}

	for (int i = 0; i < n; i++)
	{
		if (aa[i] <= a && bb[i] > a)
		{
			cout << '1' << endl;
			break;
		}
		else if (aa[i] < b && bb[i] >= b)
		{
			cout << '1' << endl;
			break;
		}
		else if (a <= aa[i] && bb[i] <= b)
		{
			cout << '1' << endl;
			break;
		}
		else if (i == n - 1)
		{
			cout << '0' << endl;
		}
	}
}



Measured memory_bytes: 3116
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N, M;
   cin >> N >> M;
   if (abs(N - M) >= 2) cout << 0 << endl;
   else {
      ll ans = 1;
      for (int i = 1; i <= N; i++) {
         ans *= i;
         ans %= MOD;
      }
      for (int i = 1; i <= M; i++) {
         ans *= i;
         ans %= MOD;
      }
      if (N == M) {
         ans *= 2;
         ans %= MOD;
      }
      cout << ans << endl;
   }

   return 0;
}


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

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, w;
  cin >> n >> w;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  long long dp[n + 1][w + 1] = {};
  for (int i = 0; i < n; i++) {
    for (int sum = 0; sum <= w; sum++) {
      if (sum - a[i] >= 0) {
        chmax(dp[i + 1][sum], dp[i][sum - a[i]] + b[i]);
      }
      chmax(dp[i + 1][sum], dp[i][sum]);
    }
  }
  cout << dp[n][w] << '\n';
  return 0;
}

Measured memory_bytes: 82396
n, w = gets.strip.split.map(&:to_i)
vw = readlines.map {|l| l.strip.split.map(&:to_i) }

dp = Array.new(n+1) { [0]*(w+1) }

(n).times do |i|
  (w+1).times do |j|
    cv, cw = vw[i]
    if j < cw
      dp[i+1][j] = dp[i][j]
    else
      dp[i+1][j] = [dp[i][j], dp[i+1][j-cw]+cv].max
    end
  end
end

# dp.each {|l|p l}

p dp.last.last



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

//テストケースはあんまり見ないほうが良い。デバッグする能力が必要.
int main(){
    ll h;
    cin >> h;
    int a = log2(h);
    ll ans=0;
    rep(i,a+1)ans+=pow(2,i);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication11 {
    class Program {

        

        static void Main(string[] args) {
            new Program().solve();
        }

        void solve() {
            while (true) {
                string input = Console.ReadLine();
                if (input == "-1" ) {
                    return;
                }
                int splitDigit =  int.Parse(input);
                Console.WriteLine(quaternary.convertTo(splitDigit));
            }
        }

        
    }

    class quaternary {
        public static string convertTo(int input) {
            string quant = "";
            int copy = input;

            while (copy >= 4) {
                quant = copy%4 + quant ;
                copy /= 4;
            }
            quant = copy + quant;
            return quant;
        }
    }
}

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

using namespace std;

int main()
{
  int H, W;
  string S[8];

  cin >> H >> W;
  for(int i = 0; i < H; i++) cin >> S[i];

  int beet = 0;
  for(int i = 0; i < H; i++) {
    for(auto &c : S[i]) beet += c == '#';
  }
  if(beet == H + W - 1) puts("Possible");
  else puts("Impossible");
}

Measured memory_bytes: 256
get_input(Number):-
    current_input(Input),
    read_string(Input, ' \n', '', _, String),
    number_string(Number, String). 

f(0, 'pon').
f(1, 'pon').
f(2, 'hon').
f(3, 'bon').
f(4, 'hon').
f(5, 'hon').
f(6, 'pon').
f(7, 'hon').
f(8, 'pon').
f(9, 'hon').

main:-
    get_input(A),
    N is A mod 10,
    f(N, R),
    writeln(R).


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

int main(){
    int k,n;
    cin>>k>>n;
    int dis=-1;
    int a[200010];
    rep(i, n){
        cin>>a[i];
        if(i!=0){
            int tmp=a[i]-a[i-1];
            dis=max(dis,tmp);
        }
    }
    int tmp=k+a[0]-a[n-1];
    dis=max(dis,tmp);
    cout<<k-dis<<endl;
}

Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  string s;
  cin >> s;
  bool flag1, flag2, flag3;
  flag1 = flag2 = flag3 = false;
  if (s[a] == '-' && s.size() == a + b + 1) flag1 = true;
  for (int i = 0; i < a; i++) {
    if (s[i] == '-') {
      flag2 = false;
      break;
    }
    else flag2 = true;
  }
  for (int i = a + 1; i < a + b + 1; i++) {
    if (s[i] == '-') {
      flag3 = false;
      break;
    }
    else flag3 = true;
  }
  if (flag1 && flag2 & flag3) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  vector<int>V(N);
  for(int i=0;i<N;i++)cin>>V[i];
  int ans=0;
  for(int l=0;l<=N;l++){
    for(int r=0;r<=N;r++){
      if(l+r>N)break;
      if(l+r>K)break;
      int res=0;
      vector<int>t;
      for(int i=0;i<l;i++)t.emplace_back(V[i]);
      for(int i=0;i<r;i++)t.emplace_back(V[N-1-i]);
      sort(t.begin(),t.end());
      int M=t.size();
      for(int i=0;i<K-l-r;i++){
        if(i>=M)break;
        if(t[i]>=0)break;
        t[i]=0;
      }
      for(int i=0;i<M;i++)res+=t[i];
      ans=max(ans,res);
    }
  }
  cout<<ans<<endl;
}


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

#define INF 1e9
#define LLINF 1e18
#define pi 3.14159265358979323
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    string s;
    cin >> s;
    int w;
    cin >> w;
    for (int i = 0; i < s.size(); i += w) {
        cout << s.at(i);
    }
    cout << endl;
}

Measured memory_bytes: 3580